Read the labs blog
SunlightLabs API
places.getDistrictsFromZip
Get the one or more districts (state & district#) from a 5 or 9 digit zip code
Arguments
These are all $_GET parameters.
zip (required)
The 5 digit zipcode
apikey (required)
your individual API key
plus4 (optional)
The plus4 part of the zip, e.g. the '2000' of 12345-2000
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.getDistrictsFromZip.php?zip=20740 &apikey=23kj234kjb3kjbcl87ds
says give me the district containing the zipcode 20740.
Example Response
For the default JSON:
{ "zip": "20740", "districts": [ {"state": "MD", "district": "5"}, {"state": "MD", "district": "4"} ] }
For XML:
<results>
<zip>20740</zip>
<districts>
<district state="MD">5</district>
<district state="MD">4</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
209: invalid zip9
The complete 5+4 zipcode was not valid

