¶ Docs

Use your api.data.gov key with every federal API.

Get a key, copy a sample request, then jump straight to each agency’s parameter and field reference. Every adapter follows the same shape: auth, filter, paginate, export.

01

Get your key

Register once at api.data.gov/signup and that one key unlocks FEC, NASA, NPS, FDA, USDA, and Census endpoints. The email you provide is just for rate-limit accounting — there is no approval step and the key arrives instantly. USAJOBS, FRED, BLS, and EIA each require their own free key (see each agency’s developer page).

Treat the key like a password: do not commit it to source control. In this project, store it under DATA_GOV_API_KEY in Cloud → Secrets so server functions can read it from process.env.

02

Use the key in a request

Most api.data.gov-fronted endpoints accept the key as the api_key query parameter. A few (NPS, some NOAA endpoints) prefer it as an X-Api-Key header. Both work identically for rate-limit accounting.

Query parameter (most APIs)
curl -G 'https://api.open.fec.gov/v1/candidates/' \
  -d api_key=$DATA_GOV_API_KEY \
  -d q=harris \
  -d sort=name
Header (NPS, NOAA)
curl 'https://developer.nps.gov/api/v1/parks?stateCode=CA' \
  -H "X-Api-Key: $DATA_GOV_API_KEY"
03

Rate limits & error handling

api.data.gov returns X-RateLimit-Limit, X-RateLimit-Remaining, and X-RateLimit-Reset on every response. Default quota is 1,000 requests/hour per key. A 429 response means you’ve hit the cap; back off until the reset timestamp.

Reading rate-limit headers
const res = await fetch(url)
const limit = res.headers.get('x-ratelimit-limit')
const remaining = res.headers.get('x-ratelimit-remaining')
const reset = res.headers.get('x-ratelimit-reset')
if (res.status === 429) throw new Error(`Rate limited; resets at ${reset}`)
04

Add sort, filter, and pagination

Pass UI state directly into query parameters and keep the request function pure.

GET /v1/schedules/schedule_a/
curl -G 'https://api.open.fec.gov/v1/schedules/schedule_a/' \
  -d api_key=$DATA_GOV_API_KEY \
  -d contributor_state=CA \
  -d min_amount=2500 \
  -d sort=-contribution_receipt_amount \
  -d per_page=100 -d page=1
05

Export to CSV

Paginate, normalize, then convert to a CSV blob in the browser. Stable column keys keep the export aligned with what users see on screen.

client.ts
const csv = [headers.join(','), ...rows.map(r => headers.map(h => esc(r[h])).join(','))].join('\n')
const url = URL.createObjectURL(new Blob([csv], { type: 'text/csv' }))
06

Handle auth edge cases

USAJOBS needs a User-Agent header plus an Authorization-Key header. FRED takes api_key as a query param. BLS is technically open but works more reliably with a key. Build a tiny auth adapter rather than assuming one universal rule.

SEC EDGAR and NWS both require a descriptive User-Agent identifying your app and contact email — requests without it are rejected.

¶ Reference

Per-API parameters and fields

Jump to each agency’s official parameter reference, or open the live explorer to test queries against your key in this repo.

APIKeyDocsParameters & fieldsExplorer
Federal Election Commission
FEC
api.data.govOverview Reference Open
NASA Open APIs
NASA
api.data.govOverview Reference Open
National Park Service
NPS
api.data.govOverview Reference Open
USGS Earthquakes
USGS
PublicOverview Reference Open
openFDA
FDA
PublicOverview Reference Open
Federal Register
FEDREG
PublicOverview Reference Open
National Weather Service
NWS
PublicOverview Reference Open
U.S. Treasury Fiscal Data
TREAS
PublicOverview Reference Open
SEC EDGAR
SEC
PublicOverview Reference Open
Public Holidays (Nager.Date)
HOLIDAYS
PublicOverview Reference Open

Example queries

Federal Election Commission
Fields
GET /v1/candidates/
curl -G 'https://api.open.fec.gov/v1/candidates/' \
  -d api_key=$API_DATA_GOV_KEY \
  -d q=harris -d sort=name -d per_page=20
NASA Open APIs
Fields
GET /planetary/apod
curl -G 'https://api.nasa.gov/planetary/apod' \
  -d api_key=$API_DATA_GOV_KEY \
  -d date=2024-07-04
National Park Service
Fields
GET /api/v1/parks
curl -G 'https://developer.nps.gov/api/v1/parks' \
  -H "X-Api-Key: $API_DATA_GOV_KEY" \
  -d stateCode=CA -d limit=10
USGS Earthquakes
Fields
GET /fdsnws/event/1/query
curl -G 'https://earthquake.usgs.gov/fdsnws/event/1/query' \
  -d format=geojson \
  -d starttime=2024-01-01 \
  -d minmagnitude=5
openFDA
Fields
GET /drug/event.json
curl -G 'https://api.fda.gov/drug/event.json' \
  -d search='patient.reaction.reactionmeddrapt:"nausea"' \
  -d limit=5
Federal Register
Fields
GET /api/v1/documents
curl -G 'https://www.federalregister.gov/api/v1/documents.json' \
  -d 'conditions[term]=climate' \
  -d per_page=20
National Weather Service
Fields
GET /alerts/active
curl 'https://api.weather.gov/alerts/active?area=FL' \
  -H 'User-Agent: (your-app, you@example.com)'
U.S. Treasury Fiscal Data
Fields
GET /debt_to_penny
curl -G 'https://api.fiscaldata.treasury.gov/services/api/fiscal_service/v2/accounting/od/debt_to_penny' \
  -d sort=-record_date -d 'page[size]=10'
SEC EDGAR
Fields
GET /submissions/CIK…
curl 'https://data.sec.gov/submissions/CIK0000320193.json' \
  -H 'User-Agent: (your-app, you@example.com)'
Public Holidays (Nager.Date)
Fields
GET /v3/PublicHolidays/{year}/{country}
curl 'https://date.nager.at/api/v3/PublicHolidays/2025/US'