# Elections API: Candidates, Officeholders, Ballots (Ballotpedia) (`nabeelbaghoor/elections-candidates-officeholders-api`) Actor

US elections data from the Ballotpedia API: current elected officials with contact details and voting districts for any address point, election dates, candidates on the ballot with results, and ballot measures by state or location, federal to local. Bring your own key.

- **URL**: https://apify.com/nabeelbaghoor/elections-candidates-officeholders-api.md
- **Developed by:** [Nabeel Hassan](https://apify.com/nabeelbaghoor) (community)
- **Categories:** Developer tools, Lead generation, News
- **Features:** Limited permissions
- **Stats:** 2 total users, 1 monthly users, 100.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

from $10.00 / 1,000 elected official returneds

This Actor is paid per event. You are not charged for the Apify platform usage, but only a fixed price for specific events.

Learn more: https://docs.apify.com/actors/running/actors-in-store.md#pay-per-event

## What's an Apify Actor?

An Actor is a serverless cloud program that runs on the Apify platform. It has two run modes.
In Batch mode, an Actor accepts a well-defined JSON input, performs an action which can take anything from a few seconds to a few hours,
and optionally produces a well-defined JSON output, datasets with results, or files in key-value store.
In Standby mode, an Actor provides a web server which can be used as a website, API, or an MCP server.

Apify vocabulary and the platform model are defined once, in the agent quickstart at https://apify.com/agents.md.

## How to integrate an Actor?

If asked about integration, you help developers integrate Actors into their projects.
You adapt to their stack and deliver integrations that are safe, well-documented, and production-ready.

Do not guess an integration path. Every one of them is in the agent quickstart at https://apify.com/agents.md: the Apify MCP server, Agent Skills with the Apify CLI, the JavaScript and Python clients, the REST API, and the account-free path for an agent with no human to sign in. It also carries the rule on stating cost before the first paid run.

For examples already wired to this Actor's own input schema, see the [API](#api) section below.

Each client library has reference documentation the quickstart does not restate: [JavaScript/TypeScript](https://docs.apify.com/api/client/js/docs.md) (`npm install apify-client`) and [Python](https://docs.apify.com/api/client/python/docs.md) (`pip install apify-client`).

# README

## Elections API: Candidates, Officeholders, Ballots (Ballotpedia)

Look up US elected officials, voting districts, election dates, candidates with results and ballot measures for any address point or state, as one clean dataset row per record.

Ballotpedia, published by the Lucy Burns Institute, researches every federal and state office, state legislative seat, the largest cities and many counties, school districts and judicial seats, and every statewide ballot measure. This actor wraps the Ballotpedia Geographic APIs and Ballot measures endpoints on api4.ballotpedia.org: give latitude and longitude points or pick states and an election date, and get deduplicated rows with the officeholder or candidate, office, level, branch, district, party, contact details, vote totals and Ballotpedia links already flattened, ready to download as JSON, CSV or Excel, schedule before each election, or feed into sample ballot tools, "who represents me" lookups, voter guides, CRM enrichment, civic tech apps, RAG pipelines and AI agents.

Bring your own API key: Ballotpedia issues keys to its licensed data clients (see below).

### What it does

- **Officeholders by location**: the current elected officials who represent a point, federal, state and local, with office, level (Federal, State, Local), branch (Executive, Legislative, Judicial), district, party, status, phone, email, website and Ballotpedia profile link.
- **Voting districts by location**: every district a point lies in (Congress, state legislative upper and lower, county, city, school district, judicial and special districts) with OCD division IDs, Census geo IDs and boundary end dates, optionally as of a past date around redistricting.
- **Election dates by location**: the elections at a point from one year back to one year ahead.
- **Election dates by state, year and type**: General, Primary, Special and Recall election dates from 2018 on, with district and whether candidate lists are complete.
- **Ballot and results by location or by state**: every race on the ballot for an election date, one row per candidate, with office, district, party, incumbency, write in, withdrawn but still on the ballot, status (such as On the Ballot, Advanced, Won or Lost), vote totals, ranked choice voting rounds, running mates, FEC IDs and Ballotpedia disclaimers. By state filters by office level, office branch and district type.
- **Ballot measures**: the dates with ballot measures in a year, and every state and local ballot measure for a state and election date, with type, status, yes and no vote totals and what a yes or no vote means.
- **Pay only for results**: refused and empty lookups become a free row that says why.

Nothing is written to any Ballotpedia account: only GET endpoints are called. Ballotpedia's bulk data file downloads are deliberately not offered, and every run is capped by Max results, as Ballotpedia's terms require.

### How to use it

1. Get a Ballotpedia API key from Ballotpedia's data sales team (developer.ballotpedia.org documents the API; keys come with a licensed data package).
2. Paste it into the **API key** field (or set a `DATA_API_KEY` environment variable on the actor). It is sent only to api4.ballotpedia.org in the x-api-key header and never logged.
3. Choose **What to get**. For a location mode, add points as latitude,longitude (geocode addresses first). For a state mode, pick **States** and set the **Election date** or **Election year**.
4. Press Start and download the dataset, or schedule the actor for a recurring feed before each election.

The default Ballotpedia plan allows 5 requests a second with a burst of 100 and 200,000 a day; the actor paces itself at 120 a minute by default. Each point is one request. When the quota is used up the run ends cleanly and says so.

### Input

| Field | Used by | Example |
|---|---|---|
| What to get | all | Officeholders by location |
| Locations (latitude, longitude) | officeholders, districts, election dates and ballot by location | 43.079896,-89.3818172 |
| Districts in effect on | Voting districts by location | 2022-06-01 |
| Extra details (collections) | officeholders, ballots | Contact details, Social media |
| States | election dates by state, ballot by state, ballot measures | Wisconsin, California |
| Election date | ballots, ballot measures, election dates filter | 2026-11-03 |
| Election year | election dates by state, ballot measure dates | 2026 |
| Election types | Election dates by state | General, Primary |
| Office levels, Office branches | Ballot by state | Federal, Legislative |
| District types | Ballot by state, ballot measures | State, County |
| Max results | all | 100 |
| Requests per minute | all | 120 |
| API key | all | your Ballotpedia key |

Example input for every candidate for federal office on the Wisconsin general election ballot:

```json
{
    "mode": "electionsByState",
    "states": ["WI"],
    "electionDate": "2024-11-05",
    "officeLevels": ["Federal"],
    "collections": ["contact"],
    "maxResults": 200
}
```

### Example output

The shape of one officeholder row (values illustrative, from Ballotpedia's documented example):

```json
{
    "mode": "officeholders",
    "recordType": "officeholder",
    "query": "43.079896,-89.3818172",
    "found": true,
    "id": 37193,
    "name": "Mark Pocan",
    "lastName": "Pocan",
    "state": "WI",
    "districtId": 430,
    "districtName": "Wisconsin District 2",
    "districtType": "Congress",
    "preciseBoundary": true,
    "officeId": 10859,
    "officeName": "U.S. House Wisconsin District 2",
    "officeType": "Representative",
    "officeLevel": "Federal",
    "officeBranch": "Legislative",
    "status": "Current",
    "party": "Democratic Party",
    "partyId": 2,
    "phone": "202-225-2906",
    "website": "https://pocan.house.gov/",
    "ballotpediaUrl": "https://ballotpedia.org/Mark_Pocan",
    "note": null,
    "record": { "id": 37193, "...": "the full Ballotpedia officeholder with its office and district" }
}
```

Candidate rows carry `raceId`, `raceUrl`, `raceYear`, `raceType`, `stageType`, `stageParty`, `isIncumbent`, `isWriteIn`, `status`, `votes`, `rcvRounds`, `runningMate`, `fecId` and `disclaimers`; ballot measure rows `measureType`, `officialTitle`, `status`, `yesVotes`, `noVotes`, `yesVote` and `noVote`; district rows `districtOcdId`, `districtGeoId` and `districtEndDate`; election date rows `electionDate`, `electionType`, `description` and `candidateListsComplete`. Every row keeps the full Ballotpedia record under `record`.

### Pricing

| Event | Price |
|---|---|
| Elected official returned | 0.01 USD |
| Candidate on the ballot returned | 0.008 USD |
| Ballot measure returned | 0.008 USD |
| Voting district returned | 0.005 USD |
| Election date returned | 0.005 USD |

Refused and empty lookups are free rows. Platform usage is included. The Ballotpedia key and its data licence are billed by Ballotpedia separately.

### FAQ

#### What is the Ballotpedia API?

Ballotpedia is the nonpartisan online encyclopedia of American politics, published by the Lucy Burns Institute. Its Geographic APIs on api4.ballotpedia.org return voting districts, current officeholders, election dates and ballots with results for a latitude and longitude or a state, and its Ballot measures endpoints return state and local ballot measures. Access needs an API key from Ballotpedia's data sales team.

#### Do I need an API key?

Yes. Ballotpedia answers nothing without one, and the actor ends the run with instructions if none is set. Keys come with a licensed Ballotpedia data package; contact Ballotpedia's data sales team through developer.ballotpedia.org. What each key reaches depends on the package: a ballot measures package, for example, covers only the two ballot measure modes.

#### How do I find who represents an address?

Geocode the address to latitude and longitude (with the Google Geocoding API, AWS Location or any geocoder), choose Officeholders by location and paste the point. You get the President, US senators and representative, governor and statewide officials, state legislators, and local officials Ballotpedia covers, with phone, email and website.

#### How do I build a sample ballot lookup?

Choose Election dates by location for the voter's point to find the upcoming election dates, then Ballot and results by location with that point and date. Each candidate row carries the race, office, district and party; ballot measures on that ballot come back as their own rows. This is the flow Ballotpedia's own practical guide describes.

#### Can I get election results and vote totals?

Yes, when your Ballotpedia package includes results. Candidate rows then carry the status (Won or Lost), votes, whether results are certified, and ranked choice voting rounds; ballot measure rows carry Approved or Defeated and yes and no vote totals.

#### How do I list every election in a state?

Choose Election dates by state, year and type, pick the state, and optionally a year and types such as Special or Primary. Leave States empty to list election dates in every state, 25 per request.

#### Which offices and districts are covered?

Ballotpedia's officeholder data covers Congress, statewide offices, state legislatures and elected officials in the 100 largest US cities; ballots also cover many county, school board, judicial and special district races. Districts follow Ballotpedia's district types, from Country and Congress down to School district subdivision.

#### Can I download Ballotpedia's whole data set?

No. Ballotpedia licenses its data for use in products as long as third parties cannot bulk download it, so this actor offers query lookups only, capped by Max results, and does not wrap the bulk data file endpoints. Licensed bulk data clients download their files from the Ballotpedia client portal.

### Keyword map

Elections API, election data API, Ballotpedia API, Ballotpedia scraper, elected officials API, who represents me lookup, find my representative, officeholders API, legislator contact list, candidates API, candidate list by state, election results API, sample ballot API, ballot measures API, voting districts by address, OCD division IDs, election dates calendar, voter guide data, civic data, political data, Google Civic Information API alternative.

### How to get your own key

Ballotpedia API keys are issued by Ballotpedia's data sales team to licensed data clients; the developer documentation is at developer.ballotpedia.org. Once you have the key, paste it into the API key field or store it as the DATA_API_KEY secret. If you call the API from a web page instead, Ballotpedia must whitelist your domain first; this actor calls it server side, so no whitelisting is needed.

### Data licence and terms

Ballotpedia content is copyrighted by its editors and contributors, and licensed data sets are Ballotpedia's proprietary property. Ballotpedia's terms let licensees use the data in internal or external products as long as reasonable precautions prevent bulk downloads of the data set by third parties. Run this actor only with your own licensed key and keep the rows within your licence. This actor is not affiliated with or endorsed by Ballotpedia or the Lucy Burns Institute.

# Actor input Schema

## `mode` (type: `string`):

Officeholders by location returns the current elected officials (federal, state and local, with contact details) for each point. Voting districts by location returns the districts a point lies in. Election dates by location lists the elections at a point from one year back to one year ahead; Election dates by state, year and type lists election dates from 2018 on. Ballot and results by location or by state returns every race, candidate and ballot measure on the ballot for an election date, with results where your package includes them. Ballot measure election dates and Ballot measures by state and date cover statewide and local ballot measures.

## `locations` (type: `array`):

Officeholders, voting districts, election dates by location and ballot by location. One point per line as latitude,longitude in decimal degrees (geocode an address first). Each point is one lookup.

## `districtsDate` (type: `string`):

Voting districts by location only. Optional YYYY-MM-DD: returns the district boundaries in effect on that date (useful around redistricting). Leave empty for today.

## `collections` (type: `array`):

Officeholders and ballots by location or state. The collections Ballotpedia adds to each officeholder or candidate. What comes back depends on your API package.

## `states` (type: `array`):

Election dates by state, ballot by state, ballot measure dates and ballot measures. One lookup per state. Optional for the two election date modes (empty means every state); required for ballot by state and ballot measures.

## `electionDate` (type: `string`):

YYYY-MM-DD. Required for ballot and results by location or by state and for ballot measures; an optional exact date filter for election dates by state. The election date modes list the valid dates.

## `year` (type: `string`):

Election dates by state (optional) and ballot measure election dates (required). Ballotpedia election dates start in 2018.

## `electionTypes` (type: `array`):

Election dates by state only. Keep only these election types; empty means all.

## `officeLevels` (type: `array`):

Ballot and results by state only. Keep only races for these levels of government; empty means all.

## `officeBranches` (type: `array`):

Ballot and results by state only. Keep only races for these branches of government; empty means all.

## `districtTypes` (type: `array`):

Ballot and results by state and ballot measures. Keep only districts of these types, such as State or County; empty means all.

## `maxResults` (type: `integer`):

Stops after this many rows (officeholders, candidates, ballot measures, districts or election dates). Ballotpedia licenses its data on the condition that third parties cannot bulk download it, so every run is capped.

## `requestsPerMinute` (type: `integer`):

Pacing ceiling. The default Ballotpedia plan allows 5 requests a second (300 a minute) with a burst of 100 and 200,000 a day.

## `apiKey` (type: `string`):

Your own Ballotpedia API key, sent only to api4.ballotpedia.org in the x-api-key header. Ballotpedia issues keys to licensed data clients through its data sales team. Leave empty to use the DATA_API_KEY environment variable.

## Actor input object example

```json
{
  "mode": "officeholders",
  "locations": [
    "43.079896,-89.3818172"
  ],
  "collections": [
    "contact"
  ],
  "year": "any",
  "electionTypes": [],
  "officeLevels": [],
  "officeBranches": [],
  "districtTypes": [],
  "maxResults": 100,
  "requestsPerMinute": 120
}
```

# Actor output Schema

## `records` (type: `string`):

One row per record returned for the chosen mode.

# API

You can run this Actor programmatically using our API. Below are code examples in JavaScript, Python, and CLI, as well as the OpenAPI specification and MCP server setup.

## JavaScript example

```javascript
import { ApifyClient } from 'apify-client';

// Initialize the ApifyClient with your Apify API token
// Replace the '<YOUR_API_TOKEN>' with your token
const client = new ApifyClient({
    token: '<YOUR_API_TOKEN>',
});

// Prepare Actor input
const input = {
    "locations": [
        "43.079896,-89.3818172"
    ]
};

// Run the Actor and wait for it to finish
const run = await client.actor("nabeelbaghoor/elections-candidates-officeholders-api").call(input);

// Fetch and print Actor results from the run's dataset (if any)
console.log('Results from dataset');
console.log(`💾 Check your data here: https://console.apify.com/storage/datasets/${run.defaultDatasetId}`);
const { items } = await client.dataset(run.defaultDatasetId).listItems();
items.forEach((item) => {
    console.dir(item);
});

// 📚 Want to learn more 📖? Go to → https://docs.apify.com/api/client/js/docs

```

## Python example

```python
from apify_client import ApifyClient

# Initialize the ApifyClient with your Apify API token
# Replace '<YOUR_API_TOKEN>' with your token.
client = ApifyClient("<YOUR_API_TOKEN>")

# Prepare the Actor input
run_input = { "locations": ["43.079896,-89.3818172"] }

# Run the Actor and wait for it to finish
run = client.actor("nabeelbaghoor/elections-candidates-officeholders-api").call(run_input=run_input)

# Fetch and print Actor results from the run's dataset (if there are any)
print(f"💾 Check your data here: https://console.apify.com/storage/datasets/{run.default_dataset_id}")
for item in client.dataset(run.default_dataset_id).iterate_items():
    print(item)

# 📚 Want to learn more 📖? Go to → https://docs.apify.com/api/client/python/docs/quick-start

```

## CLI example

```bash
echo '{
  "locations": [
    "43.079896,-89.3818172"
  ]
}' |
apify call nabeelbaghoor/elections-candidates-officeholders-api --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "type": "http",
            "url": "https://mcp.apify.com/?tools=fetch-actor-details,nabeelbaghoor/elections-candidates-officeholders-api"
        }
    }
}
```

The hosted server signs you in with OAuth on first connect, so no API token belongs in this config. Clients without OAuth support can send an `Authorization: Bearer <APIFY_API_TOKEN>` header instead, using a token from API & Integrations in Apify Console (https://console.apify.com/settings/integrations).

## OpenAPI specification

Download the OpenAPI definition: https://api.apify.com/v2/actors/NQ5w4sn9LZEkJU3l5/builds/TKoBkoOJaljuKysnM/openapi.json
