API Documentation

Free, public API for U.S. electoral data. CORS enabled for all origins. No authentication required.

Base URL: https://decisionlabs.aiFormat: JSONCORS: *Rate Limit: 100 req/min
GET/api/elections/:year

All state results for a presidential election year

Parameters

yearpathElection year (1976-2024, divisible by 4)

Example

GET /api/elections/2024

Response

{ year, national: { winner, ev, popular_vote, ... }, states: [...] }
GET/api/elections/:year/:state

Detailed results for one state in one election

Parameters

yearpathElection year
statepathState abbreviation (e.g., PA, CA)

Example

GET /api/elections/2024/PA

Response

{ year, state: { abbr, name, ev_count, margin, candidates, ... } }
GET/api/states/:abbr/history

All presidential results for a state since 1976

Parameters

abbrpathState abbreviation

Example

GET /api/states/PA/history

Response

{ abbr, name, region, ev_history, elections: [...] }
GET/api/polls

Recent polls with optional filtering

Parameters

statequeryFilter by state abbreviation or "national"
daysqueryOnly polls from last N days
min_ratingqueryMinimum pollster rating (A+ through C-)
pollsterqueryFilter by pollster name (partial match)

Example

GET /api/polls?state=PA&days=30

Response

{ polls: [...], meta: { count, filters } }
GET/api/polls/average

Computed polling average with adjustable parameters

Parameters

statequeryState abbreviation or "national"
half_lifequeryRecency half-life in days (default: 14)
min_ratingqueryMinimum pollster rating (default: C-)

Example

GET /api/polls/average?state=PA&half_life=21

Response

{ average, methodology, polls_included: [...] }
GET/api/ratings/:year

Third-party race ratings for the 2026 cycle (Cook, Sabato, Inside Elections). Values are null until verified by automated sourcing.

Parameters

yearpathElection cycle year (2026)

Example

GET /api/ratings/2026

Response

{ year, source_status, last_verified, raters, ratings: [{ raceId, abbr, state, office, cook, sabato, inside_elections }] }
GET/api/swing

Swing analysis between two election years

Parameters

from_yearqueryStarting year (default: 2020)
to_yearqueryEnding year (default: 2024)

Example

GET /api/swing?from_year=2016&to_year=2020

Response

{ from_year, to_year, national_swing, states: [...] }
GET/api/export

Bulk export as CSV or JSON

Parameters

yearqueryElection year (required)
statequeryFilter to one state
formatquery"json" (default) or "csv"

Example

GET /api/export?year=2024&format=csv

Response

CSV file download or JSON array