Authentication
All API endpoints live under /api/v1/* and
require a valid API key. API keys are generated from your account.
When using authenticated access, include your key in the Authorization header:
Authorization: Bearer YOUR_API_KEY
/api/v1/.
Base URL
All API requests should be made to:
https://api.secondcongress.com
All endpoints return JSON. Responses larger than 500 bytes are
automatically gzip-compressed when the client sends
Accept-Encoding: gzip.
Rate Limits
Daily allowance
Accounts are free. Each one has a daily allowance, and the counts reset at midnight UTC.
| Semantic searches a day | Other API calls a day | Results you can page through | |
|---|---|---|---|
| No account (website only) | 3 | None | 250 |
| Account | 20 | 100 | 250 |
Need more for research or reporting? Ask through the contact form.
- Semantic searches (
mode=semantic) count against their own allowance, shared with the website and the MCP server. Paging through one search counts once: the same text and filters with a differentpageis free. - Other API calls count 1 each. That includes keyword searches.
- Results you can page through caps how far into one search you can go. A page past it returns
400.
Per-minute limits
These apply to every account and stop runaway scripts.
| Endpoint | Per key | Per IP address |
|---|---|---|
/api/v1/search | 180/min | 240/min |
/api/v1/statements | 300/min | 450/min |
/api/v1/browse/{date} | 300/min | 450/min |
/api/v1/dates | 600/min | 900/min |
| Any other route | 120/min | 240/min |
A key that goes over a per-minute limit 3 times within 24 hours is suspended. Running out of a daily allowance never suspends a key.
When a limit or allowance is used up, the API returns 429 Too Many Requests with the error object below; the message says which limit and when it resets. Check the status code rather than relying on the body, and wait before retrying.
{
"error": {
"type": "RateLimitError",
"message": "Rate limit exceeded for api key route /api/v1/search: 180 requests/60s. Resets in 24s.",
"status": 429
},
"detail": "Rate limit exceeded for api key route /api/v1/search: 180 requests/60s. Resets in 24s."
}
Error Handling
The API uses standard HTTP status codes. Errors return a frozen contract with an error object and legacy detail string.
| Status | Meaning | Typical Cause |
|---|---|---|
200 |
OK | Request succeeded |
400 |
Bad Request | Invalid query parameters: a date that isn't a real YYYY-MM-DD date, search text over 300 characters, more than 20 members or states, or a page past your account's result limit |
401 |
Unauthorized | Missing or malformed Authorization header |
403 |
Forbidden | Invalid API key |
429 |
Too Many Requests | A rate limit or the day's allowance is used up |
500 |
Internal Error | Unexpected server-side failure |
502 |
Bad Gateway | Upstream service error (e.g. embedding generation failed) |
503 |
Service Unavailable | Service not configured (e.g. semantic search unavailable) |
{
"error": {
"type": "AuthError",
"message": "Invalid API key",
"status": 403
},
"detail": "Invalid API key"
}
/api/v1/search
Unified search across all congressional statements. Supports keyword full-text search (powered by PostgreSQL tsvector + GIN indexes) and AI-powered semantic search (powered by OpenAI embeddings + pgvector). Combine with filters for chamber, member, state, congress number, and date range.
Query Parameters
| Parameter | Type | Default | Description |
|---|---|---|---|
q |
string | — | Search query. Max 300 characters. Required for semantic mode. Supports PostgreSQL websearch syntax in keyword mode (e.g. "climate change" -carbon). |
mode |
string | keyword |
Search mode. keyword for full-text search, semantic for AI-powered vector similarity search. |
searchIn |
string | both |
Search scope. title — search only statement titles. statement — search only statement text. both — search both fields. Keyword mode only. |
chamber |
string | — | Filter by chamber: House, Senate, or Extensions of Remarks. |
member |
string | — | Filter by a single member's name (e.g. Nancy Pelosi). |
members |
string | — | Filter by multiple members (comma-separated), up to 20. E.g. Nancy Pelosi,Chuck Schumer. |
states |
string | — | Filter by state(s), comma-separated, up to 20. E.g. California,New York. |
congress |
string | — | Filter by congress number (e.g. 119 for the 119th Congress). |
dateFrom |
string | — | Start date filter, inclusive. Format: YYYY-MM-DD. |
dateTo |
string | — | End date filter, inclusive. Format: YYYY-MM-DD. |
page |
integer | 1 |
Page number (1-indexed). Pages stop at your account's result limit (250 unless you've been given more). Turning pages in a semantic search doesn't count against the daily allowance again. |
pageSize |
integer | 50 |
Results per page. Min 1, max 100. |
Keyword Search Example
Find statements about "infrastructure" in the Senate during 2025:
curl -H "Authorization: Bearer YOUR_API_KEY" \
"https://api.secondcongress.com/api/v1/search?\
mode=keyword&\
q=infrastructure&\
chamber=Senate&\
dateFrom=2025-01-01&\
dateTo=2025-12-31&\
pageSize=10"
{
"results": [
{
"id": "a1b2c3d4-...",
"name": "Chuck Schumer",
"chamber": "Senate",
"date": "2025-03-15",
"title": "INFRASTRUCTURE INVESTMENT AND JOBS ACT",
"text": "Mr. President, I rise today to discuss the critical ...",
"deliveryType": "spoken",
"statementOrigin": "floor_speech",
"wordCount": 1842,
"politicalParty": "Democrat",
"state": "New York",
"pictureUrl": "https://...",
"headerPages": "S2145-S2148",
"contentPages": "S2145-S2147",
"crecVolume": "171",
"crecNumber": "47",
"congressNumber": 119,
"topicGroupId": "group-xyz",
"seq": 1,
"groupCount": 3,
"legislation": ["H.R. 3684"],
"sourcePdfUrls": ["https://..."],
"artifacts": []
}
],
"totalCount": 347,
"countCapped": false,
"resultLimit": 250,
"page": 1,
"pageSize": 10,
"totalPages": 25
}
Keyword counts stop at 1,000: when there are more,
totalCount is 1,000 and countCapped is
true. resultLimit is how far your account
can page, and totalPages stops there.
Semantic Search Example
Find statements conceptually similar to a natural-language question — even if the exact words don't appear:
curl -H "Authorization: Bearer YOUR_API_KEY" \
"https://api.secondcongress.com/api/v1/search?\
mode=semantic&\
q=debate+about+regulating+artificial+intelligence&\
pageSize=5"
{
"results": [
{
"id": "e5f6g7h8-...",
"name": "Maria Cantwell",
"title": "AI OVERSIGHT AND ACCOUNTABILITY",
"similarity": 0.8723,
"matchedChunk": "...we must ensure that the development of artificial intelligence is guided by principles of transparency and accountability...",
...
}
],
"totalCount": 800,
"countCapped": false,
"resultLimit": 250,
"page": 1,
"pageSize": 5,
"totalPages": 50
}
text-embedding-3-large model
to find conceptually similar statements. The similarity score ranges from
0 to 1 (higher is more relevant), and matchedChunk shows the
most relevant passage from the full statement text.
Advanced Keyword Syntax
The q parameter in keyword mode supports PostgreSQL websearch syntax:
| Syntax | Example | Meaning |
|---|---|---|
"..." |
"climate change" |
Exact phrase match |
OR |
climate OR environment |
Match either term |
- |
infrastructure -bridges |
Exclude a term |
| space (AND) | budget deficit |
Both terms must appear |
/api/v1/statements
Retrieve congressional statements with optional filters. Returns an array of statement objects ordered by date (descending), then by topic group sequence. Ideal for browsing recent activity or fetching a specific day's proceedings.
Query Parameters
| Parameter | Type | Default | Description |
|---|---|---|---|
date |
string | — | Filter by date. Format: YYYY-MM-DD. |
chamber |
string | — | Filter by chamber: House, Senate, or Extensions of Remarks. |
congress_number |
integer | — | Filter by congress number (e.g. 119). |
search |
string | — | Case-insensitive text filter. searchIn controls which field it applies to. |
searchIn |
string | all |
Field the search filter applies to. speaker — speaker name. title — statement title; returns every statement under a matching title, including ones whose own text does not match. statement — statement text. all — any of the three. |
topic_group_id |
string | — | Return only statements belonging to a specific topic group. |
limit |
integer | 200 |
Max rows to return. Min 1, max 1000. |
Example: Get a Single Day
curl -H "Authorization: Bearer YOUR_API_KEY" \
"https://api.secondcongress.com/api/v1/statements?\
date=2025-03-15&\
limit=50"
Example: House Statements Only
curl -H "Authorization: Bearer YOUR_API_KEY" \
"https://api.secondcongress.com/api/v1/statements?\
chamber=House&\
limit=100"
[
{
"id": "a1b2c3d4-...",
"name": "Nancy Pelosi",
"chamber": "House",
"date": "2025-03-15",
"title": "HONORING THE LEGACY OF...",
"text": "Mr. Speaker, I rise today...",
"deliveryType": "spoken",
"statementOrigin": "floor_speech",
"wordCount": 523,
"politicalParty": "Democrat",
"state": "California",
"district": "11",
"website": "https://pelosi.house.gov",
"pictureUrl": "https://...",
"headerPages": "H1234-H1235",
"contentPages": "H1234",
"crecVolume": "171",
"crecNumber": "47",
"congressNumber": 119,
"seq": 1,
"groupCount": 1,
"topicGroupId": "group-abc",
"legislation": null,
"sourcePdfUrls": ["https://..."],
"artifacts": ["Amendment text..."]
},
...
]
/api/v1/dates
Returns every date for which congressional statements are available, sorted newest-first. Use this to discover which dates have data before making more targeted queries.
Parameters
This endpoint takes no parameters.
Example
curl -H "Authorization: Bearer YOUR_API_KEY" \
"https://api.secondcongress.com/api/v1/dates"
[
"2026-02-07",
"2026-02-06",
"2026-02-05",
"2026-02-04",
"2026-02-03",
"2025-12-20",
"2025-12-19",
...
]
/api/v1/statements endpoint to
iterate over all available dates and build a complete local mirror of the Congressional Record.
/api/v1/browse/{date}
Returns statements for a specific date, pre-organized into three categories (Written Remarks, House Spoken Remarks, Senate Spoken Remarks) and further grouped by topic title. This mirrors the structure of the official Congressional Record.
Path Parameters
| Parameter | Type | Description |
|---|---|---|
date |
string | Required. Date in YYYY-MM-DD format. |
Example
curl -H "Authorization: Bearer YOUR_API_KEY" \
"https://api.secondcongress.com/api/v1/browse/2025-03-15"
{
"Written Remarks": {
"HONORING THE LEGACY OF JOHN DOE": [
{
"id": "...",
"name": "Rep. Jane Smith",
"chamber": "House",
"title": "HONORING THE LEGACY OF JOHN DOE",
"text": "Mr. Speaker, I rise to honor...",
"date": "2025-03-15",
"seq": 1,
"groupCount": 1,
...
}
],
"RECOGNIZING NATIONAL SCIENCE WEEK": [...]
},
"House Spoken Remarks": {
"INFRASTRUCTURE INVESTMENT ACT": [
{ "id": "...", "name": "Rep. Jim Brown", "seq": 1, ... },
{ "id": "...", "name": "Rep. Amy Lee", "seq": 2, ... }
]
},
"Senate Spoken Remarks": {
"NOMINATION OF...": [...]
}
}
Statement Object Schema
Every statement in the API shares this common structure. Some fields may be null when data is not available.
| Field | Type | Description |
|---|---|---|
id | string (UUID) | Unique statement identifier. |
name | string | Speaker's full name (e.g. "Nancy Pelosi"). |
chamber | string | House, Senate, or Extensions of Remarks. |
date | string | Date of the statement (YYYY-MM-DD). |
title | string | Topic title from the Congressional Record. |
text | string | Full statement text. |
deliveryType | string | How the statement was delivered (e.g. spoken, extension_of_remarks). |
statementOrigin | string | Origin context (e.g. floor_speech). |
wordCount | integer | Number of words in the statement. |
politicalParty | string | Speaker's party (e.g. Democrat, Republican). |
state | string | Speaker's state (e.g. California). |
district | string|null | Speaker's congressional district (House only). |
website | string|null | Speaker's official website URL. |
pictureUrl | string|null | URL to the speaker's official portrait. |
headerPages | string|null | CREC header page range (e.g. S2145-S2148). |
contentPages | string|null | CREC content page range. |
crecVolume | string|null | Congressional Record volume number. |
crecNumber | string|null | Congressional Record issue number. |
congressNumber | integer | Congress number (e.g. 119). |
seq | integer|null | Sequence position within the topic group. |
groupCount | integer|null | Total statements in the topic group. |
topicGroupId | string|null | Identifier for the topic group. Use to fetch all related statements. |
legislation | array|null | Referenced legislation identifiers (e.g. ["H.R. 3684"]). |
sourcePdfUrls | array|null | URLs to the original Congressional Record PDF pages. |
artifacts | array | Array of artifact text strings associated with the statement. |
artifact_titles | array | Titles for artifacts, in the same order. null where no title has been assigned. |
Search-Only Fields
These fields appear only in /api/v1/search responses when using semantic mode:
| Field | Type | Description |
|---|---|---|
similarity | float | Cosine similarity score (0–1). Higher = more relevant. Only present in semantic mode. |
matchedChunk | string | The text passage from the statement that was most similar to the query. Only present in semantic mode. |
Search Paging Fields
Every /api/v1/search response, in both modes, has these alongside results:
| Field | Type | Description |
|---|---|---|
totalCount | integer | Number of matching statements. Keyword counts stop at 1,000. |
countCapped | boolean | true when there are more than 1,000 matches, so totalCount is a floor. |
resultLimit | integer | How far into the results your account can page: 250 unless you've been given more. |
page, pageSize | integer | The page returned and its size. |
totalPages | integer | Pages you can request, counted up to resultLimit. |
Example Responses
Representative JSON responses from each endpoint so you know what to expect.
GET /api/v1/dates
[
"2025-03-15",
"2025-03-14",
"2025-03-13",
"2025-03-12",
"2025-03-11"
]
GET /api/v1/statements?date=2025-03-15&chamber=Senate&limit=2
[
{
"id": "f1e2d3c4-9876-5432-abcd-fedcba987654",
"name": "Sen. Patricia Moore",
"chamber": "Senate",
"date": "2025-03-15",
"title": "HIGHER EDUCATION AFFORDABILITY ACT",
"text": "Mr. President, I rise today to address the growing crisis...",
"deliveryType": "spoken",
"statementOrigin": "floor_speech",
"wordCount": 891,
"politicalParty": "Democrat",
"state": "Virginia",
"district": null,
"congressNumber": 119,
"seq": 1,
"groupCount": 5,
"topicGroupId": "a1b2c3d4-5678-9abc-def0-123456789abc",
"legislation": ["S. 1025"],
"sourcePdfUrls": ["https://www.govinfo.gov/content/pkg/CREC-2025-03-15/pdf/..."],
"artifacts": []
},
{
"id": "e2d3c4b5-8765-4321-bcde-edcba9876543",
"name": "Sen. Robert Jackson",
"chamber": "Senate",
"date": "2025-03-15",
"title": "HIGHER EDUCATION AFFORDABILITY ACT",
"text": "I thank the senior Senator from Virginia for her remarks...",
"deliveryType": "spoken",
"statementOrigin": "floor_speech",
"wordCount": 612,
"politicalParty": "Republican",
"state": "Texas",
"district": null,
"congressNumber": 119,
"seq": 2,
"groupCount": 5,
"topicGroupId": "a1b2c3d4-5678-9abc-def0-123456789abc",
"legislation": ["S. 1025"],
"sourcePdfUrls": null,
"artifacts": []
}
]
GET /api/v1/browse/2025-03-15
{
"Extensions of Remarks": {
"RECOGNIZING NATIONAL SCIENCE WEEK": [
{ "id": "...", "name": "Rep. Amy Lee", "seq": 1, "chamber": "Extensions of Remarks", ... }
]
},
"House Spoken Remarks": {
"PROVIDING FOR CONSIDERATION OF H.R. 1234": [
{ "id": "...", "name": "Rep. Maria Torres", "seq": 1, "chamber": "House", ... },
{ "id": "...", "name": "Rep. James Chen", "seq": 2, "chamber": "House", ... }
],
"INFRASTRUCTURE INVESTMENT ACT": [
{ "id": "...", "name": "Rep. Jim Brown", "seq": 1, "chamber": "House", ... }
]
},
"Senate Spoken Remarks": {
"HIGHER EDUCATION AFFORDABILITY ACT": [
{ "id": "...", "name": "Sen. Patricia Moore", "seq": 1, "chamber": "Senate", ... },
{ "id": "...", "name": "Sen. Robert Jackson", "seq": 2, "chamber": "Senate", ... }
]
}
}
GET /api/v1/search?mode=keyword&q=tariff&chamber=House&pageSize=2
{
"results": [
{
"id": "c4d5e6f7-1234-5678-abcd-123456789abc",
"name": "Rep. Kevin Walsh",
"chamber": "House",
"date": "2025-02-20",
"title": "TRADE AND TARIFF REFORM ACT",
"text": "The impact of these tariffs on American manufacturing cannot be overstated...",
"wordCount": 612,
"politicalParty": "Republican",
"state": "Ohio",
"topicGroupId": "d4e5f6a7-3456-7890-cdef-456789abcdef"
}
],
"totalCount": 84,
"countCapped": false,
"resultLimit": 250,
"page": 1,
"pageSize": 2,
"totalPages": 42
}
GET /api/v1/search?mode=semantic&q=student+loan+forgiveness&pageSize=2
{
"results": [
{
"id": "d5e6f7a8-2345-6789-bcde-23456789abcd",
"name": "Sen. Patricia Moore",
"chamber": "Senate",
"date": "2025-03-10",
"title": "HIGHER EDUCATION AFFORDABILITY ACT",
"text": "The question before us is whether the federal government should...",
"wordCount": 891,
"politicalParty": "Democrat",
"state": "Virginia",
"similarity": 0.87,
"matchedChunk": "The burden of student loan debt affects over 43 million Americans. Proponents argue that forgiveness stimulates economic growth and enables home ownership."
},
{
"id": "e6f7a8b9-3456-789a-cdef-3456789abcde",
"name": "Sen. Robert Jackson",
"chamber": "Senate",
"date": "2025-03-10",
"title": "STUDENT LOAN REFORM",
"text": "We must weigh the cost to taxpayers against the economic benefit...",
"wordCount": 734,
"politicalParty": "Republican",
"state": "Texas",
"similarity": 0.82,
"matchedChunk": "We must weigh the cost to taxpayers against the economic benefit of freeing an entire generation from crushing debt that prevents them from starting families."
}
],
"totalCount": 42,
"page": 1,
"pageSize": 2,
"totalPages": 21
}
Code Examples
Complete, ready-to-run examples in popular languages.
Keyword Search with Pagination
import requests
API_KEY = "YOUR_API_KEY"
BASE = "https://api.secondcongress.com"
HEADERS = {"Authorization": f"Bearer {API_KEY}"}
# Paginated keyword search
def search_statements(query, page=1, page_size=50):
resp = requests.get(f"{BASE}/api/v1/search", headers=HEADERS, params={
"mode": "keyword",
"q": query,
"page": page,
"pageSize": page_size,
})
resp.raise_for_status()
return resp.json()
# Fetch all pages for "climate change"
data = search_statements("climate change")
all_results = data["results"]
while data["page"] < data["totalPages"]:
data = search_statements("climate change", page=data["page"] + 1)
all_results.extend(data["results"])
print(f"Found {len(all_results)} total statements")
Semantic Search with Filters
import requests
API_KEY = "YOUR_API_KEY"
BASE = "https://api.secondcongress.com"
HEADERS = {"Authorization": f"Bearer {API_KEY}"}
# Semantic search — find conceptually similar statements
resp = requests.get(f"{BASE}/api/v1/search", headers=HEADERS, params={
"mode": "semantic",
"q": "arguments for and against federal student loan forgiveness",
"chamber": "Senate",
"dateFrom": "2025-01-01",
"pageSize": 10,
})
resp.raise_for_status()
results = resp.json()["results"]
for r in results:
print(f"[{r['similarity']:.2f}] {r['name']} — {r['title']}")
print(f" Matched: {r['matchedChunk'][:120]}...")
print()
Download Full Day's Record
import requests, json
API_KEY = "YOUR_API_KEY"
BASE = "https://api.secondcongress.com"
HEADERS = {"Authorization": f"Bearer {API_KEY}"}
# Get available dates
dates = requests.get(f"{BASE}/api/v1/dates", headers=HEADERS).json()
print(f"Available: {len(dates)} dates, latest: {dates[0]}")
# Browse the most recent date
latest = dates[0]
record = requests.get(f"{BASE}/api/v1/browse/{latest}", headers=HEADERS).json()
# Print summary
for category, topics in record.items():
stmt_count = sum(len(stmts) for stmts in topics.values())
print(f"\n{category}: {len(topics)} topics, {stmt_count} statements")
for title, stmts in list(topics.items())[:3]:
speakers = ", ".join(s["name"] for s in stmts if s.get("name"))
print(f" • {title} ({len(stmts)} statements) — {speakers}")
Get Statements by Date and Chamber
import requests
API_KEY = "YOUR_API_KEY"
BASE = "https://api.secondcongress.com"
HEADERS = {"Authorization": f"Bearer {API_KEY}"}
# Fetch Senate statements for a specific date
resp = requests.get(f"{BASE}/api/v1/statements", headers=HEADERS, params={
"date": "2025-03-15",
"chamber": "Senate",
"limit": 200,
})
resp.raise_for_status()
statements = resp.json()
print(f"{len(statements)} Senate statements on 2025-03-15")
for s in statements[:10]:
print(f" {s['name']} — {s['title'][:60]}")
Filter Search by State
import requests
API_KEY = "YOUR_API_KEY"
BASE = "https://api.secondcongress.com"
HEADERS = {"Authorization": f"Bearer {API_KEY}"}
# Search for Texas representatives discussing border policy
resp = requests.get(f"{BASE}/api/v1/search", headers=HEADERS, params={
"mode": "keyword",
"q": "border security",
"states": "Texas",
"chamber": "House",
"pageSize": 25,
})
resp.raise_for_status()
data = resp.json()
print(f"{data['totalCount']} results from Texas House members")
for r in data["results"]:
print(f" {r['date']} | {r['name']} ({r.get('district', 'N/A')})")
print(f" {r['title'][:80]}")
Compare Statements Across Chambers
import requests
API_KEY = "YOUR_API_KEY"
BASE = "https://api.secondcongress.com"
HEADERS = {"Authorization": f"Bearer {API_KEY}"}
query = "artificial intelligence"
for chamber in ["House", "Senate"]:
resp = requests.get(f"{BASE}/api/v1/search", headers=HEADERS, params={
"mode": "keyword",
"q": query,
"chamber": chamber,
"dateFrom": "2025-01-01",
"pageSize": 1,
})
resp.raise_for_status()
data = resp.json()
print(f"{chamber}: {data['totalCount']} statements about '{query}'")
Keyword Search with Fetch API
const API_KEY = "YOUR_API_KEY";
const BASE = "https://api.secondcongress.com";
async function searchStatements(query, options = {}) {
const params = new URLSearchParams({
mode: options.mode || "keyword",
q: query,
page: String(options.page || 1),
pageSize: String(options.pageSize || 50),
});
if (options.chamber) params.set("chamber", options.chamber);
if (options.dateFrom) params.set("dateFrom", options.dateFrom);
if (options.dateTo) params.set("dateTo", options.dateTo);
if (options.states) params.set("states", options.states);
const res = await fetch(`${BASE}/api/v1/search?${params}`, {
headers: { Authorization: `Bearer ${API_KEY}` },
});
if (!res.ok) {
const err = await res.json();
throw new Error(`API error ${res.status}: ${err.detail}`);
}
return res.json();
}
// Usage
const data = await searchStatements("healthcare reform", {
chamber: "Senate",
dateFrom: "2025-06-01",
pageSize: 20,
});
console.log(`Found ${data.totalCount} results`);
data.results.forEach((s) => {
console.log(`${s.date} | ${s.name} | ${s.title}`);
});
Browse All Dates and the Latest Record
const API_KEY = "YOUR_API_KEY";
const BASE = "https://api.secondcongress.com";
const headers = { Authorization: `Bearer ${API_KEY}` };
// Fetch all dates, then browse the latest
const dates = await fetch(`${BASE}/api/v1/dates`, { headers }).then(r => r.json());
console.log(`${dates.length} dates available`);
const browse = await fetch(`${BASE}/api/v1/browse/${dates[0]}`, { headers })
.then(r => r.json());
for (const [category, topics] of Object.entries(browse)) {
const count = Object.values(topics).flat().length;
console.log(`${category}: ${Object.keys(topics).length} topics (${count} statements)`);
}
Get Statements for a Date
const API_KEY = "YOUR_API_KEY";
const BASE = "https://api.secondcongress.com";
const headers = { Authorization: `Bearer ${API_KEY}` };
const params = new URLSearchParams({
date: "2025-03-15",
chamber: "House",
limit: "100",
});
const statements = await fetch(`${BASE}/api/v1/statements?${params}`, { headers })
.then(r => r.json());
console.log(`${statements.length} House statements on 2025-03-15`);
statements.slice(0, 5).forEach(s => {
console.log(` ${s.name} — ${s.title}`);
});
Semantic Search with Date Range
const API_KEY = "YOUR_API_KEY";
const BASE = "https://api.secondcongress.com";
const headers = { Authorization: `Bearer ${API_KEY}` };
const params = new URLSearchParams({
mode: "semantic",
q: "impact of tariffs on American farmers",
dateFrom: "2025-01-01",
dateTo: "2025-06-30",
pageSize: "10",
});
const data = await fetch(`${BASE}/api/v1/search?${params}`, { headers })
.then(r => r.json());
data.results.forEach(r => {
console.log(`[${r.similarity.toFixed(2)}] ${r.name} — ${r.title}`);
console.log(` ${r.matchedChunk.slice(0, 120)}...\n`);
});
Search and Analyze with R
library(httr2)
library(jsonlite)
library(dplyr)
api_key <- "YOUR_API_KEY"
base_url <- "https://api.secondcongress.com"
# Search for statements about immigration
resp <- request(base_url) |>
req_url_path_append("api", "v1", "search") |>
req_url_query(
mode = "keyword",
q = "immigration reform",
pageSize = 100,
chamber = "Senate"
) |>
req_headers(Authorization = paste("Bearer", api_key)) |>
req_perform()
data <- resp_body_json(resp)
statements <- bind_rows(data$results)
# Analyze by party
statements |>
count(politicalParty, sort = TRUE) |>
print()
# Analyze by state
statements |>
filter(!is.na(state)) |>
count(state, sort = TRUE) |>
head(10) |>
print()
Build a Time Series Dataset
library(httr2)
library(jsonlite)
library(dplyr)
library(lubridate)
api_key <- "YOUR_API_KEY"
base_url <- "https://api.secondcongress.com"
# Get all available dates
dates_resp <- request(base_url) |>
req_url_path_append("api", "v1", "dates") |>
req_headers(Authorization = paste("Bearer", api_key)) |>
req_perform()
dates <- resp_body_json(dates_resp)
# Fetch statements per day and count by chamber
daily_stats <- lapply(dates[1:30], function(d) {
resp <- request(base_url) |>
req_url_path_append("api", "v1", "statements") |>
req_url_query(date = d, limit = 1000) |>
req_headers(Authorization = paste("Bearer", api_key)) |>
req_perform()
stmts <- resp_body_json(resp)
tibble(
date = as.Date(d),
total = length(stmts),
house = sum(sapply(stmts, \(s) s$chamber == "House")),
senate = sum(sapply(stmts, \(s) s$chamber == "Senate"))
)
}) |> bind_rows()
print(daily_stats)
Quick Keyword Search
# Keyword search for "tariff" in the House
curl -s -H "Authorization: Bearer YOUR_API_KEY" \
"https://api.secondcongress.com/api/v1/search?\
mode=keyword&q=tariff&chamber=House&pageSize=5" | jq '.results[] | {name, date, title}'
Semantic Search
# Semantic search — natural language query
curl -s -H "Authorization: Bearer YOUR_API_KEY" \
"https://api.secondcongress.com/api/v1/search?\
mode=semantic&q=debate+about+TikTok+ban+and+national+security&\
pageSize=5" | jq '.results[] | {similarity, name, title, matchedChunk}'
List Dates and Browse
# Get all available dates
curl -s -H "Authorization: Bearer YOUR_API_KEY" \
"https://api.secondcongress.com/api/v1/dates" | jq '.[0:5]'
# Browse a specific date (grouped by category)
curl -s -H "Authorization: Bearer YOUR_API_KEY" \
"https://api.secondcongress.com/api/v1/browse/2025-03-15" | jq 'keys'
Get Statements for a Date and Chamber
# Fetch Senate statements for a specific date
curl -s -H "Authorization: Bearer YOUR_API_KEY" \
"https://api.secondcongress.com/api/v1/statements?\
date=2025-03-15&chamber=Senate&limit=10" | jq '.[].name'
Filter by State
# Search for statements by California representatives
curl -s -H "Authorization: Bearer YOUR_API_KEY" \
"https://api.secondcongress.com/api/v1/search?\
mode=keyword&q=wildfire&states=California&pageSize=10" \
| jq '.results[] | {name, date, state, title}'
Paginate Through All Results
# Loop through all pages of results
PAGE=1
TOTAL_PAGES=1
while [ $PAGE -le $TOTAL_PAGES ]; do
RESPONSE=$(curl -s -H "Authorization: Bearer YOUR_API_KEY" \
"https://api.secondcongress.com/api/v1/search?\
mode=keyword&q=healthcare&page=$PAGE&pageSize=100")
TOTAL_PAGES=$(echo "$RESPONSE" | jq '.totalPages')
COUNT=$(echo "$RESPONSE" | jq '.results | length')
echo "Page $PAGE/$TOTAL_PAGES: $COUNT results"
PAGE=$((PAGE + 1))
done