Skip to content

Google Civic Information API

bdunklau edited this page Sep 11, 2020 · 12 revisions

https://developers.google.com/civic-information/docs/v2

Figuring out OCD-ID's for Cities and Counties

https://groups.google.com/g/google-civicinfo-api/c/I8TR3U5e48E

cURL to get state House and Senator for an address

curl below was created from this form
Notice the request parameters on the form

curl \
  "https://civicinfo.googleapis.com/civicinfo/v2/representatives?address=2070%20Belfry%20Ct%2C%20Rockwall%2C%20TX%2075087&includeOffices=true&levels=administrativeArea1&roles=legislatorUpperBody&roles=legislatorLowerBody&key=${YOURVOTECOUNTS_CIVIC_API_KEY}" \
  --header 'Accept: application/json' \
  --compressed

Env Variable in commands above

YOURVOTECOUNTS_CIVIC_API_KEY = cURL Key

Sample Output - State Rep/Senator

{
  "normalizedInput": {
    "line1": "2070 Belfry Court",
    "city": "Rockwall",
    "state": "TX",
    "zip": "75087"
  },
  "kind": "civicinfo#representativeInfoResponse",
  "divisions": {
    "ocd-division/country:us/state:tx/sldl:33": {
      "name": "Texas State House district 33",
      "officeIndices": [
        1
      ]
    },
    "ocd-division/country:us/state:tx/sldu:2": {
      "name": "Texas State Senate district 2",
      "officeIndices": [
        0
      ]
    }
  },
  "offices": [
    {
      "name": "TX State Senator",
      "divisionId": "ocd-division/country:us/state:tx/sldu:2",
      "levels": [
        "administrativeArea1"
      ],
      "roles": [
        "legislatorUpperBody"
      ],
      "officialIndices": [
        0
      ]
    },
    {
      "name": "TX State Representative",
      "divisionId": "ocd-division/country:us/state:tx/sldl:33",
      "levels": [
        "administrativeArea1"
      ],
      "roles": [
        "legislatorLowerBody"
      ],
      "officialIndices": [
        1
      ]
    }
  ],
  "officials": [
    {
      "name": "Bob Hall",
      "address": [
        {
          "line1": "P.O. Box 12068",
          "line2": "Capitol Station",
          "line3": "",
          "city": "Austin",
          "state": "TX",
          "zip": "78711"
        },
        {
          "line1": "17585 State Highway 19",
          "line2": "Suite 200",
          "line3": "",
          "city": "Canton",
          "state": "TX",
          "zip": "75103"
        }
      ],
      "party": "Republican Party",
      "phones": [
        "(972) 722-3131"
      ],
      "urls": [
        "https://senate.texas.gov/member.php?d=2"
      ],
      "photoUrl": "http://www.senate.texas.gov/members/d02/img/headshot.jpg",
      "emails": [
        "[email protected]"
      ],
      "channels": [
        {
          "type": "Facebook",
          "id": "SenatorBobHall"
        },
        {
          "type": "Twitter",
          "id": "SenatorBobHall"
        }
      ]
    },
    {
      "name": "Justin Holland",
      "address": [
        {
          "line1": "State Capitol",
          "line2": "Room E2.804",
          "line3": "P.O. Box 2910",
          "city": "Austin",
          "state": "TX",
          "zip": "78768-2910"
        },
        {
          "line1": "101 E. Rusk St.",
          "line2": "#201",
          "line3": "",
          "city": "Rockwall",
          "state": "TX",
          "zip": "75087"
        }
      ],
      "party": "Republican Party",
      "phones": [
        "(972) 722-7521"
      ],
      "urls": [
        "https://house.texas.gov/members/member-page/?district=33"
      ],
      "photoUrl": "http://www.house.state.tx.us/photos/members/3205.jpg",
      "emails": [
        "[email protected]"
      ],
      "channels": [
        {
          "type": "Facebook",
          "id": "Texans4JAH"
        },
        {
          "type": "Twitter",
          "id": "justinaholland"
        }
      ]
    }
  ]
}

Sample Output - Congress

{
  "normalizedInput": {
    "line1": "2070 Belfry Court",
    "city": "Rockwall",
    "state": "TX",
    "zip": "75087"
  },
  "kind": "civicinfo#representativeInfoResponse",
  "divisions": {
    "ocd-division/country:us/state:tx": {
      "name": "Texas",
      "officeIndices": [
        0
      ]
    },
    "ocd-division/country:us/state:tx/cd:4": {
      "name": "Texas's 4th congressional district",
      "officeIndices": [
        1
      ]
    }
  },
  "offices": [
    {
      "name": "U.S. Senator",
      "divisionId": "ocd-division/country:us/state:tx",
      "levels": [
        "country"
      ],
      "roles": [
        "legislatorUpperBody"
      ],
      "officialIndices": [
        0,
        1
      ]
    },
    {
      "name": "U.S. Representative",
      "divisionId": "ocd-division/country:us/state:tx/cd:4",
      "levels": [
        "country"
      ],
      "roles": [
        "legislatorLowerBody"
      ],
      "officialIndices": [
        2
      ]
    }
  ],
  "officials": [
    {
      "name": "Ted Cruz",
      "address": [
        {
          "line1": "127A",
          "city": "Washington",
          "state": "DC",
          "zip": "20510"
        }
      ],
      "party": "Republican Party",
      "phones": [
        "(202) 224-5922"
      ],
      "urls": [
        "https://www.cruz.senate.gov/"
      ],
      "photoUrl": "http://www.cruz.senate.gov/files/images/OfficialPortrait.jpg",
      "channels": [
        {
          "type": "Facebook",
          "id": "SenatorTedCruz"
        },
        {
          "type": "Twitter",
          "id": "SenTedCruz"
        },
        {
          "type": "YouTube",
          "id": "TedCruzforSenate"
        },
        {
          "type": "YouTube",
          "id": "SenTedCruz"
        }
      ]
    },
    {
      "name": "John Cornyn",
      "address": [
        {
          "line1": "517 Hart Senate Office Building",
          "city": "Washington",
          "state": "DC",
          "zip": "20510"
        }
      ],
      "party": "Republican Party",
      "phones": [
        "(202) 224-2934"
      ],
      "urls": [
        "https://www.cornyn.senate.gov/"
      ],
      "photoUrl": "http://bioguide.congress.gov/bioguide/photo/C/C001056.jpg",
      "channels": [
        {
          "type": "Facebook",
          "id": "Sen.JohnCornyn"
        },
        {
          "type": "Twitter",
          "id": "JohnCornyn"
        },
        {
          "type": "YouTube",
          "id": "SenJohnCornyn"
        }
      ]
    },
    {
      "name": "VACANT",
      "address": [
        {
          "line1": "223 Cannon House Office Building",
          "city": "Washington",
          "state": "DC",
          "zip": "20515"
        }
      ],
      "phones": [
        "(202) 225-6673"
      ],
      "urls": [
        "https://ratcliffe.house.gov/"
      ],
      "channels": [
        {
          "type": "Facebook",
          "id": "RepRatcliffe"
        },
        {
          "type": "Twitter",
          "id": "RepRatcliffe"
        }
      ]
    }
  ]
}