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

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

Libraries, or one call

OptionGood forTrade-off
requests + data.sec.govFull control, freeYou handle CIKs, concepts and rate limits
edgartools (pip)Rich Python objects for filingsA dependency to learn and keep updated
sec-edgar-downloader (pip)Downloading filing documents in bulkFiles, 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