OpenBB-finance/OpenBB · error · OpenBBError
Congress.gov API rate limit exceeded. Please wait a moment…
Error message
Congress.gov API rate limit exceeded. Please wait a moment and try again.
What it means
Raised as OpenBBError from fetch_committee_bills when the Congress.gov API responds with error code OVER_RATE_LIMIT. Congress.gov enforces a request quota (5,000 requests/hour per API key as of writing); once exceeded, every response carries that error code instead of data. The helper checks the error envelope on the first page response and aborts the pagination immediately.
Solutions
- Wait for the rate-limit window to reset (typically the top of the next hour) and retry
- Reduce request volume: use use_cache=True, lower refetch frequency, or batch fewer committees per run
- Provision a separate Congress.gov API key (free at api.congress.gov) for heavy consumers so keys are not shared
Example fix
# before
for code in ['hsju00', 'ssju00', 'hsba00']:
bills = await fetch_committee_bills(chamber, code, api_key)
# after
for code in ['hsju00', 'ssju00', 'hsba00']:
try:
bills = await fetch_committee_bills(chamber, code, api_key)
except OpenBBError as e:
if 'OVER_RATE_LIMIT' in str(e) or 'rate limit' in str(e).lower():
await asyncio.sleep(3600) # wait out the window
raise Defensive patterns
Strategy: retry
Try / catch
from openbb_core.app.model.abstract.error import OpenBBError
async def fetch_with_backoff(fetch, *a, max_retries=5, **kw):
for attempt in range(max_retries):
try:
return await fetch(*a, **kw)
except OpenBBError as e:
if 'rate limit' not in str(e).lower() or attempt == max_retries - 1:
raise
await asyncio.sleep(min(60 * (2 ** attempt), 900)) Prevention
- Enable use_cache=True for committee document/bill fetches
- Stagger batch jobs to stay well under the 5,000 req/hour key quota
- Use a dedicated API key per team/system to isolate quotas
When it happens
Trigger: Fetching all bills for a committee whose pagination.count exceeds 250, generating many back-to-back page requests; running multiple concurrent workers or dashboards against the same congress_gov_api_key; tight refetch intervals on Workspace widgets.
Common situations: Shared API key across a team or CI; batch/backfill scripts looping over many committees; a scheduled job overlapping the hourly window reset.
Related errors
- An error occurred during the HTTP request
- e
- Error fetching data
- Error fetching port data
- Error fetching report
AI-assisted analysis of OpenBB-finance/OpenBB@3e071fcc2c (2026-08-14).
Data as JSON: /api/errors/6a75b573059df08b.
Report an issue: GitHub.
Appendix: source
Thrown at openbb_platform/providers/congress_gov/openbb_congress_gov/utils/committees.py:191
"s": "is",
"sres": "is",
"sjres": "is",
"sconres": "is",
}
kwargs: dict = {}
if session is not None:
kwargs["session"] = session
bills_base = f"{base_url}committee/{chamber}/{system_code}/bills"
first_url = f"{bills_base}?format=json&limit=250&offset=0&api_key={api_key}"
resp = await amake_request(first_url, timeout=20, **kwargs)
all_bills: list[dict] = []
if isinstance(resp, dict):
if resp.get("error", {}).get("code") == "OVER_RATE_LIMIT":
raise OpenBBError(
ValueError(
"Congress.gov API rate limit exceeded. Please wait a moment and try again."
)
)
cb = resp.get("committee-bills", {})
all_bills = list(cb.get("bills", []) if isinstance(cb, dict) else [])
total = resp.get("pagination", {}).get("count", 0)
if total > 250 and all_bills:
remaining_urls = [
f"{bills_base}?format=json&limit=250&offset={off}&api_key={api_key}"
for off in range(250, total, 250)
]
page_sem = asyncio.Semaphore(10)
async def _fetch_bills_page(page_url: str) -> list[dict]:
async with page_sem:View on GitHub (pinned to 3e071fcc2c)