Skip to main content

A Python wrapper for the Congress.gov API.

Project description

CongressLib

CongressLib is a Python client library for interacting with the Congress.gov API. It provides a simple and intuitive interface for retrieving legislative data such as bills, amendments, treaties, committee activities, congressional records, and more. This library is designed for researchers, developers, and anyone interested in programmatically accessing Congress.gov data.


Features

  • Retrieve lists and detailed information about:
    • Bills
    • Amendments
    • Committees
    • Communications
    • Congressional records (daily and bound)
    • Members of Congress
    • Nominations
    • Summaries
    • Treaties
  • Easily handle API authentication with your Congress.gov API key.
  • Modular design for extensibility and maintainability.

Installation

Install the package using pip:

pip install py-congress

Or, clone the repository and install it manually:

git clone https://github.com/harryziyuhe/py-congress.git
cd py-congress
pip install .

Getting Started

Prerequisites

  1. Congress.gov API Key: You need an API key from Congress.gov Developer Hub.
  2. Python version 3.8 or higher.

Setup

Store your API key in an environment file (.env):

apikey=your_congress_api_key

Example Usage

from congresslib import PyCongress

# Initialize the client
client = PyCongress(apikey="your_api_key")

# Retrieve a list of bills
bills = client.bill.get_bill_list(congress=117, limit=5)
print(bills)

# Get detailed information about a specific treaty
treaty = client.treaty.get_treaty(congress=117, number=1)
print(treaty)

# Fetch amendments for a specific bill
amendments = client.amendment.get_amendment_list(congress=117, type="h", limit=10)
print(amendments)

Available Functions

Bill

  • get_bill_list: Retrieve a list of bills based on filters like Congress number, type, and date range.
  • get_bill: Get detailed information about a specific bill.
  • get_bill_actions: Retrieve a list of actions on a specific bill.
  • get_bill_amendments: Get amendments related to a specific bill.
  • get_bill_committees: Retrieve committees associated with a bill.
  • get_bill_cosponsors: Retrieve cosponsors of a specific bill.
  • get_bill_relatedbills: Get related bills.
  • get_bill_subjects: Get legislative subjects related to a bill.
  • get_bill_summaries: Get summaries for a specific bill.
  • get_bill_text: Retrieve text versions of a bill.
  • get_bill_titles: Retrieve titles of a specific bill.
  • get_law_list: Retrieve a list of laws.
  • get_law: Retrieve detailed information about a specific law.

Amendment

  • get_amendment_list: Retrieve a list of amendments.
  • get_amendment: Get detailed information about a specific amendment.
  • get_amendment_actions: Retrieve a list of actions on a specific amendment.
  • get_amendment_cosponsors: Retrieve cosponsors for a specific amendment.
  • get_amendment_amendments: Retrieve amendments to a specific amendment.
  • get_amendment_text: Retrieve text versions of an amendment (117th Congress onwards).

Committee

  • get_committee_list: Retrieve a list of congressional committees.
  • get_committee: Get detailed information about a specific committee.
  • get_committee_bills: Retrieve bills associated with a committee.
  • get_committee_reports: Retrieve reports associated with a committee.
  • get_committee_nominations: Retrieve nominations associated with a committee.
  • get_committee_communications: Retrieve communications associated with a committee.

Communication

  • get_communication_list: Retrieve a list of communications for a chamber (House or Senate).
  • get_communication: Get detailed information about a specific communication.
  • get_requirement_list: Retrieve a list of House requirements.
  • get_requirement: Get detailed information about a specific House requirement.
  • get_requirement_communications: Retrieve communications matching a House requirement.

Congress

  • get_congress_list: Retrieve a list of congresses and congressional sessions.
  • get_congress: Get detailed information about a specific Congress.

Member

  • get_member_list: Retrieve a list of congressional members.
  • get_member: Get detailed information about a specific member.
  • get_sponsored_legislation: Retrieve legislation sponsored by a member.
  • get_cosponsored_legislation: Retrieve legislation cosponsored by a member.

Nomination

  • get_nomination_list: Retrieve a list of nominations received from the President.
  • get_nomination: Get detailed information about a specific nomination.
  • get_nominees: Retrieve a list of nominees for a position within a nomination.
  • get_nomination_actions: Retrieve actions related to a nomination.
  • get_nomination_committees: Retrieve committees associated with a nomination.
  • get_nomination_hearings: Retrieve hearings associated with a nomination.

Record

  • get_record_list: Retrieve a list of congressional record issues.
  • get_daily_record_list: Retrieve daily congressional record issues.
  • get_daily_record: Retrieve a specific daily congressional record issue.
  • get_daily_record_articles: Retrieve articles from a daily congressional record issue.
  • get_bound_record_list: Retrieve a list of bound congressional records.

Summary

  • get_summary_list: Retrieve a list of summaries based on filters like Congress number, type, and date range.

Treaty

  • get_treaty_list: Retrieve a list of treaties.
  • get_treaty: Get detailed information about a specific treaty.
  • get_treaty_actions: Retrieve actions related to a treaty.
  • get_treaty_committees: Retrieve committees associated with a treaty.

Contributing

Contributions are welcome! Please follow these steps:

  1. Fork the repository.
  2. Create a new branch for your feature (git checkout -b feature-name).
  3. Commit your changes (git commit -m 'Add some feature').
  4. Push to the branch (git push origin feature-name).
  5. Open a pull request.

License

This project is licensed under the MIT License. See the LICENSE file for details.


Acknowledgments


Contact

For questions or feedback, feel free to reach out:

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

congresslib-0.1.1.tar.gz (14.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

CongressLib-0.1.1-py3-none-any.whl (19.7 kB view details)

Uploaded Python 3

File details

Details for the file congresslib-0.1.1.tar.gz.

File metadata

  • Download URL: congresslib-0.1.1.tar.gz
  • Upload date:
  • Size: 14.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.12.7

File hashes

Hashes for congresslib-0.1.1.tar.gz
Algorithm Hash digest
SHA256 2704e5723db88ae8f010a7a2cc6c44de550ca9ccfcfa86fe7d7e39c997b8dd2e
MD5 4893de50765be2d2a1086583b2b2f56b
BLAKE2b-256 c4efc08c4fe88720df95908de02a2ca84588f0b18b03f2f2a52d268c699c7244

See more details on using hashes here.

File details

Details for the file CongressLib-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: CongressLib-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 19.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.12.7

File hashes

Hashes for CongressLib-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 c06f2b2a8913ec40ed700944f03f545fdc6dcf8a3fa8d0cd8615932abf380d6e
MD5 e4e6ab3a973043cb7ba970cd922556dd
BLAKE2b-256 988d1d14f76b15954f6b00d22d6e298840158e1ba26b9a4f07588acefc231373

See more details on using hashes here.

Supported by

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