Accessing data on County level elected officials

70 zobrazení
Přeskočit na první nepřečtenou zprávu

Eric Foster

nepřečteno,
13. 3. 2024 13:37:3713. 3.
komu: 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

nepřečteno,
14. 3. 2024 2:14:3114. 3.
komu: 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

nepřečteno,
14. 3. 2024 9:07:2714. 3.
komu: 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

nepřečteno,
22. 3. 2024 0:43:5122. 3.
komu: 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

Odpovědět všem
Odpověď autorovi
Přeposlat
0 nových zpráv