{
  "openapi": "3.0.1",
  "info": {
    "title": "Elections API: Candidates, Officeholders, Ballots (Ballotpedia)",
    "description": "US elections data from the Ballotpedia API: current elected officials with contact details and voting districts for any address point, election dates, candidates on the ballot with results, and ballot measures by state or location, federal to local. Bring your own key.",
    "version": "0.1",
    "x-build-id": "TKoBkoOJaljuKysnM"
  },
  "servers": [
    {
      "url": "https://api.apify.com/v2"
    }
  ],
  "paths": {
    "/acts/nabeelbaghoor~elections-candidates-officeholders-api/run-sync-get-dataset-items": {
      "post": {
        "operationId": "run-sync-get-dataset-items-nabeelbaghoor-elections-candidates-officeholders-api",
        "x-openai-isConsequential": false,
        "summary": "Executes an Actor, waits for its completion, and returns Actor's dataset items in response.",
        "tags": [
          "Run Actor"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/inputSchema"
              }
            }
          }
        },
        "parameters": [
          {
            "name": "token",
            "in": "query",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "Enter your Apify token here"
          }
        ],
        "responses": {
          "200": {
            "description": "OK"
          }
        }
      }
    },
    "/acts/nabeelbaghoor~elections-candidates-officeholders-api/runs": {
      "post": {
        "operationId": "runs-sync-nabeelbaghoor-elections-candidates-officeholders-api",
        "x-openai-isConsequential": false,
        "summary": "Executes an Actor and returns information about the initiated run in response.",
        "tags": [
          "Run Actor"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/inputSchema"
              }
            }
          }
        },
        "parameters": [
          {
            "name": "token",
            "in": "query",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "Enter your Apify token here"
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/runsResponseSchema"
                }
              }
            }
          }
        }
      }
    },
    "/acts/nabeelbaghoor~elections-candidates-officeholders-api/run-sync": {
      "post": {
        "operationId": "run-sync-nabeelbaghoor-elections-candidates-officeholders-api",
        "x-openai-isConsequential": false,
        "summary": "Executes an Actor, waits for completion, and returns the OUTPUT from Key-value store in response.",
        "tags": [
          "Run Actor"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/inputSchema"
              }
            }
          }
        },
        "parameters": [
          {
            "name": "token",
            "in": "query",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "Enter your Apify token here"
          }
        ],
        "responses": {
          "200": {
            "description": "OK"
          }
        }
      }
    }
  },
  "components": {
    "schemas": {
      "inputSchema": {
        "type": "object",
        "properties": {
          "mode": {
            "title": "What to get",
            "enum": [
              "officeholders",
              "districts",
              "electionDatesByPoint",
              "electionDates",
              "electionsByPoint",
              "electionsByState",
              "ballotMeasureDates",
              "ballotMeasures"
            ],
            "type": "string",
            "description": "Officeholders by location returns the current elected officials (federal, state and local, with contact details) for each point. Voting districts by location returns the districts a point lies in. Election dates by location lists the elections at a point from one year back to one year ahead; Election dates by state, year and type lists election dates from 2018 on. Ballot and results by location or by state returns every race, candidate and ballot measure on the ballot for an election date, with results where your package includes them. Ballot measure election dates and Ballot measures by state and date cover statewide and local ballot measures.",
            "default": "officeholders"
          },
          "locations": {
            "title": "Locations (latitude, longitude)",
            "type": "array",
            "description": "Officeholders, voting districts, election dates by location and ballot by location. One point per line as latitude,longitude in decimal degrees (geocode an address first). Each point is one lookup.",
            "items": {
              "type": "string"
            }
          },
          "districtsDate": {
            "title": "Districts in effect on",
            "type": "string",
            "description": "Voting districts by location only. Optional YYYY-MM-DD: returns the district boundaries in effect on that date (useful around redistricting). Leave empty for today."
          },
          "collections": {
            "title": "Extra details (collections)",
            "type": "array",
            "description": "Officeholders and ballots by location or state. The collections Ballotpedia adds to each officeholder or candidate. What comes back depends on your API package.",
            "items": {
              "type": "string",
              "enum": [
                "contact",
                "social"
              ],
              "enumTitles": [
                "Contact details (phone, email, website)",
                "Social media"
              ]
            },
            "default": [
              "contact"
            ]
          },
          "states": {
            "title": "States",
            "type": "array",
            "description": "Election dates by state, ballot by state, ballot measure dates and ballot measures. One lookup per state. Optional for the two election date modes (empty means every state); required for ballot by state and ballot measures.",
            "items": {
              "type": "string",
              "enum": [
                "AL",
                "AK",
                "AZ",
                "AR",
                "CA",
                "CO",
                "CT",
                "DE",
                "DC",
                "FL",
                "GA",
                "HI",
                "ID",
                "IL",
                "IN",
                "IA",
                "KS",
                "KY",
                "LA",
                "ME",
                "MD",
                "MA",
                "MI",
                "MN",
                "MS",
                "MO",
                "MT",
                "NE",
                "NV",
                "NH",
                "NJ",
                "NM",
                "NY",
                "NC",
                "ND",
                "OH",
                "OK",
                "OR",
                "PA",
                "RI",
                "SC",
                "SD",
                "TN",
                "TX",
                "UT",
                "VT",
                "VA",
                "WA",
                "WV",
                "WI",
                "WY"
              ],
              "enumTitles": [
                "Alabama",
                "Alaska",
                "Arizona",
                "Arkansas",
                "California",
                "Colorado",
                "Connecticut",
                "Delaware",
                "District of Columbia",
                "Florida",
                "Georgia",
                "Hawaii",
                "Idaho",
                "Illinois",
                "Indiana",
                "Iowa",
                "Kansas",
                "Kentucky",
                "Louisiana",
                "Maine",
                "Maryland",
                "Massachusetts",
                "Michigan",
                "Minnesota",
                "Mississippi",
                "Missouri",
                "Montana",
                "Nebraska",
                "Nevada",
                "New Hampshire",
                "New Jersey",
                "New Mexico",
                "New York",
                "North Carolina",
                "North Dakota",
                "Ohio",
                "Oklahoma",
                "Oregon",
                "Pennsylvania",
                "Rhode Island",
                "South Carolina",
                "South Dakota",
                "Tennessee",
                "Texas",
                "Utah",
                "Vermont",
                "Virginia",
                "Washington",
                "West Virginia",
                "Wisconsin",
                "Wyoming"
              ]
            }
          },
          "electionDate": {
            "title": "Election date",
            "type": "string",
            "description": "YYYY-MM-DD. Required for ballot and results by location or by state and for ballot measures; an optional exact date filter for election dates by state. The election date modes list the valid dates."
          },
          "year": {
            "title": "Election year",
            "enum": [
              "any",
              "2018",
              "2019",
              "2020",
              "2021",
              "2022",
              "2023",
              "2024",
              "2025",
              "2026",
              "2027",
              "2028",
              "2029",
              "2030"
            ],
            "type": "string",
            "description": "Election dates by state (optional) and ballot measure election dates (required). Ballotpedia election dates start in 2018.",
            "default": "any"
          },
          "electionTypes": {
            "title": "Election types",
            "type": "array",
            "description": "Election dates by state only. Keep only these election types; empty means all.",
            "items": {
              "type": "string",
              "enum": [
                "General",
                "Primary",
                "Special",
                "Recall"
              ],
              "enumTitles": [
                "General",
                "Primary",
                "Special",
                "Recall"
              ]
            },
            "default": []
          },
          "officeLevels": {
            "title": "Office levels",
            "type": "array",
            "description": "Ballot and results by state only. Keep only races for these levels of government; empty means all.",
            "items": {
              "type": "string",
              "enum": [
                "Federal",
                "State",
                "Local"
              ],
              "enumTitles": [
                "Federal",
                "State",
                "Local"
              ]
            },
            "default": []
          },
          "officeBranches": {
            "title": "Office branches",
            "type": "array",
            "description": "Ballot and results by state only. Keep only races for these branches of government; empty means all.",
            "items": {
              "type": "string",
              "enum": [
                "Legislative",
                "Executive",
                "Judicial"
              ],
              "enumTitles": [
                "Legislative",
                "Executive",
                "Judicial"
              ]
            },
            "default": []
          },
          "districtTypes": {
            "title": "District types",
            "type": "array",
            "description": "Ballot and results by state and ballot measures. Keep only districts of these types, such as State or County; empty means all.",
            "items": {
              "type": "string",
              "enum": [
                "Country",
                "Congress",
                "State",
                "State Legislative (Upper)",
                "State Legislative (Lower)",
                "Judicial District",
                "County",
                "County subdivision",
                "City-town",
                "School District",
                "State subdivision",
                "Special district subdivision",
                "Judicial district subdivision",
                "Special District",
                "City-town subdivision",
                "School district subdivision"
              ],
              "enumTitles": [
                "Country",
                "Congress",
                "State",
                "State Legislative (Upper)",
                "State Legislative (Lower)",
                "Judicial District",
                "County",
                "County subdivision",
                "City-town",
                "School District",
                "State subdivision",
                "Special district subdivision",
                "Judicial district subdivision",
                "Special District",
                "City-town subdivision",
                "School district subdivision"
              ]
            },
            "default": []
          },
          "maxResults": {
            "title": "Max results",
            "minimum": 1,
            "maximum": 10000,
            "type": "integer",
            "description": "Stops after this many rows (officeholders, candidates, ballot measures, districts or election dates). Ballotpedia licenses its data on the condition that third parties cannot bulk download it, so every run is capped.",
            "default": 100
          },
          "requestsPerMinute": {
            "title": "Requests per minute",
            "minimum": 1,
            "maximum": 300,
            "type": "integer",
            "description": "Pacing ceiling. The default Ballotpedia plan allows 5 requests a second (300 a minute) with a burst of 100 and 200,000 a day.",
            "default": 120
          },
          "apiKey": {
            "title": "API key (Ballotpedia)",
            "type": "string",
            "description": "Your own Ballotpedia API key, sent only to api4.ballotpedia.org in the x-api-key header. Ballotpedia issues keys to licensed data clients through its data sales team. Leave empty to use the DATA_API_KEY environment variable."
          }
        }
      },
      "runsResponseSchema": {
        "type": "object",
        "properties": {
          "data": {
            "type": "object",
            "properties": {
              "id": {
                "type": "string"
              },
              "actId": {
                "type": "string"
              },
              "userId": {
                "type": "string"
              },
              "startedAt": {
                "type": "string",
                "format": "date-time",
                "example": "2025-01-08T00:00:00.000Z"
              },
              "finishedAt": {
                "type": "string",
                "format": "date-time",
                "example": "2025-01-08T00:00:00.000Z"
              },
              "status": {
                "type": "string",
                "example": "READY"
              },
              "meta": {
                "type": "object",
                "properties": {
                  "origin": {
                    "type": "string",
                    "example": "API"
                  },
                  "userAgent": {
                    "type": "string"
                  }
                }
              },
              "stats": {
                "type": "object",
                "properties": {
                  "inputBodyLen": {
                    "type": "integer",
                    "example": 2000
                  },
                  "rebootCount": {
                    "type": "integer",
                    "example": 0
                  },
                  "restartCount": {
                    "type": "integer",
                    "example": 0
                  },
                  "resurrectCount": {
                    "type": "integer",
                    "example": 0
                  },
                  "computeUnits": {
                    "type": "integer",
                    "example": 0
                  }
                }
              },
              "options": {
                "type": "object",
                "properties": {
                  "build": {
                    "type": "string",
                    "example": "latest"
                  },
                  "timeoutSecs": {
                    "type": "integer",
                    "example": 300
                  },
                  "memoryMbytes": {
                    "type": "integer",
                    "example": 1024
                  },
                  "diskMbytes": {
                    "type": "integer",
                    "example": 2048
                  }
                }
              },
              "buildId": {
                "type": "string"
              },
              "defaultKeyValueStoreId": {
                "type": "string"
              },
              "defaultDatasetId": {
                "type": "string"
              },
              "defaultRequestQueueId": {
                "type": "string"
              },
              "buildNumber": {
                "type": "string",
                "example": "1.0.0"
              },
              "containerUrl": {
                "type": "string"
              },
              "usage": {
                "type": "object",
                "properties": {
                  "ACTOR_COMPUTE_UNITS": {
                    "type": "integer",
                    "example": 0
                  },
                  "DATASET_READS": {
                    "type": "integer",
                    "example": 0
                  },
                  "DATASET_WRITES": {
                    "type": "integer",
                    "example": 0
                  },
                  "KEY_VALUE_STORE_READS": {
                    "type": "integer",
                    "example": 0
                  },
                  "KEY_VALUE_STORE_WRITES": {
                    "type": "integer",
                    "example": 1
                  },
                  "KEY_VALUE_STORE_LISTS": {
                    "type": "integer",
                    "example": 0
                  },
                  "REQUEST_QUEUE_READS": {
                    "type": "integer",
                    "example": 0
                  },
                  "REQUEST_QUEUE_WRITES": {
                    "type": "integer",
                    "example": 0
                  },
                  "DATA_TRANSFER_INTERNAL_GBYTES": {
                    "type": "integer",
                    "example": 0
                  },
                  "DATA_TRANSFER_EXTERNAL_GBYTES": {
                    "type": "integer",
                    "example": 0
                  },
                  "PROXY_RESIDENTIAL_TRANSFER_GBYTES": {
                    "type": "integer",
                    "example": 0
                  },
                  "PROXY_SERPS": {
                    "type": "integer",
                    "example": 0
                  },
                  "PROXY_UNBLOCKER_UNITS": {
                    "type": "integer",
                    "example": 0
                  }
                }
              },
              "usageTotalUsd": {
                "type": "number",
                "example": 0.00005
              },
              "usageUsd": {
                "type": "object",
                "properties": {
                  "ACTOR_COMPUTE_UNITS": {
                    "type": "integer",
                    "example": 0
                  },
                  "DATASET_READS": {
                    "type": "integer",
                    "example": 0
                  },
                  "DATASET_WRITES": {
                    "type": "integer",
                    "example": 0
                  },
                  "KEY_VALUE_STORE_READS": {
                    "type": "integer",
                    "example": 0
                  },
                  "KEY_VALUE_STORE_WRITES": {
                    "type": "number",
                    "example": 0.00005
                  },
                  "KEY_VALUE_STORE_LISTS": {
                    "type": "integer",
                    "example": 0
                  },
                  "REQUEST_QUEUE_READS": {
                    "type": "integer",
                    "example": 0
                  },
                  "REQUEST_QUEUE_WRITES": {
                    "type": "integer",
                    "example": 0
                  },
                  "DATA_TRANSFER_INTERNAL_GBYTES": {
                    "type": "integer",
                    "example": 0
                  },
                  "DATA_TRANSFER_EXTERNAL_GBYTES": {
                    "type": "integer",
                    "example": 0
                  },
                  "PROXY_RESIDENTIAL_TRANSFER_GBYTES": {
                    "type": "integer",
                    "example": 0
                  },
                  "PROXY_SERPS": {
                    "type": "integer",
                    "example": 0
                  },
                  "PROXY_UNBLOCKER_UNITS": {
                    "type": "integer",
                    "example": 0
                  }
                }
              }
            }
          }
        }
      }
    }
  }
}