Accessing data on County level elected officials

103 views
Skip to first unread message

Eric Foster

unread,
Mar 13, 2024, 1:37:37 PMMar 13
to Google Civic Information API
Hello everyone.

Can someone please show me how to access and download information on county level elected officials in all 50 States and the territories? I have tried to work through the queries and still haven't been able to get pass error messages, so obviously I have no idea what I'm doing. Any assistance would be greatly appreciated. Thank you in advance.

Ralph Yozzo

unread,
Mar 14, 2024, 2:14:31 AMMar 14
to Google Civic Information API
Hi Eric,

Please post what you have tried.

This is what I tried moments ago and it seems to work well.

GET OFFICES and NAMES  (you can replace new york with any area)

curl \
  'https://civicinfo.googleapis.com/civicinfo/v2/representatives?address=new%20york&key=[YOUR_API_KEY]' \
  --header 'Accept: application/json' \
  --compressed

returns (shows only a part of the response)

...
 {
      "name": "Charles E. Schumer",
      "address": [
        {
          "line1": "322 Hart Senate Office Building",
          "city": "Washington",
          "state": "DC",
          "zip": "20510"
        }
      ],
      "party": "Democratic Party",
      "phones": [
        "(202) 224-6542"
      ],
      "urls": [
        "https://www.schumer.senate.gov/",
        "https://en.wikipedia.org/wiki/Chuck_Schumer"
      ],
      "photoUrl": "http://bioguide.congress.gov/bioguide/photo/S/S000148.jpg",
...

IF you don't know all the offices you can search by ID
GET THE REQUIRED IDs

curl \
  'https://civicinfo.googleapis.com/civicinfo/v2/divisions?query=New%20York%20&key=[YOUR_API_KEY]' \
  --header 'Accept: application/json' \
  --compressed

returns:

{
  "results": [
    {
      "ocdId": "ocd-division/country:us/state:ny",
      "name": "New York"
    },
    {
      "ocdId": "ocd-division/country:us/state:ny/sldl:1",
      "name": "New York Assembly district 1"
    },

Then get the persons by id

...

Also there is an elections API:

curl \
  'https://civicinfo.googleapis.com/civicinfo/v2/elections?productionDataOnly=true&key=[YOUR_API_KEY]' \
  --header 'Accept: application/json' \
  --compressed

and returns:

{
  "elections": [
    {
      "id": "8120",
      "name": "Louisiana Presidential Preference Primary Election",
      "electionDay": "2024-03-23",
      "ocdDivisionId": "ocd-division/country:us/state:la"
    },
    {
...

Ralph Yozzo

unread,
Mar 14, 2024, 9:07:27 AMMar 14
to Google Civic Information API
Hi Eric,

Please post what you tried.

It appears the v2/representatives endpoint may help.

This is what I see.

on the command line:

$ curl   'https://civicinfo.googleapis.com/civicinfo/v2/representatives?address=new%20york&key=[YOUR API KEY]'   --header 'Accept: application/json'   --compressed  |jq -r '.officials[]|.name + " " + (.phones|tostring) ' 

Joseph R. Biden ["(202) 456-1111"]
Kamala D. Harris ["(202) 456-1111"]
Charles E. Schumer ["(202) 224-6542"]
Kirsten E. Gillibrand ["(202) 224-4451"]
Kathleen C. Hochul ["(518) 474-8390"]
Antonio Delgado ["(518) 474-8390"]
Thomas P. DiNapoli ["(518) 474-4044"]
Letitia James ["(800) 771-7755"]
Eric L. Adams ["(212) 639-9675"]
Jumaane D. Williams ["(212) 669-7250"]
Brad Lander ["(212) 669-3916"]




SAMPLE RESPONSE without filtering

curl \
  'https://civicinfo.googleapis.com/civicinfo/v2/representatives?address=new%20york&key=[YOUR_API_KEY]' \
  --header 'Accept: application/json' \
  --compressed

returns

...
      "name": "Charles E. Schumer",
      "address": [
        {
          "line1": "322 Hart Senate Office Building",
          "city": "Washington",
          "state": "DC",
          "zip": "20510"
        }
      ],
      "party": "Democratic Party",
      "phones": [
        "(202) 224-6542"
      ],
      "urls": [
        "https://www.schumer.senate.gov/",
        "https://en.wikipedia.org/wiki/Chuck_Schumer"
      ],
      "photoUrl": "http://bioguide.congress.gov/bioguide/photo/S/S000148.jpg",
...
On Wednesday, March 13, 2024 at 1:37:37 PM UTC-4 Eric Foster wrote:

Kas Stohr

unread,
Mar 22, 2024, 12:43:51 AMMar 22
to Google Civic Information API
Hi there, 

The trick to accessing data at the county, unincorporated territory level is to understand OCDid's and AdministrativeAreas.  After making the call to the Representatives endoint, you would need to parse the response by AdministrativeArea to return offices that are not state and not specific to a census "place". You can learn more about OCDids and Administrative Areas here: https://open-civic-data.readthedocs.io/en/latest/data/introduction.html#finding-your-division-id

Reply all
Reply to author
Forward
0 new messages