Use GovTrack API to track bills through Congress

There are four main views on the website:

  1. Overview of all bills from current Congress.
  2. List of all bills on the docket, moving into, or heading out of a given Chamber (or the Executive branch).
  3. List of all bills in a given Chamber with a specific status (e.g. In Committee, On the Docket, Entering from Other Chamber, Dead, etc)
  4. Pages showing detailed info on individual bills, including:
    • Names and contact info of the bill's sponsors
    • Summary of the bill
    • Full text of the bill

Filters

Views 1, 2, and 3 can be filtered on any combination of the following attributes:

  • Party of a bill's sponsors
  • Which committee has "jurisdiction" over a bill
  • Bill topic(s) (E.g. taxes, tariffs, defense, infrastructure, etc.)
  • Bill status

Data required for each view

View 1: Overview of all bills from current Congress

View 2: List of all bills, of all statuses, in a single Chamber

  1. Current bill statuses
    • Will likely require additional calculation
  2. Bill ID numbers
  3. Bill summary
  4. Bill's sponsors
  5. Party affiliation(s) of bills' sponsors
  6. Bill topic(s)
    • May require additional calculations
  7. Committee jurisdiction of each bill

View 3: List of all bills with a single status in a single Chamber

  1. Current bill statuses
    • Will likely require additional calculation
  2. Bill ID numbers
  3. Bill summary
  4. Bill's sponsors
  5. Party affiliation(s) of bills' sponsors
  6. Bill topic(s)
    • May require additional calculations
  7. Committee jurisdiction of each bill
  8. Date that bill was introduced (?)
  9. Dates of all changes to bill's status (?)

View 4: Detailed info on a single bill

  1. Bill ID number
  2. Bill title
  3. Bill's sponsors
  4. Contact info for the bill's sponsors
  5. Party affiliation of the bill's sponsors
  6. Bill summary
  7. Full text of the bill
  8. Date that bill was introduced (?)
  9. Dates of all changes to bill's status (?)
  10. Bill topic(s)
    • May require additional calculations
  11. Committee jurisdiction of each bill

In [1]:
import requests
import json

In [11]:
r = requests.get("https://www.govtrack.us/api/v2/bill?congress=114&order_by=-current_status_date")

In [12]:
r.ok


Out[12]:
True

In [15]:
data = r.json()

In [16]:
data.keys()


Out[16]:
[u'meta', u'objects']

In [18]:
len(data['objects'])


Out[18]:
100

In [21]:
test = data["objects"][0]

In [22]:
test.keys()


Out[22]:
[u'lock_title',
 u'sliplawpubpriv',
 u'number',
 u'docs_house_gov_postdate',
 u'titles',
 u'sponsor',
 u'related_bills',
 u'id',
 u'source',
 u'senate_floor_schedule_postdate',
 u'current_status_description',
 u'current_status_label',
 u'sponsor_role',
 u'is_alive',
 u'title_without_number',
 u'congress',
 u'source_link',
 u'major_actions',
 u'bill_type',
 u'is_current',
 u'display_number',
 u'bill_type_label',
 u'noun',
 u'bill_resolution_type',
 u'current_status_date',
 u'title',
 u'current_status',
 u'introduced_date',
 u'sliplawnum',
 u'link']

In [34]:
for key in test.keys():
    print key,": ", test[key]


lock_title :  False
sliplawpubpriv :  None
number :  6380
docs_house_gov_postdate :  None
titles :  [[u'official', u'introduced', u'To amend the Omnibus Crime Control and Safe Streets Act of 1968 to authorize COPS grantees to use grant funds to hire veterans as career law enforcement officers, and for other purposes.'], [u'display', None, u'To amend the Omnibus Crime Control and Safe Streets Act of 1968 to authorize COPS grantees to use grant funds to hire veterans as career law enforcement officers, and for other purposes.']]
sponsor :  {u'name': u'Rep. Will Hurd [R-TX23]', u'firstname': u'Will', u'twitterid': u'hurdonthehill', u'middlename': u'', u'gender': u'male', u'bioguideid': u'H001073', u'namemod': u'', u'birthday': u'1977-08-19', u'link': u'https://www.govtrack.us/congress/members/will_hurd/412654', u'youtubeid': None, u'sortname': u'Hurd, Will (Rep.) [R-TX23]', u'lastname': u'Hurd', u'gender_label': u'Male', u'osid': u'N00031417', u'pvsid': None, u'nickname': u'', u'id': 412654, u'cspanid': None}
related_bills :  []
id :  347091
source :  thomas-congproj
senate_floor_schedule_postdate :  None
current_status_description :  This bill was assigned to a congressional committee on November 18, 2016, which will consider it before possibly sending it on to the House or Senate as a whole.
current_status_label :  Referred to Committee
sponsor_role :  {u'website': u'https://hurd.house.gov', u'startdate': u'2015-01-06', u'role_type_label': u'Representative', u'enddate': u'2017-01-03', u'description': u"Representative for Texas's 23rd congressional district", u'district': 23, u'extra': {u'office': u'317 Cannon House Office Building', u'address': u'317 Cannon HOB; Washington DC 20515-4323'}, u'title': u'Rep.', u'congress_numbers': [114], u'phone': u'202-225-4511', u'title_long': u'Representative', u'current': True, u'person': 412654, u'state': u'TX', u'senator_rank': None, u'role_type': u'representative', u'leadership_title': None, u'senator_class': None, u'party': u'Republican', u'id': 43715, u'caucus': None}
is_alive :  True
title_without_number :  To amend the Omnibus Crime Control and Safe Streets Act of 1968 to authorize COPS grantees to use grant funds to hire veterans as career law enforcement officers, and for other purposes.
congress :  114
source_link :  None
major_actions :  [[u'datetime.datetime(2016, 11, 18, 0, 0)', 2, u'Referred to the House Committee on the Judiciary.', u'<action datetime="2016-11-18" state="REFERRED">\n      <text>Referred to the House Committee on the Judiciary.</text>\n    </action>\n  ']]
bill_type :  house_bill
is_current :  True
display_number :  H.R. 6380
bill_type_label :  H.R.
noun :  bill
bill_resolution_type :  bill
current_status_date :  2016-11-18
title :  H.R. 6380: To amend the Omnibus Crime Control and Safe Streets Act of 1968 to authorize COPS grantees to use grant funds to hire veterans as career law enforcement officers, and for other purposes.
current_status :  referred
introduced_date :  2016-11-18
sliplawnum :  None
link :  https://www.govtrack.us/congress/bills/114/hr6380

In [ ]: