Registry / http-networking / sec-api

sec-api

JSON →
library1.0.36pypypi✓ verified 22d ago

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.

pip install sec-api
INSTALL
IMPORT
SIG · SEC-API
S
sec-api
http-networkingpythonv1.0.36
Install
2.1s avg
Import
363ms
Disk
19MB
Pass rate
10/ 10
Env Coverage10 / 10
glibc
3.93.13
musl
3.93.13
Install & Compatibility
Where this runs
tested against v1.0.36 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
py 3.103.95 runs
installs and imports cleanly · install 0.0s · import 0.376s · 21.3MB
glibc
py 3.103.95 runs
installs and imports cleanly · install 2.1s · import 0.350s · 22MB
19MB installed
● package 19MB
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

QueryApi
from sec_api import QueryApi
Used for searching and filtering SEC EDGAR filings metadata.
FullTextSearchApi
from sec_api import FullTextSearchApi
For searching the full text of SEC filings and their exhibits.
DownloadApi
from sec_api import DownloadApi
from sec_api import RenderApi
DownloadApi is the current class for downloading filings and exhibits. RenderApi was an alias or an older name for this functionality and is now a dedicated class in recent versions (>=1.0.34).
XbrlApi
from sec_api import XbrlApi
For converting XBRL data to JSON and extracting financial statements.
Datasets
from sec_api import Datasets
Introduced in v1.0.34 for managing and downloading bulk datasets.

This quickstart demonstrates how to use the QueryApi to retrieve metadata for the latest 50 EDGAR filings for Tesla. Remember to replace 'YOUR_API_KEY' with a valid API key or set the 'SEC_API_KEY' environment variable.

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']}")
Debug
Known issues
gotchaAn API key is required for all interactions with the SEC API. Obtain a free API key from sec-api.io.
fix
Ensure `api_key` is provided when instantiating any API client class, e.g., `QueryApi(api_key="YOUR_API_KEY")`. It is recommended to use environment variables for keys.
affects: All versions
gotchaSearch 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.
fix
For datasets larger than 10,000 records, you will need to break down your queries by narrower time ranges or other filters to retrieve all data.
affects: All versions
gotchaThe SEC API imposes rate limits. Exceeding approximately 40 requests per second can lead to temporary blocks of your API key.
fix
Implement proper rate-limiting in your application to stay within the allowed request rate. Check your specific plan for exact limits.
affects: All versions
deprecatedThe `RenderApi` class for downloading filings has been superseded by `DownloadApi`. While `RenderApi` might still function due to aliases, using `DownloadApi` is recommended.
fix
Update imports and instantiation from `RenderApi` to `DownloadApi`. For example, `from sec_api import DownloadApi` and `downloadApi = DownloadApi(...)`.
affects: Introduced in 1.0.34
Errors
Common errors & fixes
ModuleNotFoundError: No module named 'sec_api'
The `sec-api` library is either not installed, installed in a different Python environment, or the import statement uses an incorrect module name.
fix
Install the library using `pip install sec-api`. Ensure your import statement is `import sec_api` or `from sec_api import ...`.
Exception: {"error": "Unauthorized"}
The API key provided during client initialization is missing, incorrect, expired, or doesn't have the necessary permissions, leading to authentication failure with the SEC API service.
fix
Obtain a valid API key from your SEC API dashboard and ensure it is correctly passed as a string when initializing the client (e.g., `sec_api.query_api.QueryApi("YOUR_VALID_API_KEY")`).
AttributeError: module 'sec_api' has no attribute 'get_filings'
You are attempting to call an API method (like `get_filings`) directly from the top-level `sec_api` module instead of from an instantiated client object (e.g., `QueryApi`).
fix
First, instantiate the relevant API client (e.g., `queryApi = sec_api.query_api.QueryApi(api_key)`), then call the method on that object (e.g., `queryApi.get_filings(...)`).
KeyError: 'some_missing_key'
The code is trying to access a key (e.g., `'some_missing_key'`) from a dictionary within the API response, but that key does not exist in the specific response structure or filing data.
fix
Double-check the exact structure of the API response JSON. Use `dict.get('key_name', default_value)` to safely access keys and provide a fallback, or explicitly check for key existence using `if 'key_name' in my_dict:`.
Upgrade
Version history
1.0.36latest on PyPI · released Apr 13, 2026
Audit
Dependencies

No dependency data recorded yet.

Agent activity
10 hits · last 30 days
node
8
OpenAI (training)
1
Resources
sec-api — pip install sec-api · libregistry