Sunlight Labs
Project of The Sunlight Foundation    
Read the labs blog

SunlightLabs API

Your API keys

people.getDataItem

Get a single data item (party, email, photo etc.) for a person

These are the different types of items available:

NameDescription
CRPcandIDThe candidate ID used by the Center For Responsive politics.
URLThe person's or entity's website
state_full_nameThe full name of a state, e.g. "North Dakota"
state_abbreviationThe abbreviation of a state's name, e.g. "CA"
districtThe integer value of a representative's district, e.g., "6"
WashPost_IDWashington Post's ID for this person
partyThe person's party, i.e. "D", "R" or "I'
VoteSmart_IDThe ID used by Project Vote Smart (http://votesmart.org/index.htm)
titleA person's title, e.g. "Representative" or "Senator"
member110congressIs/Was the person a member of the 110th Congress?, i.e., "yes" or "no"
FEC_IDFEC's ID for this person
webformA contact webform for this person
emailEmail for this person
senator_classClass for this person (Senator): I, II, or III
phonePhone number
name_suffixName Suffix, e.g. "Jr." or "II"
congress_officeAddress of their Congressional Office, e.g. "1502 Longworth HOB, Washington, DC 20515-1101"
genderGender: "M" or "F"
photoThe filename for their photo at http://sunlightlabs.com/widgets/popuppoliticians/resources/images/
congresspediaThe URL for their Congresspedia page
BioGuide_IDID for their BioGuide entry at http://bioguide.congress.gov/biosearch/biosearch.asp
Eventful_IDThe performer ID for an Eventful politician
lastnameLast Name(s)
firstnameFirst Name(s)
middlenameMiddle Names(s)
nicknameNickname
GovTrack_IDThe ID used by Govtrack.us
entity_idThe common id being promoted by the labs

Arguments

These are all $_GET parameters.

id (required)

An entity_id, e.g. "fakeopenID2".

code (required)

One of the codes above specifiying the desired item type

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.getDataItem.php?id=fakeopenID2&code=phone
&apikey=23kj234kjb3kjbcl87ds

says take the entity_id "fakeopenID2" and get their phone number.

Example Response

For the default JSON:

{ "entity_id": "fakeopenID2", "phone":"(202) 225-5431" }

For XML:

<results>
  <entity_id>fakeopenID2</entity_id>
  <phone>(202) 225-5431</phone>
</results>

Error Codes

If there is an error: a plain text string will be returned:

0: no data found

This means that the entity was found but there was no data for that id for that field. This might occur. The database is not complete

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

200: invalid input code

Invalid code. Check against the table above