Sunlight Labs
Project of The Sunlight Foundation    
Read the labs blog

SunlightLabs API

Your API keys

places.109th.getDistrictsFromZip5

Get the one or more districts (state & district#) from a 5 digit zip code

This was a response from users who had complained about the quality supplied in places.getDistrictsFromZip.php.

Note: that these data are from 109th Congress. At time of writing (4/5/07), the 110th Congressional Directory has not been published.

These data come from the 109th Congressional Directory and are believed to be accurate capture of that data. That is, for each representative, the congressional directory lists all the 5 digit zipcodes that they represent. Here is an example for Alabama.

Note: individual 5-digit zips may lie within more than one district.

Following the US census Bureau, for At-Large states, district is '00'. For DC, district is '98'.

Arguments

These are all $_GET parameters.

zip (required)

The 5 digit zipcode

apikey (required)

your individual API key

metadata (optional)

&metadata=true provides detail about source, last update of the information etc. Click here for details

output (optional)

&output=json is set by default. You can also use &output=xml

Example Call
http://api.sunlightlabs.com/places.109th.getDistrictsFromZip5.php?zip=10941
&apikey=23kj234kjb3kjbcl87ds

says give me the 1 or more districts containing the zipcode 10941.

Example Response

For the default JSON:

{ "zip" : "10941", "districts": [ { "state" : "NY", "district" : "19" }, 
                                  { "state" : "NY", "district" : "22" } ] }
and (At-Large states)
{ "zip" : "99701", "districts": [ { "state" : "AK", "district" : "00" } ] }
and
{ "zip" : "20005", "districts": [ { "state" : "DC", "district" : "98" } ] }
For XML:
<results>
  <zip>10941</zip>
  <districts>
    <district state="NY">19</district>
    <district state="NY">22</district>
  </districts>
</results>

Error Codes

If there is an error: a plain text string will be returned:

100: invalid API key

The API key was invalid

101: API key not valid for this method

Not permitted to call this particular method with this particular API key

205: invalid zip5

The zip5 was not valid