# SEC EDGAR & XBRL API in Python: 10-K, 10-Q & CIK Lookup

> Query normalized Form 10-K and discrete quarterly 10-Q financial statements, segments, ticker-to-CIK mappings, and raw XBRL company facts via JSON or CSV.

Canonical URL: https://quantset.dev/docs/guides/sec-edgar-xbrl-api
Full LLM API Contract: https://api.quantset.dev/llms-full.txt

> ## For AI agents
> The QuantSet API is at https://api.quantset.dev. Send the key in the `X-API-Key` header. The sandbox key `mw_demo` needs no signup and reads the sample listings.
> No key yet? An agent can open an account on its own: https://api.quantset.dev/skill.md
> Connect an MCP client to https://api.quantset.dev/mcp. Client setup is at https://api.quantset.dev/agents.md.
> Start with https://api.quantset.dev/llms.txt or read the full reference at https://api.quantset.dev/llms-full.txt. The OpenAPI file is https://api.quantset.dev/openapi.json. Add `.md` to any docs URL to get that page as Markdown.

Raw SEC EDGAR `companyfacts.json` archives force engineers to untangle thousands of drifting US-GAAP and IFRS XBRL taxonomy tags, subtract cumulative 6-month and 9-month Form 10-Q cash flows into discrete quarters, zero-pad 10-digit CIK numbers, and manage SEC fair-access rate headers. QuantSet exposes both normalized statements and raw XBRL company facts behind one fast JSON/CSV contract.
          

          

## Four traps when parsing raw SEC EDGAR XBRL files

          
            
- **Taxonomy concept drift:** A single line item like revenue spans multiple XBRL concepts over a company's history (`Revenues`, `RevenueFromContractWithCustomerExcludingAssessedTax`, `SalesRevenueNet`). Naive parsers leave multi-year holes when an issuer adopts ASC 606 or switches tags.
            
- **Cumulative YTD Form 10-Q cash flows:** On Form 10-Q, issuers frequently report Q2 and Q3 cash flow statements as 6-month and 9-month year-to-date totals rather than standalone 3-month quarters. Feeding raw YTD numbers into a trailing-twelve-month (TTM) screen inflates free cash flow by 2–3×.
            
- **Amendments & restatements (`10-K/A`, `10-Q/A`):** Raw fact arrays mix comparative prior-year footnotes with restated filings unless filtered carefully by frame, period duration, form type, and filing date.
            
- **CIK vs. ticker mapping:** SEC EDGAR indexes issuers by 10-digit zero-padded Central Index Key (`0001045810`), not exchange ticker (`NVDA`), and reuses or changes tickers after mergers.
          

          

## 1. Instant Ticker ↔ SEC CIK lookup

          

Resolve any ticker or company name to its canonical `instrument_id`, 10-digit SEC `cik`, 4-digit `sic` industry code, and canonical sector in one call:
          
            
```
curl "https://api.quantset.dev/api/v1/instruments?q=NVDA" -H "X-API-Key: mw_demo"
```

          

          

## 2. Normalized Form 10-K & 10-Q statements (with filing provenance)

          

Query `income`, `balance_sheet`, or `cash_flow` across up to 100 companies at once. Every row preserves its SEC accession number, form type (`10-K` / `10-Q`), and `available_at` date so point-in-time backtests never peek ahead of the actual EDGAR filing date:
          
            
```
curl "https://api.quantset.dev/api/v1/financial-statements/cash_flow?tickers=us:NVDA&period=quarterly&limit_per_instrument=4" -H "X-API-Key: mw_demo"
```

          
          

**Discrete quarters, not unlabelled YTD sums:** QuantSet reconciles cumulative Form 10-Q periods into discrete quarterly figures and labels provenance explicitly—returning `null` whenever a line item cannot be verified cleanly.

          

## 3. Tag-level SEC XBRL Company Facts (by CIK or ticker)

          

When an audit or specialized industry model needs exact as-reported XBRL concepts (such as `RemainingPerformanceObligation` or custom footnotes), query `/api/v1/sec/company-facts` using exactly one of `ticker=NVDA` or `issuer_cik=0001045810`:
          
            
```
curl "https://api.quantset.dev/api/v1/sec/company-facts?issuer_cik=0001045810&limit=5" -H "X-API-Key: mw_demo"
```

          

          

## 4. Revenue segments, debt maturities, headcount & executive pay

          

Beyond the three core statements, QuantSet extracts structured footnote tables from 10-K filings—including geographic/product revenue segments, debt maturity schedules, employee headcount history, and proxy executive compensation:
          
            
```
curl "https://api.quantset.dev/api/v1/segments?ticker=NVDA&limit=6" -H "X-API-Key: mw_demo"
```

          
          
            
```
curl "https://api.quantset.dev/api/v1/employees?ticker=AAPL&limit=5" -H "X-API-Key: mw_demo"
```

---

## QuantSet Ecosystem & Integrations (https://quantset.dev/integrations)

- **MCP Clients & 7 Skills:** `npx quantset init` & `npx skills add quantset/skills` (Claude, Claude Code, Cursor, ChatGPT, Codex, Hermes, OpenClaw, Block Goose, Cline, Docker MCP Toolkit — `https://api.quantset.dev/mcp`)
- **Python SDK & Agent Frameworks:** `pip install "quantset[pandas]"` · `from quantset.tools import build_agent_functions, langchain_tools, crewai_tools` (PydanticAI, LangGraph, LangChain, CrewAI, Agno, AutoGen, Google ADK, OpenAI Agents SDK)
- **TypeScript SDK & Vercel AI / Mastra:** `npm install quantset` · `import { createQuantsetTools } from "quantset/tools"` (Node 20+, Bun, Deno, Cloudflare Workers, Vercel Edge)
- **Spreadsheets & Workspaces:** Google Sheets (`=QUANTSET()` & `=IMPORTDATA()`), Microsoft Excel Power Query (`?format=csv`), Notion MCP & n8n/Make webhooks (`https://quantset.dev/docs/guides/google-sheets-excel-notion-stock-templates`)
- **Drop-In Migrations & Machine Payments:** FMP `/stable/*` & `/v3/*` adapter (`https://quantset.dev/docs/switch/fmp`), `yfinance` migration (`https://quantset.dev/docs/switch/yfinance`), autonomous signup (`https://api.quantset.dev/skill.md`), and `x402` Base USDC.
