Sunlight Labs
Project of The Sunlight Foundation    
Read the labs blog

SunlightLabs API

As of July 2008 this API has been deprecated and will no longer be updated. The new Sunlight Labs API provides similar functionality with a simpler API and more up to date data.


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.

Thus, we set out to create an up-to-date database for the 110th Congress that provides basic clerical information about members of congress (phone, email, district etc.) via API. Moreover, we provide converter methods to convert between the different IDs, thereby facilitating bringing together data about the same person from different sources. To complete the package, we have provided basic API methods that tie cities to zipcodes to districts to latitude/longitude, perfect for those web-based mashups.


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:

People-related Methods

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.

These methods are specifically about representatives:

These methods are specifically about senators:

State-related Methods

The following methods provide basic conversion between the full names and abbreviations for states:

See also places.getStateFromZip

Place-related Methods

The following methods relate to locations: zips, districts, city, latitudes, longitudes. Full details about our place-related data.

See also people.reps.getRepFromDistrict and people.reps.getRepsFromCityState.