-
Notifications
You must be signed in to change notification settings - Fork 0
Voter Registration API
JL offers a voter registration api to help individuals get the information they need to register to vote in their home state. The api provides relevant information to the user on how to register in their home state. To use the API follow these instructions. You will need an access token to use the API please see this documentation first.
The simplest way to provide the information to the user if you do not have a developer on staff or are unsure of how to interact with an API is to provide a link to
https://jeffersonslist.com/VoterRegistration/Register
If you have access to edit your HTML directly you can add something like this directly to your code
<a href="https://jeffersonslist.com/VoterRegistration/Register"><button>Register To Vote</button></a>
To interact directly with the API you will need a way to make an HTTP POST call as well as a way to render the JSON response that contains the relevant information. As there are many different front end architectures I will refrain from documenting that here.
The endpoint for submitting information can be found at
https://jeffersonslist.com/api/VoterRegistration/SubmitVoterInfo
The API requires the following fields be submitted with the call these fields are mandatory and will result in an error response if they are missing. The error response on missing fields is a 200 with a list of the fields that are missing in a list of printable strings. This allows you to display the result body if needed.
- Address
- City
- State Abbreviation (Two Letters Only)
- Zip
- Citizen Conformation
The simplest solution to the state input is a dropdown. You can manually build this drop down or we can provide an endpoint to deliver the state information as needed.
The API expects this as a JSON body to the POST for example
{
"Email":"jefferson@theprez.com",
"Address":"931 Thomas Jefferson Parkway",
"City":"Charlottesville",
"StateAbrev":"VA",
"Zip":"22902",
"IsCitizen":true
}
You can make a simple AJAX call to the API as follows
function submitInfo(){
$.ajax({
type: "POST",
url: "https://jeffersonslist.com/api/VoterRegistration/SubmitVoterInfo",
contentType: "application/json",
dataType: "json",
headers: {
"JLAuthToken":"XXXXXXX-TOKEN-XXXXXXXX"
},
data: JSON.stringify({
Email : document.getElementById('email').value,
Address : document.getElementById('address').value,
City : document.getElementById('city').value,
StateAbrev : document.getElementById('state').value,
Zip : document.getElementById('zip').value,
IsCitizen:true
}),
success: function( result ) {
//Display the result data as needed
}
});
}
If successful you will get a response in the following format
{
"id": 46,
"usStateId": 45,
"state": {
"usStateId": 45,
"name": "Virginia",
"abreviation": "VA"
},
"onlineRegistrationLink": "https://vote.elections.virginia.gov/VoterInformation",
"paperRegistrationLink": "https://jefflistcontent.blob.core.windows.net/voter-registration-files/Virginia_Voter_Reg_Form.pdf",
"message": null
}
Most of these fields are not relevant to the consumer however the relevant fields are:
The onlineRegistrationLink is the link, if available to the states website where they can register.
The paperRegistrationLink is a link to the PDF document the user can register with.
The message is any custom message we display, this generally has extra documentation for the user or a note that "no registration is required" which is the case for a few states.