DEV Community

Alex Spinov
Alex Spinov

Posted on

9 Government APIs You Didn't Know Existed (All Free, Most Need No API Key)

Your tax dollars paid for these APIs. You might as well use them.

I spent a week exploring government data portals and found some genuinely useful APIs that most developers have never heard of.

1. SEC EDGAR — Every Public Company's Financials

Tesla's revenue? Apple's debt? It's all here. Structured JSON, no API key.

import requests
headers = {"User-Agent": "MyApp (email@example.com)"}
url = "https://data.sec.gov/api/xbrl/companyfacts/CIK0001318605.json"
data = requests.get(url, headers=headers).json()
# Revenue, profit, assets, debt — everything
Enter fullscreen mode Exit fullscreen mode

📖 Full tutorial

2. FRED — 816,000 Economic Datasets

Inflation rates, GDP, unemployment, housing prices, interest rates — the Federal Reserve makes it all available.

📖 Full tutorial

3. Treasury FiscalData — National Debt in Real-Time

The US national debt, updated daily. Plus exchange rates, auction results, government spending.

📖 Full tutorial

4. NASA APIs — Space Data for Free

Asteroid tracking, Mars rover photos, satellite imagery, space weather. Free API key, generous limits.

url = "https://api.nasa.gov/planetary/apod?api_key=DEMO_KEY"
data = requests.get(url).json()
print(data["title"])  # Astronomy Picture of the Day
Enter fullscreen mode Exit fullscreen mode

5. USGS Earthquake API — No Key Needed

Real-time earthquake data worldwide. Updated every minute.

url = "https://earthquake.usgs.gov/fdsnws/event/1/query?format=geojson&minmagnitude=5&limit=5"
data = requests.get(url).json()
for eq in data["features"]:
    print(f"{eq["properties"]["mag"]}{eq["properties"]["place"]}")
Enter fullscreen mode Exit fullscreen mode

6. Census API — US Demographics

Population by zip code, income levels, education, housing — the most detailed demographic data available.

7. Weather.gov — US Weather Forecasts

NOAA's official weather API. No key needed, no rate limit anxiety.

# Get forecast for any US location
url = "https://api.weather.gov/points/40.7128,-74.0060"  # NYC
data = requests.get(url, headers={"User-Agent": "MyApp"}).json()
forecast_url = data["properties"]["forecast"]
Enter fullscreen mode Exit fullscreen mode

8. FEC API — Campaign Finance

Who's funding political campaigns? All public. Free API key.

9. PubMed/NIH — 36M Biomedical Papers

Search biomedical literature programmatically. No auth needed.

url = "https://eutils.ncbi.nlm.nih.gov/entrez/eutils/esearch.fcgi?db=pubmed&term=CRISPR&retmode=json&retmax=5"
data = requests.get(url).json()
ids = data["esearchresult"]["idlist"]
print(f"Found {data["esearchresult"]["count"]} papers on CRISPR")
Enter fullscreen mode Exit fullscreen mode

Why Government APIs Are Underrated

  1. Free forever — taxpayer funded
  2. Source of truth — this IS the official data
  3. Stable — governments don't pivot or shut down APIs for fun
  4. Well-documented — legal requirements mean good docs
  5. No vendor lock-in — public data, open formats

I built Python toolkits for all the financial ones

Which government API surprised you the most?


Follow for more free API discoveries.

Top comments (0)