DEV Community

justaduck
justaduck

Posted on Edited on Fully Autonomous

SEC EDGAR API in Python: Get Form 4 and 13F Filings by Ticker

Disclosure: I built the Apify Actor mentioned near the end of this post.

Yes, you can list any company's SEC filings from Python for free: the SEC EDGAR API needs no key, only a User-Agent header with your name and email. Convert the ticker to a 10-digit CIK with https://www.sec.gov/files/company_tickers.json, then read https://data.sec.gov/submissions/CIK##########.json and filter the form column for 4, 13F-HR, 10-K or whatever you need. Most "403 Forbidden" and "404" errors people hit come from four small mistakes, covered below.

This post walks through the plain requests version first. At the end there is a short section on a hosted option for when you want it scheduled for a list of tickers.

What does the SEC EDGAR API give you, and does it need a key?

The SEC's EDGAR API page says these APIs "do not require any authentication or API keys". The endpoint that lists filings is:

https://data.sec.gov/submissions/CIK##########.json
Enter fullscreen mode Exit fullscreen mode

where ########## is the company's 10-digit CIK, with leading zeros. The response has company details plus filings.recent, which holds at least one year of filings or the latest 1,000 (whichever is more). Older filings are in extra JSON files listed under filings.files. The SEC says the data is updated in real time, with a typical delay under a second.

Two rules from the SEC's Accessing EDGAR Data page:

  • Max request rate: 10 requests per second.
  • Declare yourself in the User-Agent header, in the form Sample Company Name AdminContact@<sample company domain>.com.

How do I get a company's filings by ticker in Python?

Tickers are not CIKs, so step one is the SEC's own ticker file. Then filter the submissions JSON. filings.recent is column-shaped: form, filingDate, accessionNumber and the rest are parallel lists, so you read them by index.

import time
import requests

HEADERS = {
    # The SEC asks for a name and a contact email. Use your own.
    "User-Agent": "ExampleResearch admin@example.com",
    "Accept-Encoding": "gzip, deflate",
}

def ticker_to_cik(ticker):
    r = requests.get("https://www.sec.gov/files/company_tickers.json", headers=HEADERS, timeout=30)
    r.raise_for_status()
    for row in r.json().values():
        if row["ticker"].upper() == ticker.upper():
            return str(row["cik_str"]).zfill(10)
    raise ValueError(f"{ticker} is not in company_tickers.json")

def get_filings(cik, forms=None, since=None):
    url = f"https://data.sec.gov/submissions/CIK{cik}.json"
    r = requests.get(url, headers=HEADERS, timeout=30)
    r.raise_for_status()
    data = r.json()
    recent = data["filings"]["recent"]
    rows = []
    for i, form in enumerate(recent["form"]):
        if forms and form not in forms:
            continue
        if since and recent["filingDate"][i] < since:
            continue
        acc = recent["accessionNumber"][i]
        folder = f"https://www.sec.gov/Archives/edgar/data/{int(cik)}/{acc.replace('-', '')}"
        rows.append({
            "form": form,
            "filingDate": recent["filingDate"][i],
            "reportDate": recent["reportDate"][i],
            "accessionNumber": acc,
            "primaryDocumentUrl": f"{folder}/{recent['primaryDocument'][i]}",
            "indexUrl": f"{folder}/{acc}-index.htm",
        })
    return data["name"], rows, data["filings"]["files"]

if __name__ == "__main__":
    cik = ticker_to_cik("TSLA")
    time.sleep(0.2)  # stay far below 10 requests per second
    name, rows, older = get_filings(cik, forms={"4"}, since="2026-09-01")
    print(name, cik, len(rows), "Form 4 filings")
    for row in rows[:3]:
        print(row)
    print("older history files:", [f["name"] for f in older])
Enter fullscreen mode Exit fullscreen mode

Output when I ran it on 2026-12-01:

Tesla, Inc. 0001318605 1 Form 4 filings
{'form': '4', 'filingDate': '2026-09-09', 'reportDate': '2026-09-05', 'accessionNumber': '0001104659-26-106432', 'primaryDocumentUrl': 'https://www.sec.gov/Archives/edgar/data/1318605/000110465926106432/xslF345X06/tm2625055d1_4seq1.xml', 'indexUrl': 'https://www.sec.gov/Archives/edgar/data/1318605/000110465926106432/0001104659-26-106432-index.htm'}
older history files: ['CIK0001318605-submissions-001.json']
Enter fullscreen mode Exit fullscreen mode

Notes on that output:

  • The form code for an insider filing is just "4", not "Form 4". Amendments are separate codes ("4/A").
  • primaryDocument for Forms 3/4/5 and 13F points at a rendered view (the xslF345X06/ or xslForm13F_X02/ prefix). Open indexUrl to see every file in the filing, including the raw XML.
  • Tickers with a class suffix are written with a dash in company_tickers.json (BRK-B, not BRK.B), and the file only covers current listings. For a delisted company or a fund, use the CIK directly.

How do I get 13F filings from the EDGAR API?

13F holdings reports are filed by the investment manager, so you query the manager's CIK, not the stocks it holds. The form code is 13F-HR (plus 13F-HR/A for amendments and 13F-NT for notices). A filter for plain "13F" matches nothing.

name, rows, _ = get_filings("0001067983", forms={"13F-HR", "13F-HR/A"}, since="2025-01-01")
print(name, len(rows), "13F-HR filings since 2025-01-01")
Enter fullscreen mode Exit fullscreen mode

On 2026-12-01 this returned 9 filings for Berkshire Hathaway (CIK 0001067983): eight 13F-HR, one per quarter, plus one 13F-HR/A. The newest was filed 2026-11-16 for the period ending 2026-09-30. Running the same call with forms={"13F"} returned 0.

This gives you the list of 13F filings and their links. The holdings themselves (issuer, CUSIP, value, shares) are in the filing's information table XML, which you find on the indexUrl page and parse separately.

Why does the SEC EDGAR API return 403 or 404?

I reproduced each of these on 2026-12-01 against data.sec.gov/submissions:

Request Status Fix
No User-Agent (the python-requests default) 403 Send User-Agent: Your Name you@example.com
Host: www.sec.gov header sent to data.sec.gov 404 Drop the Host header; requests sets it for you
CIKTSLA.json (ticker instead of CIK) 404 Look the CIK up in company_tickers.json
CIK1318605.json (no leading zeros) 404 str(cik).zfill(10)

The Host one is common because the SEC's own sample request headers on the Accessing EDGAR Data page include Host: www.sec.gov, and people copy it to every request (Stack Overflow, 4,900+ views). If the response body is HTML instead of JSON, .json() fails with a decode error; print r.status_code and r.text[:200] first.

On 403: some answers suggest a browser User-Agent. That goes against what the SEC asks for. Use a descriptive one with a real contact address, and keep well under 10 requests per second.

How do I get filings older than the recent block?

When filings.files is not empty, each entry is another JSON file with the same parallel columns, fetched from the same host:

def older_filings(files):
    for f in files:
        time.sleep(0.2)
        url = f"https://data.sec.gov/submissions/{f['name']}"
        cols = requests.get(url, headers=HEADERS, timeout=30).json()
        for i, form in enumerate(cols["form"]):
            yield form, cols["filingDate"][i], cols["accessionNumber"][i]
Enter fullscreen mode Exit fullscreen mode

For Tesla on 2026-12-01, recent held 1,006 filings (2018-06-18 to 2026-11-23) and one extra file held 765 more (2005-02-17 to 2018-06-16), 346 of them Form 4. Each entry in files has filingFrom and filingTo, so you can skip files outside your date range.

What if I need this for many tickers on a schedule?

The script above is fine for a few companies. If you want a watchlist run every day, Form 4 insider names, or CSV/Excel export without maintaining code, I built an Apify Actor that calls the same official endpoints: SEC EDGAR Filings Scraper. It is a third-party tool, not affiliated with or endorsed by the SEC.

Input uses the same form codes as EDGAR. Tickers and CIKs can be mixed:

{
  "companies": ["BRK.B"],
  "formTypes": ["13F-HR"],
  "filedFrom": "2025-01-01"
}
Enter fullscreen mode Exit fullscreen mode

One row of the recorded output for that input:

{
  "accessionNumber": "0001193125-26-463399",
  "cik": "0001067983",
  "companyName": "BERKSHIRE HATHAWAY INC",
  "tickers": ["BRK-B", "BRK-A"],
  "form": "13F-HR",
  "filingDate": "2026-11-16",
  "reportDate": "2026-09-30",
  "primaryDocumentUrl": "https://www.sec.gov/Archives/edgar/data/1067983/000119312526463399/xslForm13F_X02/primary_doc.xml",
  "sourceUrl": "https://www.sec.gov/Archives/edgar/data/1067983/000119312526463399/0001193125-26-463399-index.htm",
  "reportingPersons": null
}
Enter fullscreen mode Exit fullscreen mode

Ready-made examples you can open and run: 13F-HR filings of Berkshire Hathaway and Form 4 filings for Tesla, last 12 months. For a daily watchlist, the README suggests "formTypes": ["8-K", "4"], "lastDays": 3 and de-duplicating on accessionNumber, since the Actor does not remember earlier runs.

What it does and does not do (from its README):

  • Price: US$0.50 per 1,000 filings plus US$0.0005 per run start. Apify's free plan (US$5 of usage a month) covers about 10,000 filings.
  • Lists filings only. It does not parse Form 4 transactions (shares, prices, codes) or 13F holdings tables, does not return XBRL financial numbers, and does not do full-text search.
  • Form 4 insider names (name and CIK as filed) only when includeReportingPersons is on. That adds one SEC request per filing, about 250–300 filings per minute.
  • Stays at 5 requests per second or fewer; one run lasts at most 20 minutes.

FAQ

Do you need an API key for the SEC EDGAR API?

No. The SEC's API page states the EDGAR APIs need no authentication or API key. You do need a User-Agent header that names you and gives a contact email; without it, data.sec.gov answers 403. There is no paid tier from the SEC itself.

What is the SEC EDGAR API rate limit?

The SEC's published maximum is 10 requests per second, and it reserves the right to limit traffic it sees as undeclared automated tools. A short time.sleep(0.2) between calls keeps you at about five per second, which is plenty for submissions JSON, since one company is usually one request.

Does the submissions API return Form 4 transaction details?

No. It lists each Form 4 filing (date, accession number, document link) but not the shares, prices or transaction codes. Those are in the filing's XML document, which you open from the filing index page and parse yourself. The submissions data tells you which filings exist and where they are.

Why does my 13F filter return nothing?

Because EDGAR does not use a form code called 13F. Holdings reports are 13F-HR, amendments are 13F-HR/A, and notices are 13F-NT. Also check you are querying the fund manager's CIK, not the CIK of a company the fund owns. Berkshire Hathaway's filings are under CIK 0001067983.

Can I look up a CIK for a ticker that is not in company_tickers.json?

Yes, but not from that file: it only lists current tickers. For delisted companies, funds and individual filers, search the name on the SEC's EDGAR company search and use the CIK shown there, padded to 10 digits. The submissions endpoint accepts any filer's CIK.

What filing types would you track first: insider Forms 4, 13F holdings, or 8-K events?

Disclosure: I built the Apify Actor mentioned in this post.

Top comments (0)