Elections
Election hub, races, live results, forecasts, maps and the election post feed from x.com. Results data comes from Decision Desk HQ.
IDs are rest IDs as strings. Get an election ID and its chamber IDs from hub, then race IDs from races or keyRaces.
const [election] = await client.elections.hub();
const chamberId = election.info.chambers[0].rest_id;
const races = await client.elections.races(election.rest_id, chamberId);
const forecast = await client.elections.forecast(races[0].rest_id);elections.hub(opts?)
List the featured elections with their chambers. Pass opts.electionId to load one election instead. Uses electionsHubQuery.
elections.featured()
Get the election featured in the live chat. Uses electionsChatStateFeaturedElectionQuery.
elections.races(electionId, chamberId)
List the races of one chamber in an election, with candidates and results. Uses electionRacesQuery.
elections.keyRaces(electionId)
List the key races of an election. Uses electionKeyRacesQuery.
elections.chambers(electionId, chamberId?)
Get the seat overview of each chamber, or of one chamber. Uses electionChamberOverviewsQuery.
elections.liveResults(electionId, opts?)
Get live results across an election's races. Returns { asOfMs, nextCursor, results }. Takes opts.updatedSinceMs, opts.cursor and opts.limit (default 50). Uses electionLiveResultsQuery.
const { results, nextCursor } = await client.elections.liveResults(electionId, { limit: 20 });elections.race(raceId)
Get one race with its candidates and results. Uses electionRacePageQuery.
elections.polls(raceId, opts?)
Get a race's poll averages, from opts.fromDate if set. Returns null when the race has no polling. Uses electionPollAveragesQuery.
elections.forecast(raceId)
Get a race's forecast and the fundamentals, markets and polls behind it. Uses electionRaceForecastQuery.
elections.pulse(raceId)
Get a race's live pulse. Returns null outside election night. Uses electionRaceLivePulseQuery.
elections.map(raceId)
Get the SVG map of a race, with its outline and units. Uses electionRaceMapQuery.
elections.counties(raceId, opts?)
Get county level results of a race. Page with opts.cursor. Uses electionRaceCountiesQuery.
elections.feed(electionId, opts?)
Get the post timeline of an election. Returns a parsed timeline. opts.product is "top" (default) or "latest", with opts.count and opts.cursor. Uses electionsTimelineFeedQuery.
elections.chatState(electionId)
Get whether the election live chat is open, with its broadcast ID. Uses electionsChatStateQuery.
elections.viewers(electionId)
Get how many people are in the election live chat, as a number. Uses electionsChatStateViewerBeatQuery.
elections.dataCredit()
Get the results data provider's name and logo. Uses electionDataCreditQuery.