SunlightLabs API
This is work in progress: at this time, we are not requiring API keys.
Thus, you can ignore the apikey parameter in the method calls.
However, we may be implementing API key reigstration soon.
Thus, we strongly encourage you to sign up here for email updates.
The official name of the SunlightLabs is actually The Sunlight Mashup Labs so you would expect us to into APIs, the driving force behind modern mashups. However, after poking around the web to see what data were available we were very surprised how difficult it was to get current, basic information about members of congress. Further, while different organizations—both non-profit and government agencies—were tracking the same 535 members of congress, they were all using different IDs. This, we thought, was ridiculous.
To use our API, you must register for a free API key. This is only so that we can keep track of useage, block any outrageous activity, and inform you of any important changes. Please register here.
Use the API and do something wonderful. We would love to know what you have created.
General Information
Our APIs are all REST-ful [excepting people.getHCard which returns an HTML block]. Output, however, is JSON by default with an option for XML (&output=XML).
The output is generally compact by default with no additional data about when the data was last updated, whether it is actively maintained, the source of the data etc. However, there is an optional parameter which can be switched on to provide such information (&metadeta=true). Click here for details.
Example Mashup & Tutorial
To help you get started with the API, we implemented a sample mashup using the API.
We also have a tutorial page the provides all the source code and a detailed explanation about how the mashup works.
Changelog
See recent changes in our change log
but wait, there's more. Our changelog is also in:
These methods relate to the information about representatives and senators of the 110th Congress: their webpages, districts, party, emails, IDs, photos, congresspedia URLs etc. Full details about our data on members of congress.
- people.convertId : convert between different IDs
- people.getDataItem : get a single data item (party, email, photo etc.) for a person
- people.getDataCondition : get IDs of people matching some condition, say all senators or all democrats
- people.getPersonInfo : get all availbale data about a person
- people.getHCard : get a microformats hCard for a person [Note: this returns an HTML block]
These methods are specifically about representatives:
- people.reps.getRepFromDistrict : get the representative's ID from a district id
- people.reps.getRepsFromCityState : get the representative's ID(s) from a city name and state
These methods are specifically about senators:
- people.sens.getSensFromState.php : get the IDs of senators from a given state
The following methods provide basic conversion between the full names and abbreviations for states:
- states.getAbbreviationFromName : e.g., get "DE" from "Delaware"
- states.getNameFromAbbreviation : e.g., get "Delaware" from "DE"
See also places.getStateFromZip
The following methods relate to locations: zips, districts, city, latitudes, longitudes. Full details about our place-related data.
- places.getCityStateFromZip : get the city name and state from a 5 digit zip code
- places.getDistrictFromAddress : get the congressional district from full street address
- places.getDistrictsFromZip : get the one or more district IDs from a 5 or 9 digit zip code
- places.getDistrictFromLatLong : get the congressional district for a given lat/long
- places.109th.getDistrictsFromZip5 : get the one or more district from a 5 digit zip code -- 109th Congress Data
- places.getStateFromZip : get the state abbreviation from a 5 digit zip code
- places.getLatLongFromZip : get the latitude and longitude from a 5 digit zip code
- places.getLatLongsFromCityState : get the latitude(s) and longitude(s) from a city name and state
- places.getTimezoneFromCityState : get the timezone (from GMT) from a city name and state
- places.getZipsFromCityState : get the zipcode(s) from a city name and state
See also people.reps.getRepFromDistrict and people.reps.getRepsFromCityState.


