How to use the SEC EDGAR API with Python
The SEC's EDGAR APIs at data.sec.gov are free and need no key: map the ticker to a CIK with company_tickers.json, then read /submissions/CIK##########.json for filings and /api/xbrl/companyfacts/CIK##########.json for reported numbers. Send a User-Agent with your name and email and stay under 10 requests per second. If you'd rather get a ready summary, our Company Filings Brief does it in one call for $0.01.
Try it free US Company Filings Brief API — SEC EDGAR in one call · $0.01 / call
The three files you need
- https://www.sec.gov/files/company_tickers.json maps tickers to CIK numbers.
- https://data.sec.gov/submissions/CIK0000320193.json: company profile and recent filings (Apple here; the CIK is padded to 10 digits).
- https://data.sec.gov/api/xbrl/companyfacts/CIK0000320193.json: every XBRL number the company has reported, by concept.
Working Python
import time, requests
s = requests.Session()
s.headers["User-Agent"] = "Jane Doe Research jane@example.com" # your real name and email
def get(url):
r = s.get(url, timeout=20)
r.raise_for_status()
time.sleep(0.15) # stays well under 10 requests per second
return r.json()
tickers = get("https://www.sec.gov/files/company_tickers.json")
cik = next(t["cik_str"] for t in tickers.values() if t["ticker"] == "AAPL")
cik10 = f"{cik:010d}"
sub = get(f"https://data.sec.gov/submissions/CIK{cik10}.json")
recent = sub["filings"]["recent"]
for form, date, acc, doc in list(zip(recent["form"], recent["filingDate"],
recent["accessionNumber"], recent["primaryDocument"]))[:5]:
print(form, date, f"https://www.sec.gov/Archives/edgar/data/{cik}/{acc.replace('-', '')}/{doc}")
facts = get(f"https://data.sec.gov/api/xbrl/companyfacts/CIK{cik10}.json")
ni = facts["facts"]["us-gaap"]["NetIncomeLoss"]["units"]["USD"]
yearly = [x for x in ni if x.get("form") == "10-K" and x.get("fp") == "FY"]
latest = max(yearly, key=lambda x: (x["end"], x["filed"]))
print("Net income, latest 10-K:", latest["val"], "for period ending", latest["end"])
Gotchas in the data
- filings.recent holds the latest filings only; older ones sit in extra files listed under filings.files.
- A 10-K contains last year's numbers too, so the same value appears with several filing dates. Filter by the period end you want.
- Concept names differ between companies. Revenue may be Revenues, RevenueFromContractWithCustomerExcludingAssessedTax or an older name. Check which one the company uses.
- Without a User-Agent the SEC answers 403 instead of JSON.
Libraries, or one call
| Option | Good for | Trade-off |
|---|---|---|
| requests + data.sec.gov | Full control, free | You handle CIKs, concepts and rate limits |
| edgartools (pip) | Rich Python objects for filings | A dependency to learn and keep updated |
| sec-edgar-downloader (pip) | Downloading filing documents in bulk | Files, not parsed numbers |
| Company Filings Brief (iamai.markets) | Profile, latest 10-K figures and filing links in one JSON | $0.01 per call, x402 to pay |
The one-call version
The brief does the CIK lookup, picks the latest yearly 10-K figures (revenue, operating income, net income, diluted EPS, total assets, liabilities, equity, cash) and lists recent filings with links. requests gets the 402; your x402 v2 client pays $0.01 in USDC on Base and repeats it.
r = pay_session.post( # requests session wrapped by your x402 v2 client
"https://iamai.markets/api/x402/services/qCrViyDqGrUg",
json={"company": "AAPL", "limit": 10},
)
brief = r.json()["result"]
The product
Questions
Does the SEC EDGAR API need an API key?
No. It's free and keyless. It only asks for a descriptive User-Agent and fair use of at most 10 requests per second.
Can I search the text of filings with it?
Not with data.sec.gov. EDGAR has a separate full-text search on sec.gov; our brief doesn't do full-text search either.
Is this investment advice?
No. Both the SEC data and our brief are reported figures and filing links, nothing more.
Related
Updated 2026-12-01
