This API is now out of date. We have a shiny, better-documented, brand new API, up-to-date for the 110th Congress. Here is the API.
However, if you wish to use the API below, it does still work, and is still applicable for location related method calls, e.g. zip to city.
The API for SunlightLabs DataKit
This is the API for SunlightLab's data kit:
- getDistrictFromZip5
- getStateFromZip5
- getDistrictFromZip9
- getStateFromZip9.php
- getRepresentativeNameFromDistrict
- getRepresentativePhoneNumberFromDistrict
- getRepresentativeRoomNumberFromDistrict
- getCityFromZip5
- getCityStateFromZip5
- getLatitudeFromCityState
- getLongitudeFromCityState
- getZipCodesFromCityState
- getTimezoneFromCityState
- getRepresentativeNameFromCityState
- getRepresentativeNameFromState
- getStateAbbreviationFromStateName
- getStateNameFromStateAbbreviation
Location
For now, the base location for calling these functions is http://sunlightlabs.com/datakit/.
That is, to getDistrictfromZip5 then call http://sunlightlabs.com/datakit/getDistrictFromZip5.php
Sources of data
Local copies of databases obtained from:
Echoditto database
Source of data:
http://www.echoditto.com/zip2rep
getDistrictFromZip5.php
Description
|
get the one or more district IDs from a 5 digit zip code
|
Arguments
|
zip=[String] (Required)
|
Example call
|
getDistrictFromZip5.php?zip=20001
|
Example response
|
DC:0
The response is a state abbreviation followed by a colon followed by a district id.
Multiple outputs might be generated and are separated by a pipe. For example for 20740 we get: MD:5|MD:4|. Where no districts can be matched "NULL" is returned.
|
getStateFromZip5.php
Description
|
get the state abbreviation from a 5 digit zip code
|
Arguments
|
zip=[String] (Required)
|
Example call
|
getStateFromZip5.php?zip=20740
|
Example response
|
MD. Where no state can be matched "NULL" is returned.
|
getDistrictFromZip9.php
Description
|
get the one district ID from a 9 digit zip code
|
Arguments
|
zip=[String] (Required), plus4=[String] (Required)
|
Example call
|
getDistrictFromZip9.php?zip=20740&plus4=2000
|
Example response
|
MD:5
The response is a state abbreviation followed by a colon followed by a district id. "NULL" is returned if no result can be found.
|
getStateFromZip9.php
Description
|
get the state abbreviation from a 9 digit zip code
|
Arguments
|
zip=[String] (Required), plus4=[String] (Required)
|
Example call
|
getStateFromZip9.php?zip=20740&plus4=2000
|
Example response
|
MD. If no result can be found "NULL" is returned.
|
getRepresentativeNameFromDistrict.php
Description
|
get the representative's name from a district id
|
Arguments
|
state=[String] (Required),district=[String] (Required)
|
Example call
|
getRepresentativeNameFromDistrict.php?state=MD&district=5
|
Example response
|
Hoyer, Steny H. Where no representative can be matched "NULL" is returned.
|
getRepresentativePhoneNumberFromDistrict.php
Description
|
get the representative's Hart Senate Office phone number from a district id
|
Arguments
|
state=[String] (Required),district=[String] (Required)
|
Example call
|
getRepresentativePhoneNumberFromDistrict.php?state=MD&district=5
|
Example response
|
225-4131. Where no representative can be matched "NULL" is returned.
|
getRepresentativeRoomNumberFromDistrict.php
Description
|
get the representative's Hart Senate Office room number from a district id
|
Arguments
|
state=[String] (Required),district=[String] (Required)
|
Example call
|
getRepresentativeRoomNumberFromDistrict.php?state=MD&district=5
|
Example response
|
1705. Where no representative can be matched "NULL" is returned.
|
Civicspace database
Source of data:
http://civicspacelabs.org/home/zipcodedb
getCityFromZip5.php
Description
|
get the city name from a 5 digit zip code
|
Arguments
|
zip=[String] (Required)
|
Example call
|
getCityFromZip5.php?zip=20740
|
Example response
|
College Park.
Where no representative can be matched "NULL" is returned.
|
getCityStateFromZip5.php
Description
|
get the city name and state from a 5 digit zip code
|
Arguments
|
zip=[String] (Required)
|
Example call
|
getCityFromZip5.php?zip=20740
|
Example response
|
College Park, MD
Where no representative can be matched "NULL" is returned.
|
getLatitudeFromCityState.php
Description
|
get the latitude(s) from a city name and state
|
Arguments
|
city=[String] (Required),state=[String] (Required)
|
Example call
|
getLatitudeFromCityState.php?city=College%20Park&state=MD
|
Example response
|
38.997560|38.833563|
Mulitple answers, separated by a pipe, refer to different zip codes within the city. Where no city can be matched "NULL" is returned.
|
getLongitudeFromCityState.php
Description
|
get the longitude(s) from a city name and state
|
Arguments
|
city=[String] (Required),state=[String] (Required)
|
Example call
|
getLongitudeFromCityState.php?city=College%20Park&state=MD
|
Example response
|
-76.925770|-76.877743|
Mulitple answers, separated by a pipe, refer to different zip codes within the city. Where no city can be matched "NULL" is returned.
|
getZipCodesFromCityState.php
Description
|
get the zipcode(s) from a city name and state
|
Arguments
|
city=[String] (Required),state=[String] (Required)
|
Example call
|
getZipCodesFromCityState.php?city=College%20Park&state=MD
|
Example response
|
20740|20741|20742|
Mulitple zips in the response are separated by a pipe. Where no city can be matched "NULL" is returned.
|
getTimezoneFromCityState.php
Description
|
get the timezone (from GMT) from a city name and state
|
Arguments
|
city=[String] (Required),state=[String] (Required)
|
Example call
|
getTimezoneFromCityState.php?city=College%20Park&state=MD
|
Example response
|
-5
Mulitple timezones in the response are separated by a pipe. Where no city can be matched "NULL" is returned.
|
getRepresentativeNameFromCityState.php
Description
|
get the representative's name(s) from a city name and state
|
Arguments
|
city=[String] (Required),state=[String] (Required)
|
Example call
|
getRepresentativeNameFromCityState.php?city=College%20Park&state=MD
|
Example response
|
Hoyer, Steny H.|Wynn, Albert Russell|
Mulitple timezones in the response are separated by a pipe. Where no city or representative can be matched "NULL" is returned.
|
getRepresentativeNameFromState.php
Description
|
get the representative's name(s) for a state
|
Arguments
|
state=[String] (Required)
|
Example call
|
getRepresentativeNameFromState.php?state=MD
|
Example response
|
Hoyer, Steny H.|Cardin, Benjamin L.|Cummings, Elijah E.|Wynn, Albert Russell|Van Hollen, Chris|Ruppersberger, C. A. Dutch|Bartlett, Roscoe G.|Gilchrest, Wayne T.|
Mulitple representatives in the response are separated by a pipe. Where no state can be matched "NULL" is returned.
|
USPS database
Source of data: US postal service website
getStateAbbreviationFromStateName.php
Description
|
get the state's abbreviation from the state's name
|
Arguments
|
name=[String] (Required)
|
Example call
|
getStateAbbreviationFromStateName.php?name=COLORADO
|
Example response
|
CO. Where no state can be matched "NULL" is returned.
|
getStateNameFromStateAbbreviation.php
Description
|
get the state's name from the state's abbreviation
|
Arguments
|
abbreviation=[String] (Required)
|
Example call
|
getStateNameFromStateAbbreviation.php?abbreviation=CO
|
Example response
|
COLORADO. Where no state can be matched "NULL" is returned.
|