This is a small esm library to get polling data from 538. Currently it copies the api structure and only changes types for convenience (e.g. parsing dates from date strings)
import { fetchPolls } from "538-polls"
let polls = await fetchPolls("senate", 2022, "nevada")
let avg = await fetchPollingAverage("senate", 2022, "nevada")
type | cycle | entity |
---|---|---|
approval favorability |
❌ | institution person |
generic-ballot | ✔ | ❌ (always dem vs rep) |
governor house senate |
✔ | state |
governor-recall | ❌ | state |
president-general president-primary-d president-primary-r |
✔ | state "national" |