Sunlight Labs
Project of The Sunlight Foundation    
Read the labs blog

SunlightLabs API

Your API keys

states.getAbbreviationFromName

Get the state's two-letter abbreviation from its full name

Arguments

These are all $_GET parameters.

state (required)

The state's full name

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/states.getAbbreviationFromName.php?state=Maryland
&apikey=23kj234kjb3kjbcl87ds

says give me the two-letter state abbreviation for "Maryland"

Example Response

For the default JSON:

{ "state_full_name": "Maryland", "state_abbreviation": "MD" }
For XML:
<results>
  <state_full_name>Maryland</state_full_name>
  <state_abbreviation>MD</state_abbreviation>
</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

203: invalid state

The state name was not valid