CivicAPI Documentation: Difference between revisions
No edit summary |
No edit summary |
||
Line 114: | Line 114: | ||
==poll== |
==poll== |
||
The poll endpoint will give you the latest polls on various issues such as Trump vs. Harris, Biden approval rating, Harris approval rating, etc. |
The <code>poll</code> endpoint will give you the latest polls on various issues such as Trump vs. Harris, Biden approval rating, Harris approval rating, etc. |
||
(not implemented yet; no docs) |
(not implemented yet; no docs) |
||
==prediction== |
==prediction== |
||
The prediction endpoint will give you predictions on the 2024 US presidential race |
The <code>prediction</code> endpoint will give you predictions on the 2024 US presidential race |
||
(not implemented yet; no docs) |
(not implemented yet; no docs) |
||
==amendment== |
==amendment== |
||
The amendment endpoint will return amendments from the US Constitution (and maybe other countries in the future) |
The <code>amendment</code> endpoint will return amendments from the US Constitution (and maybe other countries in the future) |
||
(not implemented yet; no docs) |
|||
==upcoming== |
|||
The <code>upcoming</code> endpoint will return upcoming elections. |
|||
(not implemented yet; no docs) |
(not implemented yet; no docs) |
Revision as of 21:17, 24 July 2024
WIP documentation of ElectionsAPI. ElectionsAPI, as the name suggests, is an API which provides political data, both for US and international.
Requests are rate-limited to prevent abuse.
election
The election
endpoint will give you access to election information, both historic and current.
/v1/election/{country}/{election}/{year}
This can be used to fetch information about a country-wide election. The year
argument can be used to narrow down the results to a specific year. If one isn't specified, it will return all the elections found.
Valid election
arguments are presidential
, parliament
, and governor
Parameters
election_name
- The name of the electionelection_type
- The type of election. Currently, valid election types arepopular
,primary
,parliament
, andelectoral
.percent_reporting
- Specifies the number of precincts reporting.votes_needed
- Will list the number of votes needed in a parliamentary or electoral vote to win the election. This parameter does not exist if the election_type ispopular
.round
- Specifies the current round of voting in the election.is_snap_election
- Specifies if the election is a snap election.is_ongoing
- Specifies if the election is currently ongoing.has_map
- Specifies if the election supports a map. A map can be generated with/v1/election/{country}/{election}/{year}/map
(more information below)map
- Specifies the map file to use.polls_open
- Specifies the date of the polls for the election opening, in Epoch milliseconds.polls_close
- Specifies the date of the polls for the election closing, in Epoch milliseconds.term_start
- Specifies when the winner's term will begin, in Epoch milliseconds.term_end
- Specifies when the winner's term will end, in Epoch milliseconds.sources
- Lists the sources which were used to gather the data.candidates
- The list of candidates in the race.name
- Candidate's nameincumbent
- Specifies whether the candidate is an incumbent.write_in
- Specifies whether the candidate is a write-in candidate.dropped_out
- Specifies whether the candidate has dropped out of the race. Only exists if the election_type isprimary
.party
- Candidate's partyvotes
- The number of votes the candidate receivedpercent
- The percentage of votes the candidate receivedelectoral_votes
- The number of electoral votes the candidate received. Only exists if the election_type iselectoral
.seats_won
- The number of seats the candidate won. Only exists if the election_type isparliament
.states_carried
- The number of states the candidate received. Only exists if the election_type iselectoral
.winner
- Specifies if the candidate has been declared the winner.
region_results
- Results of the states/regions/constituencies/counties/oblasts/etc.region
- The regioncandidates
- The list of candidates in the region.name
- Candidate's nameparty
- Candidate's partyvotes
- The number of votes the candidate receivedpercent
- The percentage of votes the candidate received
electoral_votes
- Specifies the number of electoral votes of the region. Only exists if the election_type iselectoral
.percent_reporting
- Specifies the number of precincts reporting in the region.winner
- The winner of the region.fill
- The region winner's hex color, for filling maps in with.
Example URL: https://computernewb.com/election/api/v1/election/us/presidential/1789
/v1/election/{country}/{election}/{year}/map
This endpoint can be used to generate a map. It returns a PNG of a filled out map. This endpoint will only work if has_map
is true
. Otherwise, it will throw a 404 error.
Example URL: https://computernewb.com/election/api/v1/election/us/presidential/1789/map
/v1/election/{country}/{election}/{year}/{region}
This can be used to fetch information about a specific region's election results. The year
argument can be used to narrow down the results to a specific year. If one isn't specified, it will return all the elections found.
Valid election
arguments are presidential
and governor
Parameters
election_name
- The name of the electionelection_type
- The type of election. Currently, valid election types arepopular
,primary
,parliament
, andelectoral
.votes_needed
- Will list the number of votes needed in a parliamentary or electoral vote to win the election. This parameter does not exist if the election_type ispopular
.percent_reporting
- Returns the number of precincts reporting in the election.round
- Specifies the current round of voting in the election.is_snap_election
- Specifies if the election is a snap election.is_ongoing
- Specifies if the election is currently ongoing.has_map
- Specifies if the election supports a map. A map can be generated with/v1/election/{country}/{election}/{year}/map
(more information below)map
- Specifies the map file to use.polls_open
- Specifies the date of the polls for the election opening, in Epoch milliseconds.polls_close
- Specifies the date of the polls for the election closing, in Epoch milliseconds.term_start
- Specifies when the winner's term will begin, in Epoch milliseconds.term_end
- Specifies when the winner's term will end, in Epoch milliseconds.sources
- Lists the sources which were used to gather the data.candidates
- The list of candidates in the race.name
- Candidate's nameincumbent
- Specifies whether the candidate is an incumbent.write_in
- Specifies whether the candidate is a write-in candidate.dropped_out
- Specifies whether the candidate has dropped out of the race. Only exists if the election_type isprimary
.party
- Candidate's partyvotes
- The number of votes the candidate receivedpercent
- The percentage of votes the candidate receivedelectoral_votes
- The number of electoral votes the candidate received. Only exists if the election_type iselectoral
.states_carried
- The number of states the candidate received. Only exists if the election_type iselectoral
.seats_won
- The number of seats the candidate won. Only exists if the election_type isparliament
.winner
- Specifies if the candidate has been declared the winner.
region_results
- Results of the counties/districts/parishes/boroughs/etc.region
- The region namecandidates
- The list of candidates in the region.name
- Candidate's nameparty
- Candidate's partyvotes
- The number of votes the candidate receivedpercent
- The percentage of votes the candidate received
electoral_votes
- Specifies the number of electoral votes of the region. Only exists if the election_type iselectoral
.percent_reporting
- Specifies the number of precincts in the region reporting.winner
- The winner of the region.fill
- The region winner's hex color, for filling maps in with.
Example URL: https://computernewb.com/election/api/v1/election/us/governor/2022/mn
/v1/election/{country}/{election}/{year}/{region}/map
This endpoint can be used to generate a map. It returns a PNG of a filled out map. This endpoint will only work if has_map
is true
. Otherwise, it will throw a 404 error.
Example URL: https://computernewb.com/election/api/v1/election/us/governor/2022/mn/map
/v1/election/{country}/{election}/{year}/{region}/{district}
This endpoint can be used to fetch results for a specific county/region/district/etc. This does not support the map
argument yet.
(not implemented yet; no docs)
poll
The poll
endpoint will give you the latest polls on various issues such as Trump vs. Harris, Biden approval rating, Harris approval rating, etc.
(not implemented yet; no docs)
prediction
The prediction
endpoint will give you predictions on the 2024 US presidential race
(not implemented yet; no docs)
amendment
The amendment
endpoint will return amendments from the US Constitution (and maybe other countries in the future)
(not implemented yet; no docs)
upcoming
The upcoming
endpoint will return upcoming elections.
(not implemented yet; no docs)