SEC API Python Client
The `sec-api` Python library provides a robust client for accessing SEC EDGAR filings data. It offers various APIs for querying, full-text searching, real-time streaming, and converting/extracting structured data from over 20 million filings and 800,000+ entities, dating back to 1993 with real-time updates. The library is actively maintained, with frequent updates adding new API wrappers and features. The current version is 1.0.35.
Warnings
- gotcha An API key is required for all interactions with the SEC API. Obtain a free API key from sec-api.io.
- gotcha Search APIs (e.g., QueryApi, Form D API) have a maximum limit of 10,000 records per query, even when using the 'from' parameter for pagination.
- gotcha The SEC API imposes rate limits. Exceeding approximately 40 requests per second can lead to temporary blocks of your API key.
- deprecated The `RenderApi` class for downloading filings has been superseded by `DownloadApi`. While `RenderApi` might still function due to aliases, using `DownloadApi` is recommended.
Install
-
pip install sec-api
Imports
- QueryApi
from sec_api import QueryApi
- FullTextSearchApi
from sec_api import FullTextSearchApi
- DownloadApi
from sec_api import DownloadApi
- XbrlApi
from sec_api import XbrlApi
- Datasets
from sec_api import Datasets
Quickstart
import os
from sec_api import QueryApi
# Get your free API key at sec-api.io
API_KEY = os.environ.get("SEC_API_KEY", "YOUR_API_KEY")
queryApi = QueryApi(api_key=API_KEY)
search_params = {
"query": "ticker:TSLA",
"from": "0",
"size": "50",
"sort": [{"filedAt": {"order": "desc"}}]
}
response = queryApi.get_filings(search_params)
print(f"Total filings for TSLA: {response['total']['value']}")
for filing in response['filings']:
print(f" - {filing['formType']} filed on {filing['filedAt']}: {filing['linkToFilingDetails']}")