Skip to main content

A Python interface to the OpenCongress.org API

Project description

A Python interface to the OpenCongress.org API.

Installation

python-opencongress is a simple Python module that is installable by placing the opencongress directory onto your system path.

As it is available on the Python Package Index, you can install python-opencongress using your favorite package manager:

pip install python-opencongress

easy_install python-opencongress

You can also install directly from the git master branch using the pip package manager:

pip install git+http://github.com/cpharmston/python-opencongress.git#egg=opencongress

Or you can download python-opencongress and install locally:

setup.py install

Usage

The OpenCongress.org API is exposed via the opencongress.Api class. To create an instance of the class:

import opencongress
api = opencongress.Api('your_api_key_here')

Substituing your_api_key_here for your own API key, which can be obtained at the API documentation page.

Most OpenCongress.org API functionality is available through the opencongress.Api class. For example, to view a list of all bills introduced during the 111th Congress:

>>> api.bills(congress=111)
[
   <OpenCongress Bill object (H.R.5472 America RISING Act of 2010)>,
   <OpenCongress Bill object (H.R.2521 National Infrastructure Development Bank Act of 2009)>,
   <OpenCongress Bill object (H.R.5473 Investing Income at Home Act of 2010)>,
   <OpenCongress Bill object (H.R.5455 New Philadelphia, Illinois, Study Act)>,
   <OpenCongress Bill object (H.R.5454 Reduce Unnecessary Spending Act of 2010)>,
   ...
]

To view a list of all congresspeople who are members (by name) of the Kennedy family and Democrat party:

>>> api.people(last_name='Kennedy')
[
   <OpenCongress Person object (Ambrose Kennedy)>,
   <OpenCongress Person object (Andrew Kennedy)>,
   <OpenCongress Person object (Sen. Edward Kennedy [D, MA])>,
   <OpenCongress Person object (Joseph Kennedy)>,
   <OpenCongress Person object (Martin Kennedy)>,
   <OpenCongress Person object (Michael Kennedy)>,
   <OpenCongress Person object (Rep. Patrick Kennedy [D, RI-1])>,
   <OpenCongress Person object (Robert Kennedy)>,
   <OpenCongress Person object (William Kennedy)>
]

For a full list of API methods, see the pydoc-generated inspection of the Api object at api_reference.txt, included with this package and available at python-opencongress’ GitHub page.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

python-opencongress-0.1.tar.gz (9.7 kB view details)

Uploaded Source

File details

Details for the file python-opencongress-0.1.tar.gz.

File metadata

File hashes

Hashes for python-opencongress-0.1.tar.gz
Algorithm Hash digest
SHA256 598395bd41bf0a05f862456ce46c3fbd413cbf93e8d5efc35ac5b87d0f40a53a
MD5 ada940fd681f3ca63b02fc55b4da3848
BLAKE2b-256 a56caff065e9d3297b4daad2c26559573c3f07c0c39ecada3a4d7e1b1852402d

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page