Sunlight Labs
Project of The Sunlight Foundation    
Read the labs blog

SunlightLabs API

Your API keys

people.sens.getSensFromState

Get the IDs of the senators for a given state

Arguments

These are all $_GET parameters.

state (required)

The state's abbreviation

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/people.sens.getSensFromState.php?state=MD
&apikey=23kj234kjb3kjbcl87ds

says give me the IDs of the senators for Maryland

Example Response

For the default JSON:

{ "state": "MD", "entity_ids": [ "fakeopenID452", "fakeopenID505" ] }
For XML:
<results>
  <state>MD</state>
	<entity_id_list>
      <entity_id>fakeopenID452</entity_id>
      <entity_id>fakeopenID505</entity_id>
  </entity_id_list>
</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

202: invalid combined user input data

The state abbreviation + district number was not valid

203: invalid state

The state abbreviation was not valid