SEC API in Python: requests, paging, retries and pandas
Uses Filings search, Insider trading
Every endpoint takes the same body, query, from, size and sort, and returns total and data. So one function covers all of them. All you need is requests and an API key.
pip install requests pandas
export QUANTISNOW_API_KEY=qs_your_keyA client in 30 lines
import os, time, requests
BASE = "https://www.quantisnow.com/api/v1"
session = requests.Session()
session.headers["Authorization"] = f"Bearer {os.environ['QUANTISNOW_API_KEY']}"
def search(endpoint, query, size=50, start=0, sort=None):
body = {"query": query, "size": size, "from": start}
if sort:
body["sort"] = sort
for attempt in range(5):
res = session.post(f"{BASE}/{endpoint}", json=body, timeout=30)
if res.status_code == 429 and res.json()["error"]["code"] == "rate_limited":
time.sleep(int(res.headers.get("retry-after", "1")))
continue
if not res.ok:
raise RuntimeError(res.json()["error"]["message"])
return res.json()
raise RuntimeError("still rate limited after 5 tries")
def search_all(endpoint, query, sort=None, limit=10_000):
rows, start = [], 0
while start < limit:
page = search(endpoint, query, start=start, sort=sort)
rows += page["data"]
start += 50
if start >= page["total"]["value"]:
break
return rowsTwo kinds of 429 come back. rate_limited means too many requests in one second and is worth a retry after retry-after. quota_exceeded means the month's calls and your credits are used up, and retrying won't help.
Use it
import pandas as pd
filings = search_all("filings", "ticker:NVDA AND filedAt:[2026-01-01 TO 2026-11-23]", sort="filedAt:desc")
df = pd.DataFrame(filings)
print(df.groupby("formType").size().sort_values(ascending=False))That query returns records like these:
What has Nvidia filed with the SEC in the last 90 days?
A company's whole filing history for a quarter, newest first, to diff against what you already have.
curl -X POST https://www.quantisnow.com/api/v1/filings \
-H "Authorization: Bearer $QUANTISNOW_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"query": "ticker:NVDA AND filedAt:[2026-08-24 TO 2026-11-22]",
"from": 0,
"size": 5,
"sort": [
{
"filedAt": {
"order": "desc"
}
}
]
}'Response
{
"total": {
"value": 24,
"relation": "eq"
},
"data": [
{
"id": "0001045810-26-000088",
"accessionNo": "0001045810-26-000088",
"formType": "8-K",
"filedAt": "2026-11-17T16:20:51-05:00",
"cik": "0001045810",
"companyName": "NVIDIA Corporation",
"ticker": "NVDA",
"tickers": [
"NVDA"
],
"items": [
"2.02",
"9.01"
],
"description": "NVIDIA Corporation filed SEC Form 8-K: Results of Operations and Financial Condition, Financial Statements and Exhibits",
"linkToFilingIndex": "https://www.sec.gov/Archives/edgar/data/1045810/000104581026000088/0001045810-26-000088-index.htm",
"quantisnowUrl": "https://www.quantisnow.com/insight/nvidia-corporation-filed-sec-form-8-k-results-of-operations-and-6796844"
},
{
"id": "0001045810-26-000084",
"accessionNo": "0001045810-26-000084",
"formType": "13F-HR",
"filedAt": "2026-11-16T16:41:59-05:00",
"cik": "0001045810",
"companyName": "NVIDIA Corporation",
"ticker": "NVDA",
"tickers": [
"NVDA"
],
"items": [],
"description": "SEC Form 13F-HR filed by NVIDIA Corporation",
"linkToFilingIndex": "https://www.sec.gov/Archives/edgar/data/1045810/000104581026000084/0001045810-26-000084-index.htm",
"quantisnowUrl": "https://www.quantisnow.com/insight/sec-form-13f-hr-filed-by-nvidia-corporation-6794719"
},
{
"id": "0001045810-26-000082",
"accessionNo": "0001045810-26-000082",
"formType": "8-K",
"filedAt": "2026-11-12T08:52:41-05:00",
"cik": "0001045810",
"companyName": "NVIDIA Corporation",
"ticker": "NVDA",
"tickers": [
"NVDA"
],
"items": [
"5.02",
"9.01"
],
"description": "NVIDIA Corporation filed SEC Form 8-K: Leadership Update, Financial Statements and Exhibits",
"linkToFilingIndex": "https://www.sec.gov/Archives/edgar/data/1045810/000104581026000082/0001045810-26-000082-index.htm",
"quantisnowUrl": "https://www.quantisnow.com/insight/nvidia-corporation-filed-sec-form-8-k-leadership-update-financial-statements-6786747"
},
{
"id": "0001197647-26-000013",
"accessionNo": "0001197647-26-000013",
"formType": "4",
"filedAt": "2026-11-06T16:12:02-05:00",
"cik": "0001045810",
"companyName": "NVIDIA Corporation",
"ticker": "NVDA",
"tickers": [
"NVDA"
],
"items": [],
"description": "Director Coxe Tench gifted 500,000 units of Common (SEC Form 4)",
"linkToFilingIndex": "https://www.sec.gov/Archives/edgar/data/1045810/000119764726000013/0001197647-26-000013-index.htm",
"quantisnowUrl": "https://www.quantisnow.com/insight/director-coxe-tench-gifted-500000-units-of-common-sec-form-6778977"
},
{
"id": "0002152188-26-000007",
"accessionNo": "0002152188-26-000007",
"formType": "4/A",
"filedAt": "2026-10-13T17:09:29-04:00",
"cik": "0001045810",
"companyName": "NVIDIA Corporation",
"ticker": "NVDA",
"tickers": [
"NVDA"
],
"items": [],
"description": "Amendment: SEC Form 4/A filed by NVIDIA Corporation",
"linkToFilingIndex": "https://www.sec.gov/Archives/edgar/data/1045810/000215218826000007/0002152188-26-000007-index.htm",
"quantisnowUrl": "https://www.quantisnow.com/insight/amendment-sec-form-4a-filed-by-nvidia-corporation-6745423"
}
]
}Know what you have left
Every response carries x-ratelimit-remaining, the plan calls left this month. When a call is paid from credits (the free calls are credits), x-credits-remaining shows the balance. GET /v1/usage returns both and is free.
res = session.post(f"{BASE}/filings", json={"query": "formType:10-K", "size": 1})
print(res.headers["x-ratelimit-remaining"], res.headers.get("x-credits-remaining"))Searching inside the text of filings instead? See keyword search in Python. More than 10,000 results? See paging past 10,000.