You can sign up to get an API key by first signing up for a SpendingTracker.org account, then clicking the "Request API key" button on the settings pane of your account.
The SpendingTracker.org API gives you access to the raw data underlying the site, including (1) Legislative data, (2) Representative data, and (3) Rankings data.
Request an API Key
To request an API key, first sign up for a SpendingTracker.org account. Log in to the site, and click the "Account" link along the left side of the dashboard. Scroll down and click the "Request API key" link toward the bottom of the page.
Your token will be displayed, but it will not be active until approved by an administrator. You will receive an email when your request is approved and your token activated.
Authentication & Base Endpoint
All requests return json and require authentication as an api_key parameter:
api_key: SPENDINGTRACKER_API_KEY
If your API token has not been activated or is invalid, requests will return success false with no data
{ "success": false, "message": "Invalid api key", "data": [] }
Available Methods
We take every bill that each Member voted for (or against) and sum the monetary amount of spending in them to get the final total. If Members vote for some bills that lower spending and some bills that raise it, the net difference is their number.
Base Endpoint
The base endpoint for all requests is:
https://spendingtracker.org/rest/api/v1/
Requests fall into three fundamental types: bills, persons, and rankings. Each Get function in turn can be filtered based on optional parameters, examples of which are described further below.
Get Bills
Get Bills allows you to produce lists of the legislation that are used to calculate scores on the site. In addition, optional parameters allow you to filter these lists based on variables like session of Congress.
https://spendingtracker.org/rest/api/v1/legislation
Optional Parameters:
page: integer per_page: integer session: int session of congress name: string name or short title of legislation
Example Response:
{ "pager": { "page": "1", "pages": 1, "per_page": 50, "results": 1 }, "success": true, "records": [ { "id": 1183, "bill_id": "hr3981-113", "roll_id": "hr3981-113", "bill_type": "hr", "number": 3981, "congress": "113", "chamber": "house", "introduced_on": "2014-01-31", "last_action_at": "2014-09-18 00:00:00", "last_vote_at": null, "last_version_on": "2014-01-31", ... } ] }
Get Person
Get Person allows you to get information on specific representatives and senators contained on individual pages of SpendingTracker.org.
https://spendingtracker.org/rest/api/v1/person?bioguide_id=BIOGUIDE_OR_NAME
Required Parameters:
bioguide_id: string; bioguide_id, or url slug from SpendingTracker.org such as "justin-amash"
Example Response:
{ "success": true, "data": { "details": { "bioguide_id": "A000367", "ocd_id": "ocd-division/country:us/state:mi/cd:3", "thomas_id": "02029", ... "fullname": "Justin Amash", "photo": "http://spendingtracker.local/assets/images/reps/a000367.jpg?v=1486619858", "score": { "rep_overall": 98, "combined_max": 325146220000, "combined_rep": 658000000, "rep_pos": 99, "party_max": 658000000, "party_rep": 658000000, "party_pos": 100, "state_max": 324990220000, "state_rep": 658000000, "state_pos": 99.8, "status": "less", "original_pos": 1, "party_status": "higher", "original_party": 100, "state_status": "lower", "original_state": 0.2 } }, "legislation": [ { "rep_id": "A000367", "roll_id": "h203-2019", "bill_id": "hr299-116", "official_title": "To amend title 38, United States Code, to clarify presumptions relating to the exposure of certain veterans who served in the vicinity of the Republic of Vietnam, and for other purposes.", "short_title": "Blue Water Navy Vietnam Veterans Act of 2019", ... }, ... ] } }
Get Rankings
Get Rankings allows you to pull information from the Rankings page of SpendingTracker.org. The Rankings function also allows for data to be filtered based on an exhaustive list of optional parameters that correspond to the filters available on the Rankings page.
https://spendingtracker.org/rest/api/v1/rankings
Optional Parameters:
page: integer per_page: integer chamber: string; senate, house status: string; all, pending, approved spending_type: array of int, see "Get Budget Types" endpoint name: string name of person to filter by party: string; D, R, I gender: string; M, F bioguide: string bioguide ID for single person state: string, 2 letter state abbreviation
Example Response:
{ "pager": { "page": 1, "pages": 36, "per_page": 15, "results": 532 }, "success": true, "records": [ { "rep_id": 222, "bioguide_id": "P000603", "govtrack_id": "412492", "fullname": "Rand Paul", "party": "R", "state_name": "Kentucky", "chamber": "senate", "district": null, "state": "KY", "title": "Sen", "slug": "rand-paul", "total_discretionary": "1644.5000", "total_direct": "346.0000", "combined": "1990.5000", "photo": "http://spendingtracker.local/assets/images/reps/p000603.jpg?v=1486084666", "link": "http://spendingtracker.local/sen/rand-paul", "pic": "http://spendingtracker.local/assets/images/reps/p000603.jpg?v=1486084666", "short_title": "Senate - Kentucky", "total_spending": "1990500000", "total_spending_formatted": "$1,990,500,000", "short_spending": "$2 Billion" }, ... ] }
Get Budget Types
Provides the various budget types that may be used in the Get Bills or Get Rankings endpoints.
https://spendingtracker.org/rest/api/v1/budgetTypes
Example Response:
{ "pager": { "page": 1, "pages": 1, "per_page": 18, "results": 18 }, "success": true, "records": [ { "id": 7, "type": "750 - Administration of Justice", "label": "Administration of Justice" },...
Get Sessions of Congress
Provides the available sessions of Congress that may be used in the Get Bills of the Get Rankings endpoints.
https://spendingtracker.org/rest/api/v1/availableCongresses
Example Response:
{ "pager": { "page": 1, "pages": 1, "per_page": 6, "results": 6 }, "success": true, "records": [ "116", "115", "114", "113", "112", "111" ] }
Don't be sad- we've got your back. Just enter your email below and instructions on resetting your password will be sent to you.
×