Sunlight Labs
Project of The Sunlight Foundation    
Read the labs blog

SunlightLabs API

Your API keys

people.reps.getRepsFromCityState

Get the ID of the one or more representatives for a given city

Arguments

These are all $_GET parameters.

city (required)

The city's name

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.reps.getRepsFromCityState.php?city=Bethesda&state=MD
&apikey=23kj234kjb3kjbcl87ds

says give me the ID of the one or more represenatives for Bethesda, MD

Example Response

For the default JSON:

{ "city": "Bethesda", "state": "MD", "entity_ids": [ "fakeopenID406" ] }
For XML:
<results>
  <city>Bethesda</city>
  <state>MD</state>
  <entity_id_list>
    <entity_id>fakeopenID123</entity_id>
    <entity_id>fakeopenID345</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 city + state was not valid