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/minGET
/api/elections/:yearAll state results for a presidential election year
Parameters
yearpathElection year (1976-2024, divisible by 4)Example
GET /api/elections/2024Response
{ year, national: { winner, ev, popular_vote, ... }, states: [...] }GET
/api/elections/:year/:stateDetailed results for one state in one election
Parameters
yearpathElection yearstatepathState abbreviation (e.g., PA, CA)Example
GET /api/elections/2024/PAResponse
{ year, state: { abbr, name, ev_count, margin, candidates, ... } }GET
/api/states/:abbr/historyAll presidential results for a state since 1976
Parameters
abbrpathState abbreviationExample
GET /api/states/PA/historyResponse
{ abbr, name, region, ev_history, elections: [...] }GET
/api/pollsRecent polls with optional filtering
Parameters
statequeryFilter by state abbreviation or "national"daysqueryOnly polls from last N daysmin_ratingqueryMinimum pollster rating (A+ through C-)pollsterqueryFilter by pollster name (partial match)Example
GET /api/polls?state=PA&days=30Response
{ polls: [...], meta: { count, filters } }GET
/api/polls/averageComputed 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=21Response
{ average, methodology, polls_included: [...] }GET
/api/ratings/:yearThird-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/2026Response
{ year, source_status, last_verified, raters, ratings: [{ raceId, abbr, state, office, cook, sabato, inside_elections }] }GET
/api/swingSwing 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=2020Response
{ from_year, to_year, national_swing, states: [...] }GET
/api/exportBulk export as CSV or JSON
Parameters
yearqueryElection year (required)statequeryFilter to one stateformatquery"json" (default) or "csv"Example
GET /api/export?year=2024&format=csvResponse
CSV file download or JSON array