Capitol Words API
Base URI
A valid Sunlight labs API key. You can register for one here: http://services.sunlightlabs.com/accounts/register
Limit results to members of Congress from the given state.
Valid values: 2-letter state abbreviation, such as MD
, VA
, DC
.
Limit results to members of Congress from the given party.
Valid values: R
, D
, I
The chamber to search. Default includes House, Senate and extensions of remarks.
Valid values:
house
,
senate
,
extensions
Show results for only the given date. //todo provide example
Limit results to those on or after the given date.
Limit results to those on or before the given date.
Listed below are the public methods currently supported by the Capitol Words API.
All requests must be signed with a valid Sunlight labs API key.
You can register for one here: http://services.sunlightlabs.com/accounts/register
Discussion & Bugs
Sunlight API discussion takes place at the sunlightlabs-api-discuss google group. You can ask questions there, as well as alert the maintainers of bugs. If you have specific issues with the Capitol Words API, you can open a ticket directly at github.
{entity}
.jsonFind the popularity of a phrase over a period of time. Standard arguments are supported.
Request parameters
The phrase to search for.
Limit results to the member of Congress with the given Bioguide ID.
Only return results where mentions are at or above the supplied threshold
Include the percentage of mentions versus total words in the result objects.
Default - false
The length of time covered by each result.
Valid values:
- year
- month
- day (default)
Responses
Body
Examples
Get a list of how many times the phrase “united states” appears in the Congressional Record on each day in the most recent Congress:
GET http://capitolwords.org/api/1/dates.json?phrase==united+states HTTP/1.1
Get a list of how many times the phrase “united States” appears in the Congressional Record on each day between Jan. 1, 2010, and June 1, 2010:
GET http://capitolwords.org/api/1/dates.json?phrase=united+states HTTP/1.1
Get a list of how many times the phrase “united states” appears in the Congressional Record in each month between January and June, 2010:
GET http://capitolwords.org/api/1/dates.json?phrase=united+states&granularity=month HTTP/1.1
HTTP/1.1 200 OK
Content-Type: application/json
{
"results": [
{
"count": 14.0,
"percentage": 0.058309037900874633,
"total": 24010,
"day": "1996-01-02",
"raw_count": 14.0
},
{
"count": 122.0,
"percentage": 0.067791336044986786,
"total": 179964,
"day": "1996-01-04",
"raw_count": 122.0
},
{
"count": 198.0,
"percentage": 0.13499693188791165,
"total": 146670,
"day": "1996-01-05",
"raw_count": 198.0
},
{
"count": 1.0,
"percentage": 0.098135426889106966,
"total": 1019,
"day": "1996-01-08",
"raw_count": 1.0
}
]
}
List the top phrases for a facet.
Request parameters
The entity type to get top phrases for. Valid values:
date
month
state
legislator
The value of the entity given in entity_type. Formats are as follows:
date
: 2011-11-09month
: 201111state
: NYlegislator
(bioguide id): L000551
The size of phrase, in words, to search for (up to 5).
The page of results to show. 100 results are shown at a time. To get more than 100 results, use the page parameter.
The metric and direction to sort by. Valid values:
tfidf
(default)count
Both a metric and direction must be supplied, such as ‘sort=count asc’
Responses
Body
Examples
List the top words in July 2010 by count:
GET http://capitolwords.org/api/1/phrases.json?entity_type=month&entity_value=201007&sort=count+desc HTTP/1.1
List the top words for Nevada:
GET http://capitolwords.org/api/1/phrases.json?entity_type=state&entity_value=Nevada HTTP/1.1
List the top words for Barbara Lee:
GET http://capitolwords.org/api/1/phrases.json?entity_type=legislator&entity_value=L000551 HTTP/1.1
HTTP/1.1 200 OK
Content-Type: application/json
[
{
"tfidf": 3.8596557124800003e-05,
"count": 5373,
"ngram": "people"
},
{
"tfidf": 1.30267768302e-05,
"count": 3637,
"ngram": "one"
},
{
"tfidf": 2.52066478599e-05,
"count": 3509,
"ngram": "jobs"
},
{
"tfidf": 1.17409333103e-05,
"count": 3278,
"ngram": "american"
},
...snip...
]
{entity}
.jsonGet the top (legislator|state|party|bioguide_id|volume|chamber)s for a phrase. Standard arguments are supported.
Path variables
Entity type for a phrase:
legislator
state
party
bioguide_id
volume
chamber
Request parameters
The phrase to search for.
Only return results where mentions are at or above the supplied threshold
The number of results to return per page. The maximum is 50.
The page number to return.
The metric on which to sort top results.
Note: Facet sorts in Solr are alphabetically ascending by facet or descending by count. The only valid values you can provide are
count
or:entity
.
Responses
Body
Examples
GET http://capitolwords.org/api/1/phrases/legislator.json?phrase=free+market HTTP/1.1
HTTP/1.1 200 OK
Content-Type: application/json
{
"results": [
{
"count": 41.0,
"chamber": "House"
},
{
"count": 35.0,
"chamber": "Senate"
},
{
"count": 9.0,
"chamber": "Extensions"
}
]
}
Full-text search. Standard arguments are supported.
Request parameters
Text search arguments
A phrase to search the title of each CR document for.
Limit results to the member of Congress with the given Bioguide ID.
The pages in the Congressional Record to search.
The page of results to show, 50 results are shown at a time.
The value on which to sort the results. Options for this endpoint are:
speaker_state
congress
title
number
volume
chamber
session
id
speaker_party
date
bioguide_id
pages
Coupled with a direction, asc
or desc
. An example to sort by true chronological order and chamber (id works for this purpose) would be id desc
.
Responses
Returns a list of CR Documents and the total number found.
Body
Examples
Get a list of pieces of text with the phrase obama administration
in them:
GET http://capitolwords.org/api/1/text.json?phrase=obama+administration HTTP/1.1
Get a list of pieces of text by Republicans with the phrase “health care debate” in them:
GET http://capitolwords.org/api/1/text.json?phrase=health+care+debate HTTP/1.1
HTTP/1.1 200 OK
Content-Type: application/json
{
"num_found": 347,
"results": [
{
"speaker_state": "NC",
"speaker_first": "Virginia",
"congress": 111,
"title": "CULTIVATING AMERICAN ENERGY RESOURCES",
"origin_url": "http://origin.www.gpo.gov/fdsys/pkg/CREC-2009-07-30/html/CREC-2009-07-30-pt1-PgH9197.htm",
"number": 117,
"pages": "H9197-H9203",
"volume": 155,
"chamber": "House",
"session": 1,
"speaking": [
"Well, I think that this is a great segue to talk about the other subject that we wanted to talk about tonight, which is health care, and what is happening with the health care debate."
],
"capitolwords_url": "http://capitolwords.org/date/2009/07/30/H9197_cultivating-american-energy-resources/",
"speaker_party": "R",
"date": "2009-07-30",
"bills": null,
"bioguide_id": "F000450",
"order": 14,
"speaker_last": "Foxx",
"speaker_raw": "ms. foxx"
},
...snip...
]
}
sfsdf
Data container
Data container (//TODO provide better description)
total results found