FairqueryBlogToolsAboutSecurityllms.txt

How do I get SEC EDGAR company facts (XBRL financials) and filings by ticker via API?

Fairquery ·

Short answer: the SEC publishes free JSON APIs with no key: map a ticker to its 10-digit CIK with company_tickers.json, then read data.sec.gov/api/xbrl/companyfacts/CIK##########.json for XBRL financials (revenue, net income, EPS, assets) and data.sec.gov/submissions/CIK##########.json for the filing list (10-K, 10-Q, 8-K). Send a User-Agent with your contact details and stay under 10 requests per second. Watch two traps: values are repeated across filings, and concepts change over time (Apple's Revenues stops in 2018). If you want clean rows instead, the Fairquery SEC EDGAR Actor resolves tickers, CIKs or names and returns filings and the latest facts as JSON for $0.0015 per company, $0.001 per filing row and $0.0002 per fact row.

The free SEC EDGAR APIs you need

WhatEndpointNotes
Ticker → CIKhttps://www.sec.gov/files/company_tickers.jsonOne file with every listed ticker, its CIK and company name. Pad the CIK to 10 digits for the other endpoints.
Filings and company metadatahttps://data.sec.gov/submissions/CIK##########.jsonName, SIC code, exchanges, fiscal year end and the recent filings (form, dates, accession number, primary document).
All XBRL facts of one companyhttps://data.sec.gov/api/xbrl/companyfacts/CIK##########.jsonEvery reported value of every concept (us-gaap, dei), by unit, with period start/end, form, fiscal period and filing date.
One concept of one companyhttps://data.sec.gov/api/xbrl/companyconcept/CIK##########/us-gaap/<Concept>.jsonSmaller download when you need a single line item.
One concept across companieshttps://data.sec.gov/api/xbrl/frames/us-gaap/<Concept>/USD/CY2025Q2.jsonOne value per company for a calendar period, useful for screens and comparisons.

No API key or account is needed. The SEC's fair-access rules ask every client to declare a User-Agent that identifies you (for example a name and email) and to stay at or below 10 requests per second. Requests without a proper User-Agent are often refused.

Option 1 (free): SEC company facts in Python

Standard library only. It looks up Apple's CIK and prints the three most recent revenue values:

import json, urllib.request

UA = {"User-Agent": "Your Name you@example.com"}  # SEC asks every client to identify itself

def get(url):
    with urllib.request.urlopen(urllib.request.Request(url, headers=UA), timeout=30) as r:
        return json.load(r)

# 1. Ticker -> 10-digit CIK
tickers = get("https://www.sec.gov/files/company_tickers.json")
cik = next(f"{t['cik_str']:010d}" for t in tickers.values() if t["ticker"] == "AAPL")

# 2. All XBRL facts for the company, then the latest values of one concept
facts = get(f"https://data.sec.gov/api/xbrl/companyfacts/CIK{cik}.json")
rows = facts["facts"]["us-gaap"]["RevenueFromContractWithCustomerExcludingAssessedTax"]["units"]["USD"]
rows = sorted(rows, key=lambda f: (f["end"], f["filed"]), reverse=True)
for f in rows[:3]:
    print(f["start"], f["end"], f["val"], f["form"], f["fp"], f["filed"], f.get("frame", ""))

Real output (October 17, 2026, about 0.4 s for both requests). Columns: period start, period end, value in USD, form, fiscal period, filing date, frame:

2025-09-28 2026-06-27 364357000000 10-Q Q3 2026-07-31 
2026-03-29 2026-06-27 109417000000 10-Q Q3 2026-07-31 CY2026Q2
2025-09-28 2026-03-28 254940000000 10-Q Q2 2026-05-01 

The first row is the nine-month year-to-date figure, the second is the single quarter (April to June 2026), and the third is the previous quarter's year-to-date value. To build a clean quarterly or annual series you have to tell those apart, and handle the two traps below.

Trap 1: the same value appears many times

Each 10-Q and 10-K repeats earlier periods as comparatives, and companyfacts lists the value once per filing that reported it. If you sort only by filing date and take the top rows, you get last year's comparatives from the newest 10-Q instead of the current quarter. (We found exactly this in our own Actor and fixed it; see below.) Two ways out:

Trap 2: the concept you ask for may have been retired

Companies choose XBRL concepts, and the choices change. Apple reported revenue as Revenues until fiscal 2018; its filings since January 2019 (when the ASC 606 revenue standard took effect for it) use RevenueFromContractWithCustomerExcludingAssessedTax. Ask for Revenues and you silently get 2018 data. In practice, request both concepts (and check the period dates), or look at which concepts a company actually uses in its latest filing. The same applies to other line items, such as net income attributable to the parent versus including non-controlling interests.

Option 2 (API or MCP): filings and facts as clean rows

The Fairquery SEC EDGAR Company Facts & Filings Actor (fairquery/edgar-company-facts-filings) calls the same official endpoints, throttled to at most 5 requests per second with a declared User-Agent. It takes tickers (AAPL), CIKs (320193) or name fragments (nvidia), and emits one row per company, filing, fact, optional text excerpt or error. For facts it sorts by period end, then filing date, and returns a re-reported value only once, so maxFactsPerMetric: 2 gives you the two most recent periods.

We ran it on October 17, 2026 with this input, asking for both revenue concepts on purpose:

{
  "companies": [
    "AAPL"
  ],
  "mode": "both",
  "formTypes": [
    "10-K"
  ],
  "maxFilingsPerCompany": 2,
  "metrics": [
    "Revenues",
    "RevenueFromContractWithCustomerExcludingAssessedTax",
    "NetIncomeLoss",
    "EarningsPerShareDiluted"
  ],
  "maxFactsPerMetric": 2
}

Real output (run time about 2 seconds; 11 rows: 1 company, 2 filings, 8 facts). Abridged to the company row, the latest 10-K and the revenue facts:

[
  {
    "schema_version": "1.0.0",
    "type": "company",
    "source_url": "https://data.sec.gov/submissions/CIK0000320193.json",
    "scraped_at": "2026-10-17T20:09:52.368Z",
    "query": "AAPL",
    "cik": "0000320193",
    "ticker": "AAPL",
    "name": "Apple Inc.",
    "entity_type": "operating",
    "sic": "3571",
    "sic_description": "Electronic Computers",
    "exchanges": [
      "Nasdaq"
    ],
    "ein": "942404110",
    "fiscal_year_end": "0926"
  },
  {
    "schema_version": "1.0.0",
    "type": "filing",
    "source_url": "https://data.sec.gov/submissions/CIK0000320193.json",
    "scraped_at": "2026-10-17T20:09:52.368Z",
    "cik": "0000320193",
    "ticker": "AAPL",
    "name": "Apple Inc.",
    "form": "10-K",
    "filing_date": "2025-10-31",
    "report_date": "2025-09-27",
    "accession_number": "0000320193-25-000079",
    "primary_document": "aapl-20250927.htm",
    "primary_doc_description": "10-K",
    "document_url": "https://www.sec.gov/Archives/edgar/data/320193/000032019325000079/aapl-20250927.htm",
    "filing_url": "https://www.sec.gov/Archives/edgar/data/320193/000032019325000079/",
    "is_xbrl": true,
    "is_inline_xbrl": true,
    "size": 9392337
  },
  {
    "schema_version": "1.0.0",
    "type": "fact",
    "source_url": "https://data.sec.gov/api/xbrl/companyfacts/CIK0000320193.json",
    "scraped_at": "2026-10-17T20:09:52.659Z",
    "cik": "0000320193",
    "ticker": "AAPL",
    "name": "Apple Inc.",
    "taxonomy": "us-gaap",
    "concept": "RevenueFromContractWithCustomerExcludingAssessedTax",
    "label": "Revenue from Contract with Customer, Excluding Assessed Tax",
    "unit": "USD",
    "value": 109417000000,
    "end": "2026-06-27",
    "start": "2026-03-29",
    "filed": "2026-07-31",
    "form": "10-Q",
    "frame": "CY2026Q2",
    "fy": 2026,
    "fp": "Q3",
    "accession_number": "0000320193-26-000020"
  },
  {
    "schema_version": "1.0.0",
    "type": "fact",
    "source_url": "https://data.sec.gov/api/xbrl/companyfacts/CIK0000320193.json",
    "scraped_at": "2026-10-17T20:09:52.659Z",
    "cik": "0000320193",
    "ticker": "AAPL",
    "name": "Apple Inc.",
    "taxonomy": "us-gaap",
    "concept": "RevenueFromContractWithCustomerExcludingAssessedTax",
    "label": "Revenue from Contract with Customer, Excluding Assessed Tax",
    "unit": "USD",
    "value": 364357000000,
    "end": "2026-06-27",
    "start": "2025-09-28",
    "filed": "2026-07-31",
    "form": "10-Q",
    "fy": 2026,
    "fp": "Q3",
    "accession_number": "0000320193-26-000020"
  },
  {
    "schema_version": "1.0.0",
    "type": "fact",
    "source_url": "https://data.sec.gov/api/xbrl/companyfacts/CIK0000320193.json",
    "scraped_at": "2026-10-17T20:09:52.659Z",
    "cik": "0000320193",
    "ticker": "AAPL",
    "name": "Apple Inc.",
    "taxonomy": "us-gaap",
    "concept": "Revenues",
    "label": "Revenues",
    "unit": "USD",
    "value": 62900000000,
    "end": "2018-09-29",
    "start": "2018-07-01",
    "filed": "2018-11-05",
    "form": "10-K",
    "frame": "CY2018Q3",
    "fy": 2018,
    "fp": "FY",
    "accession_number": "0000320193-18-000145"
  }
]

Note the last row: Revenues for Apple ends in September 2018, while RevenueFromContractWithCustomerExcludingAssessedTax gives the quarter to June 27, 2026 ($109.4 billion) and the nine months to that date ($364.4 billion). The same run returned NetIncomeLoss (29,789,000,000 for the quarter) and diluted EPS (2.02). Every row carries source_url, the accession number and the filing date, so an agent can cite where a number came from. Run summary: 3 SEC requests, 0 errors.

That run costs 1 × $0.0015 + 2 × $0.001 + 8 × $0.0002 = $0.0051, plus Apify's $0.00005 Actor-start fee.

Name lookup and error rows

Input {"companies": ["nvidia", "ZZNOTREAL"], "mode": "filings", "formTypes": ["8-K"], "maxFilingsPerCompany": 3} resolved the name to NVIDIA CORP (CIK 0001045810) and returned a machine-readable error for the unknown query. Real output, abridged to the company row, the newest 8-K and the error:

[
  {
    "schema_version": "1.0.0",
    "type": "company",
    "source_url": "https://data.sec.gov/submissions/CIK0001045810.json",
    "scraped_at": "2026-10-17T20:10:05.758Z",
    "query": "nvidia",
    "cik": "0001045810",
    "ticker": "NVDA",
    "name": "NVIDIA CORP",
    "entity_type": "operating",
    "sic": "3674",
    "sic_description": "Semiconductors & Related Devices",
    "exchanges": [
      "Nasdaq"
    ],
    "ein": "943177549",
    "fiscal_year_end": "0131"
  },
  {
    "schema_version": "1.0.0",
    "type": "filing",
    "source_url": "https://data.sec.gov/submissions/CIK0001045810.json",
    "scraped_at": "2026-10-17T20:10:05.758Z",
    "cik": "0001045810",
    "ticker": "NVDA",
    "name": "NVIDIA CORP",
    "form": "8-K",
    "filing_date": "2026-09-03",
    "report_date": "2026-09-02",
    "accession_number": "0001045810-26-000078",
    "primary_document": "nvda-20260902.htm",
    "primary_doc_description": "8-K",
    "document_url": "https://www.sec.gov/Archives/edgar/data/1045810/000104581026000078/nvda-20260902.htm",
    "filing_url": "https://www.sec.gov/Archives/edgar/data/1045810/000104581026000078/",
    "is_xbrl": true,
    "is_inline_xbrl": true,
    "size": 146499
  },
  {
    "schema_version": "1.0.0",
    "type": "error",
    "source_url": "https://data.sec.gov/",
    "scraped_at": "2026-10-17T20:10:05.929Z",
    "code": "COMPANY_NOT_FOUND",
    "message": "Could not resolve company query: ZZNOTREAL",
    "retryable": false,
    "query": "ZZNOTREAL"
  }
]

Error rows are never charged. Other codes are INPUT_EMPTY, RESOLVE_FAILED, SUBMISSIONS_FETCH_FAILED, FACTS_FETCH_FAILED and EXCERPT_FETCH_FAILED.

From Python, curl or an AI agent

With the official apify-client package (v3; set APIFY_TOKEN):

import os
from apify_client import ApifyClient

client = ApifyClient(os.environ["APIFY_TOKEN"])
run = client.actor("fairquery/edgar-company-facts-filings").call(run_input={
    "companies": ["AAPL"],
    "mode": "both",
    "formTypes": ["10-K"],
    "maxFilingsPerCompany": 2,
    "metrics": ["Revenues", "RevenueFromContractWithCustomerExcludingAssessedTax",
                "NetIncomeLoss", "EarningsPerShareDiluted"],
    "maxFactsPerMetric": 2,
})
for row in client.dataset(run.default_dataset_id).iterate_items():
    if row["type"] == "fact":
        print(row["concept"], row["start"], row["end"], row["value"], row["form"], row.get("frame", ""))

Or one synchronous HTTP call that returns the rows directly:

curl -s -X POST "https://api.apify.com/v2/acts/fairquery~edgar-company-facts-filings/run-sync-get-dataset-items" \
  -H "Authorization: Bearer $APIFY_TOKEN" -H "Content-Type: application/json" \
  -d '{"companies": ["nvidia"], "mode": "filings", "formTypes": ["8-K"], "maxFilingsPerCompany": 1}'

In our tests a one-company run took about 2 to 14 seconds end to end, mostly container start-up; the SEC requests themselves took under half a second. For agents, add the Apify MCP server scoped to this Actor (https://mcp.apify.com/?tools=fetch-actor-details,fairquery/edgar-company-facts-filings) to Claude Desktop, Cursor or VS Code, then ask for example: "Get Apple's last two 10-K filings and its latest revenue, net income and diluted EPS from SEC EDGAR." A local stdio MCP server is also in the GitHub repo.

Input options worth knowing

Pricing

OptionPrice
SEC EDGAR APIs directly (your own code)Free
Fairquery SEC EDGAR Actor (Apify, pay per event)$0.0015 per company resolved, $0.001 per filing row, $0.0002 per fact row, $0.002 per text excerpt, plus Apify's $0.00005 Actor-start event. Error rows are free.

Example: 100 companies with 5 filings and 16 fact rows each cost 100 × $0.0015 + 500 × $0.001 + 1,600 × $0.0002 = $0.97.

How it compares with alternatives

OptionGood forTrade-offs
SEC APIs directlyFree, official, complete for what they coverYou handle CIK lookup, throttling, User-Agent, duplicate values, concept changes and joining filings to facts
Open-source Python libraries (for example edgartools)Rich parsing of filings and financial statements in Python notebooks and scriptsA Python dependency to run and maintain; not a hosted API or MCP tool
Commercial SEC data APIsBroader feature sets such as full-text search and parsers for many form typesAccount and subscription plans
Fairquery SEC EDGAR ActorOne API or MCP call from agents, n8n or scripts; ticker/CIK/name lookup, filings with document URLs and de-duplicated latest facts as JSON rows, pay per rowRecent filings and companyfacts only: no realtime quotes, no full-text search, no Form 4 parsing, no frames (cross-company) queries, US SEC registrants only

FAQ

Is there a free SEC EDGAR API?

Yes. The SEC serves free JSON at data.sec.gov with no API key: submissions (company metadata and filings), companyfacts, companyconcept and frames (XBRL financial data). Declare a User-Agent with your contact details and stay at or below 10 requests per second.

How do I get a company's CIK from its ticker?

Download https://www.sec.gov/files/company_tickers.json, find the ticker, and left-pad cik_str to 10 digits (Apple is 0000320193). The Fairquery EDGAR Actor also accepts tickers, CIKs or company name fragments directly.

Why is revenue missing or years old for some companies?

XBRL concepts change. Apple's Revenues values end in 2018; since 2019 it reports RevenueFromContractWithCustomerExcludingAssessedTax. Request both concepts and check the period end dates.

Why does companyfacts list the same value several times?

Each 10-Q and 10-K repeats earlier periods as comparatives, and companyfacts lists the value once per filing. Sort by period end, keep one value per period from the latest filing, or filter on the frame field. The Fairquery Actor returns each period once.

How much does the Fairquery SEC EDGAR Actor cost?

$0.0015 per company resolved, $0.001 per filing row, $0.0002 per fact row and $0.002 per optional text excerpt, plus Apify's $0.00005 Actor-start event. Error rows are free. Our example run (1 company, 2 filings, 8 facts) costs $0.0051.

Can AI agents use it?

Yes. Add the Apify MCP server with tools=fairquery/edgar-company-facts-filings to Claude Desktop, Cursor or VS Code, call the Actor via the Apify API, or run the stdio MCP server from the GitHub repo.

Is this investment advice?

No. It returns public SEC EDGAR data as reported, for research and tooling, with no warranty of completeness. Check important figures against the linked filing.

Not investment advice. Data comes from the U.S. Securities and Exchange Commission's EDGAR system and is returned as reported, with no warranty of completeness. Check important figures against the filing itself (every row links to it).

Source and docs: github.com/fairquery/edgar-company-facts-filings (MIT) · Apify Store · all Fairquery tools