This project provides a pipeline to fetch, process, and store financial data from the SEC EDGAR database. It focuses on:
- Company metadata (name, CIK, ticker, SIC, etc.)
- Filings history (10-K, 10-Q, and other forms)
- Company facts and US GAAP financial metrics (Revenue, Net Income, Accounts Payable, etc.)
- It also flattens nested XBRL data into a relational SQLite database for easy querying and analysis.
The project is designed to be configurable, allowing you to track additional metrics or forms over time.
Features
- Automatically fetch company filings and facts from SEC EDGAR based on CIK
- Flatten and normalize XBRL metrics into a structured format.
- Store metadata, filings, and metrics in an SQLite database.
- Flexible configuration to track specific financial metrics.
- Supports historical analysis of key financial data over multiple years.
Installation
Clone the repository:
- git clone - https://github.com/Max1-618/Edgar-SEC-API.git
- cd Edgar-SEC-API
Create and activate a Python virtual environment:
- python -m venv .venv
- source .venv/bin/activate # Linux / Mac
- .venv\Scripts\activate # Windows
Install dependencies:
- pip install -r requirements.txt
Add your SEC API headers in config/SEC_header.py:
- headers = { "User-Agent": "Your Name your_email@example.com", }
Usage
- Prepare a CSV of company tickers and CIKs:
ticker,cik AAPL,0000320193 MSFT,0000789019 NVDA,0001045810
- Place it in the config/path
Run the ingestion script to fetch and store data:
- python ingestion.py
Check the SQLite database (DB_PATH) for:
- companies – Company metadata
- filings – Historical filings
- company_facts – Flattened financial metrics
Use extract scripts to query metrics, for example, Revenue or Accounts Payable over years.
Configuration
- You can configure which metrics to track in utils/source/source.py by editing the COMPANY_FACTS_SOURCE dictionary. For example, to track AccountsPayable:
COMPANY_FACTS_SOURCE = { ... "metrics": ["AccountsPayable"], ... }
- You can add new metrics, taxonomies, or even new tables without changing the ingestion logic.
Important Resources
- SEC EDGAR API Documentation
- XBRL US GAAP Taxonomy
- Python Requests Library
- Pandas Documentation
- SQLite Documentation
Future Enhancements
- Add visualizations of key metrics over time (Revenue, Net Income, EPS).
- Create a financial dictionary automatically by tagging metrics across companies.
- Build a web interface/dashboard to explore companies and metrics interactively.