1. Documentation
  2. Examples

Examples

There's a ton of use cases for BallotAPI, but sometimes it's not obvious what API request you want to make to get the data you need. The Quickstart provides some of the most common use cases, and below we'll list more common examples submitted to us. To see the full list of what endpoints are available and what query parameters you can use, checkout the API Endpoints documentation.

Can't find an example for your use case? We encourage you to open an issue or pull request


Here's an example for getting all of the upcoming elections for a specific location, and include the ballots for these elections.

API request:

https://api.ballotapi.org/v1/elections?coords=37.7942635,-122.3955861&dates=now,future&include=contests

Parameters breakdown:


Here's an example to see where a specific ballot contest will show up on the ballot.

API request:

https://api.ballotapi.com/v1/precincts?contests=234-5&extra=merge_geos

Parameters breakdown:

  • contests=234-5 - Filter precincts to those that cover a specific contest (e.g. 2016 San Francisco Mayor, id=234-5).
  • extra=merge_geos - Include a merged geometry of the precincts in the results.

Here's an example to search for the recent races that a candidate is in.

API request:

https://api.ballotapi.com/v1/contests?q=Barbara%20Lee&dates=-365d,future

Parameters breakdown:


Can't find an example for your use case? We encourage you to open an issue or pull request

Want to see the full list of available endpoints? Checkout the API Endpoints documentation.