List elections by cycle, office, state, and district. Includes information about incumbents.
search_elections(data_structure = "tidy", api_key = Sys.getenv("DATAGOV_API_KEY"), cycle = NULL, office = NULL, sort_hide_null = NULL, zip = NULL, sort = NULL, district = NULL, state = NULL, sort_null_only = NULL)
data_structure | A character describing how you want OpenFEC results. Options are 'tidy', 'list', or 'both.' Choose list for raw results. |
---|---|
api_key | API key for https://api.data.gov. Get one at https://api.data.gov/signup. |
cycle | Two-year election cycle in which a candidate runs for office. Calculated from FEC Form 2. The cycle begins with an odd year and is named for its ending, even year. This cycle follows the traditional house election cycle and subdivides the presidential and Senate elections into comparable two-year blocks. To see data for the entire four years of a presidential term or six years of a senatorial term, you will need the election_full flag. |
office | "house", "senate", or "president." |
sort_hide_null | Hide null values on sorted column(s). |
zip | Zip code |
sort | Provide a field to sort by. Use - for descending order. |
district | Two-digit US House distirict of the office the candidate is running for. Presidential, Senate and House at-large candidates will have District 00. |
state | US state or territory where a candidate runs for office |
sort_null_only | Toggle that filters out all rows having sort column that is non-null |