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://crec-website-be.onrender.com
All endpoints return JSON. Responses larger than 500 bytes are
automatically gzip-compressed when the client sends
Accept-Encoding: gzip.
Rate Limits
Current limits are endpoint-specific. Product API routes use key-based limits plus IP backstops.
| Surface | Endpoint | Limit |
|---|---|---|
/api/v1 |
/search |
180/min per key (+ IP backstop) |
/api/v1 |
/statements |
300/min per key (+ IP backstop) |
/api/v1 |
/keys |
3/day per IP (verification request) |
When a limit is exceeded, the API returns 429 Too Many Requests with an error object and message indicating when the window resets.
{
"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 (e.g. bad mode value) |
401 |
Unauthorized | Missing or malformed Authorization header |
403 |
Forbidden | Invalid API key |
429 |
Too Many Requests | Rate limit exceeded |
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 500 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). E.g. Nancy Pelosi,Chuck Schumer. |
states |
string | — | Filter by state(s), comma-separated. 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). Keyword mode only — semantic mode returns a single page. |
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://crec-website-be.onrender.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,
"audioUrl": "https://crec.s3.us-east-2.amazonaws.com/...",
"audioDurationMs": 482000,
"videoClipUrl": "https://crec.s3.us-east-2.amazonaws.com/...",
"videoThumbnailUrl": "https://crec.s3.us-east-2.amazonaws.com/...",
"videoUrl": "https://www.youtube.com/...",
"videoStartTimestamp": 3845,
"legislation": ["H.R. 3684"],
"sourcePdfUrls": ["https://..."],
"artifacts": []
}
],
"totalCount": 347,
"page": 1,
"pageSize": 10,
"totalPages": 35
}
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://crec-website-be.onrender.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": 5,
"page": 1,
"pageSize": 5,
"totalPages": 1
}
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 on speaker name or statement text. |
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://crec-website-be.onrender.com/api/v1/statements?\
date=2025-03-15&\
limit=50"
Example: House Statements Only
curl -H "Authorization: Bearer YOUR_API_KEY" \
"https://crec-website-be.onrender.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",
"audioUrl": "https://crec.s3.us-east-2.amazonaws.com/...",
"audioDurationMs": 95000,
"videoClipUrl": null,
"videoThumbnailUrl": null,
"videoUrl": null,
"videoStartTimestamp": null,
"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://crec-website-be.onrender.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://crec-website-be.onrender.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. |
audioUrl | string|null | Direct URL to the audio recording (MP3). |
audioDurationMs | integer|null | Audio duration in milliseconds. |
videoClipUrl | string|null | Direct URL to the extracted video clip. |
videoThumbnailUrl | string|null | Video clip thumbnail image URL. |
videoUrl | string|null | Full session video URL (e.g. YouTube). |
videoStartTimestamp | integer|null | Start timestamp (seconds) within the session video. |
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. |
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. |
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",
"audioUrl": "https://storage.example.com/audio/f1e2d3c4.mp3",
"audioDurationMs": 245000,
"videoClipUrl": "https://storage.example.com/video/f1e2d3c4.mp4",
"videoThumbnailUrl": "https://storage.example.com/thumb/f1e2d3c4.jpg",
"videoUrl": "https://www.youtube.com/watch?v=example",
"videoStartTimestamp": 3420,
"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",
"audioUrl": "https://storage.example.com/audio/e2d3c4b5.mp3",
"audioDurationMs": 182000,
"videoClipUrl": null,
"videoThumbnailUrl": null,
"videoUrl": null,
"videoStartTimestamp": null,
"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,
"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://crec-website-be.onrender.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://crec-website-be.onrender.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://crec-website-be.onrender.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://crec-website-be.onrender.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://crec-website-be.onrender.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://crec-website-be.onrender.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://crec-website-be.onrender.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://crec-website-be.onrender.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://crec-website-be.onrender.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://crec-website-be.onrender.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://crec-website-be.onrender.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://crec-website-be.onrender.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://crec-website-be.onrender.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://crec-website-be.onrender.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://crec-website-be.onrender.com/api/v1/dates" | jq '.[0:5]'
# Browse a specific date (grouped by category)
curl -s -H "Authorization: Bearer YOUR_API_KEY" \
"https://crec-website-be.onrender.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://crec-website-be.onrender.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://crec-website-be.onrender.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://crec-website-be.onrender.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