Sunlight API Documentation

From Sunlabs wiki

Jump to: navigation, search

This page provides information on directly interfacing with the Sunlight Labs API, note that all calls require an API key.

If you don't already have an API key, registration is fast and simple:

Register for your Sunlight Labs API key now!

Contents

Technical Information

The Sunlight Labs API is RESTful and the preferred output format is JSON, although XML is available as well.

The base URL for all calls to the API is http://services.sunlightlabs.com/api/ and calling an API method looks like:

 http://services.sunlightlabs.com/api/api.method.format?apikey=YOUR_API_KEY&params
api.method
any of the methods listed below.
.format
.xml or .json, if omitted defaults to JSON
YOUR_API_KEY
the API key you received when signing up
params
the appropriate parameters to the API method


All API methods return a JSON or XML container named response that contains the object(s) returned by the appropriate API call. For detailed output examples view the specific documentation a particular method.

If an error is encountered the HTTP status code will be set to 400 and a plain text string describing the error is returned regardless of output format. If authentication fails due to a missing or invalid key the HTTP status code 403 is used.

Client Libraries

Sites using the API

Methods

The Sunlight Labs API currently provides the following methods:

Legislator Methods

Methods for US Representatives and Senators, providing basic contact information as well as all the various IDs we track for legislators.

legislators.get
get all information on a single legislator
legislators.getList
get information on all legislators meeting certain requirements
legislators.search
fuzzy name search against legislators
legislators.allForZip
get information on all legislators that represent some portion of a given zip code (typically 2 senators + 1 or more representatives)

District Methods

Methods for Congressional districts, providing lookups to obtain district information from a zipcode or latitude and longitude.

districts.getDistrictsFromZip
get district(s) that a given zip code falls within
districts.getZipsFromDistrict
get zip codes that fall within a given district
districts.getDistrictFromLatLong
get district that contains a location identified by a latitude/longitude

Committee Methods

Methods for Congressional Committees, providing membership information.

committees.getList
get list of committees matching certain criteria
committees.get
get details on a committee including its subcommittees and members
committees.allForLegislator
get all committees that a given legislators serves on

Lobbyist Methods

The lobbyists methods are deprecated, historical data remains but these methods will not be maintained.

Methods related to lobbying records as filed with the Senate Office of Public Records (this portion of the API is still highly experimental)

lobbyists.getFiling
get a specific SOPR lobbyist filing by unique id
lobbyists.getFilingList
get lobbying filings for a particular client or registrant
lobbyists.search
fuzzy name search against lobbyists

Words Methods

The wordlist methods are deprecated, historical data remains but these methods will not be maintained.

These methods work slightly different than the rest of the API and are documented at Sunlight Labs Wordlist API.

Personal tools