Developer SDK

Python SDK

A Pythonic client for /api/v1/* with stable method names, consistent filters, and predictable return models.

Under Development — The Python SDK is not live yet and is still in development. We recommend waiting until later this year before relying on this feature in production.

Overview

The Python SDK provides typed access to U.S. Congressional Record data — dates, topics, full statement text, and keyword or semantic search — through four methods with consistent parameters and structured return objects.

Installation

bash
pip install second-congress

Authentication

All SDK methods authenticate with an API key. Create one from your Account.

Python
from second_congress import Client

client = Client(
    base_url="https://crec-website-be.onrender.com",
    api_key="YOUR_API_KEY",
)

Methods

Method Purpose
list_dates(...)Discover dates with available data
list_topics(...)List topics discussed on a given date or time range
get_statements(...)Retrieve statements for a specific topic
search_statements(...)Keyword or semantic search across all statements

Shared Filters

These optional keyword arguments are available on every method:

Parameter Type Description
chamberstr | None"House", "Senate", or "Extensions of Remarks"
statestr | NoneTwo-letter state code, e.g. "CA"
member_idstr | NoneUnique member identifier
yearint | NoneCalendar year, e.g. 2025
congress_numberint | NoneCongress session number, e.g. 119

Return Models

Method Returns Key Fields
list_dateslist[DateSummary]date
list_topicslist[TopicSummary]topic_id, topic_title, date, statement_count
get_statementsGetStatementsResponseitems, total_count, next_offset
search_statementsSearchResponseresults, total_count, page, total_pages

Usage Examples

Discover what dates are available

Python
dates = client.list_dates()
print(f"{len(dates)} dates available")
print(f"Most recent: {dates[0].date}")

# Only Senate session dates in 2025
senate_dates = client.list_dates(chamber="Senate", year=2025)
for d in senate_dates[:5]:
    print(d.date)
Output
247 dates available
Most recent: 2025-03-15
2025-03-15
2025-03-14
2025-03-13
2025-03-12
2025-03-11

Browse topics on a specific date

Python
topics = client.list_topics(date="2025-03-15")
for t in topics:
    print(f"{t.topic_title} — {t.statement_count} statements")

# House topics only
house_topics = client.list_topics(date="2025-03-15", chamber="House")
print(f"{len(house_topics)} House topics that day")
Output
PROVIDING FOR CONSIDERATION OF H.R. 1234 — 8 statements
NATIONAL DEFENSE AUTHORIZATION ACT — 14 statements
MORNING BUSINESS — 6 statements
RECOGNIZING NATIONAL SCIENCE WEEK — 3 statements
12 House topics that day

Get statements for a topic by ID

Python
# Pick a topic from list_topics and retrieve its statements
topics = client.list_topics(date="2025-03-15")
topic = topics[0]

response = client.get_statements(topic_id=topic.topic_id)
print(f"{response.total_count} statements in '{topic.topic_title}'")

for stmt in response.items:
    print(f"  {stmt.name} ({stmt.chamber}): {stmt.text[:100]}...")
Output
8 statements in 'PROVIDING FOR CONSIDERATION OF H.R. 1234'
  Rep. Maria Torres (House): Mr. Speaker, I rise today to speak on the importance of this legislation for working fami...
  Rep. James Chen (House): I thank the gentlelady for yielding. This legislation addresses a critical gap in our inf...
  Rep. David Park (House): Mr. Speaker, I want to echo the sentiments of my colleagues regarding the need for swift...

Get statements by topic title with media URLs

Python
response = client.get_statements(
    topic_title="NATIONAL DEFENSE AUTHORIZATION ACT",
    year=2025,
    chamber="Senate",
    include_media=True,
    limit=20,
)

for stmt in response.items:
    print(f"{stmt.name}: {stmt.word_count} words")
    if stmt.video_clip_url:
        print(f"  Video: {stmt.video_clip_url}")

Keyword search

Python
results = client.search_statements(
    query="tariff",
    mode="keyword",
    chamber="House",
    page_size=20,
)

print(f"Found {results.total_count} results across {results.total_pages} pages")
for r in results.results:
    print(f"  {r.date} | {r.name} | {r.title}")
Output
Found 84 results across 5 pages
  2025-02-20 | Rep. Kevin Walsh | TRADE AND TARIFF REFORM ACT
  2025-02-18 | Rep. Susan Miller | PROTECTING AMERICAN JOBS
  2025-02-14 | Rep. Robert Kim | FAIR TRADE PRACTICES ACT

Semantic search

Python
results = client.search_statements(
    query="arguments for and against federal student loan forgiveness",
    mode="semantic",
    chamber="Senate",
    page_size=10,
)

for r in results.results:
    print(f"[{r.similarity:.2f}] {r.name} — {r.title}")
    print(f"  {r.matched_chunk[:120]}...")
    print()
Output
[0.87] Sen. Patricia Moore — HIGHER EDUCATION AFFORDABILITY ACT
  The burden of student loan debt affects over 43 million Americans. Proponents argue that forgiveness stimulates econom...

[0.82] Sen. Robert Jackson — STUDENT LOAN REFORM
  We must weigh the cost to taxpayers against the economic benefit of freeing an entire generation from crushing debt t...

[0.79] Sen. Linda Chen — EDUCATION AND WORKFORCE DEVELOPMENT
  The question is not whether we can afford to forgive student loans, but whether we can afford not to invest in the e...

Filter by state and date range

Python
results = client.search_statements(
    query="immigration reform",
    mode="keyword",
    state="TX",
    date_from="2025-01-01",
    date_to="2025-06-30",
    page_size=50,
)

print(f"{results.total_count} results from Texas representatives")

Paginate through all results

Python
all_results = []
page = 1

while True:
    results = client.search_statements(
        query="healthcare",
        mode="keyword",
        page=page,
        page_size=100,
    )
    all_results.extend(results.results)

    if page >= results.total_pages:
        break
    page += 1

print(f"Collected {len(all_results)} total statements")