Read the labs blog
SunlightLabs API
places.getCityStateFromZip
Get the city name and state from a 5 digit zip code
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.getCityStateFromZip.php?zip=94105 &apikey=23kj234kjb3kjbcl87ds
says give me the city and state containing the zipcode 94105.
Example Response
For the default JSON:
{ "zip": "91405", "city": "San Francisco", "state": "CA"}
For XML:
<results> <zip>94105</zip> <city>San Francisco</city> <state>CA</state> </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

