Read the labs blog
SunlightLabs API
people.getDataCondition
Get data according to some condition, say IDs of all senators or IDs of all democrats
These are the different types of things that one can create a condition around:
| Name | Description |
|---|---|
| CRPcandID | The candidate ID used by the Center For Responsive politics. |
| URL | The person's or entity's website |
| state_full_name | The full name of a state, e.g. "North Dakota" |
| state_abbreviation | The abbreviation of a state's name, e.g. "CA" |
| district | The integer value of a representative's district, e.g., "6" |
| WashPost_ID | Washington Post's ID for this person |
| party | The person's party, i.e. "D", "R" or "I' |
| VoteSmart_ID | The ID used by Project Vote Smart (http://votesmart.org/index.htm) |
| title | A person's title, e.g. "Representative" or "Senator" |
| member110congress | Is/Was the person a member of the 110th Congress?, i.e., "yes" or "no" |
| FEC_ID | FEC's ID for this person |
| webform | A contact webform for this person |
| Email for this person | |
| senator_class | Class for this person (Senator): I, II, or III |
| phone | Phone number |
| name_suffix | Name Suffix, e.g. "Jr." or "II" |
| congress_office | Address of their Congressional Office, e.g. "1502 Longworth HOB, Washington, DC 20515-1101" |
| gender | Gender: "M" or "F" |
| photo | The filename for their photo at http://sunlightlabs.com/widgets/popuppoliticians/resources/images/ |
| congresspedia | The URL for their Congresspedia page |
| BioGuide_ID | ID for their BioGuide entry at http://bioguide.congress.gov/biosearch/biosearch.asp |
| Eventful_ID | The performer ID for an Eventful politician |
| lastname | Last Name(s) |
| firstname | First Name(s) |
| middlename | Middle Names(s) |
| nickname | Nickname |
| GovTrack_ID | The ID used by Govtrack.us |
| entity_id | The common id being promoted by the labs |
Arguments
These are all $_GET parameters.
parameter name (required)
One of the field names listed above. That is, ?[one of the names above] = [some value]
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://www.api.sunlightlabs.com/people.getDataCondition.php?party=D &apikey=23kj234kjb3kjbcl87ds
says give me IDs of all democrats.
Another example:
http://api.sunlightlabs.com/people.getDataCondition.php?state_full_name=alaska &apikey=23kj234kjb3kjbcl87ds
says give me IDs of all people related to Alaska.
Example Response
For the default JSON:
{ "condition": "state_full_name=alaska", "entity_ids": [ "fakeopenID434", "fakeopenID506" ,"fakeopenID525" ] }
For XML:
<results>
<condition>state_full_name=alaska</condition>
<entity_id_list>
<entity_id>fakeopenID434</entity_id>
<entity_id>fakeopenID506</entity_id>
<entity_id>fakeopenID525</entity_id>
</entity_id_list>
</results>
Error Codes
If there is an error: a plain text string will be returned:
0: no data
This means that the code was recognized but there was no data for that matched that criterion.
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
The parameter did not match one of the codes above

