Code Examples
Copy-paste snippets for cURL, Python, and JavaScript. All endpoints use the same x-api-key header for authentication.
cURL
bash
# Get recent filingscurl "https://api.secdaily.io/filings?limit=5" \-H "x-api-key: YOUR_API_KEY"# Get 10-K filings for Applecurl "https://api.secdaily.io/filings?cik=320193&formTypes=10-K&limit=5" \-H "x-api-key: YOUR_API_KEY"# Get insider purchasescurl "https://api.secdaily.io/insider-transactions?transactionTypes=purchase&limit=10" \-H "x-api-key: YOUR_API_KEY"# Get latest newscurl "https://api.secdaily.io/news?newsType=PressReleases&limit=5" \-H "x-api-key: YOUR_API_KEY"# Pretty-print with jqcurl -s "https://api.secdaily.io/filings?limit=3" \-H "x-api-key: YOUR_API_KEY" | jq .
Python
Uses the requests library. Install with pip install requests.
python
import osimport requestsAPI_KEY = os.environ["SEC_API_KEY"]BASE = "https://api.secdaily.io"HEADERS = {"x-api-key": API_KEY}# --- Filings ---resp = requests.get(f"{BASE}/filings", headers=HEADERS, params={"cik": "320193","formTypes": "10-K","limit": 5,})for f in resp.json()["filings"]:print(f"{f['filingDateInEst']} {f['formType']} - {f.get('entity', {}).get('name')}")# --- Insider transactions ---resp = requests.get(f"{BASE}/insider-transactions", headers=HEADERS, params={"transactionTypes": "purchase","limit": 10,})for t in resp.json()["insiderTransactions"]:print(f"{t['filingDateInEst']} CIK {t['issuerCik']} ${t.get('totalAmount', 0):,.0f}")# --- News ---resp = requests.get(f"{BASE}/news", headers=HEADERS, params={"newsType": "PressReleases","limit": 5,})for n in resp.json()["news"]:print(f"{n['publishedDateInUtc'][:10]} {n['title']}")
JavaScript
Uses the built-in fetch API (Node.js 18+ or any modern browser).
javascript
const API_KEY = process.env.SEC_API_KEY;const BASE = "https://api.secdaily.io";async function secApi(path, params = {}) {const url = new URL(path, BASE);Object.entries(params).forEach(([k, v]) => url.searchParams.set(k, v));const res = await fetch(url, { headers: { "x-api-key": API_KEY } });if (!res.ok) throw new Error(`${res.status} ${res.statusText}`);return res.json();}// Filingsconst filings = await secApi("/filings", { cik: "320193", formTypes: "10-K", limit: 5 });for (const f of filings.filings) {console.log(`${f.filingDateInEst} ${f.formType} - ${f.entity?.name}`);}// Insider transactionsconst insider = await secApi("/insider-transactions", { transactionTypes: "purchase", limit: 10 });for (const t of insider.insiderTransactions) {console.log(`${t.filingDateInEst} CIK ${t.issuerCik} $${t.totalAmount?.toLocaleString()}`);}// Newsconst news = await secApi("/news", { newsType: "PressReleases", limit: 5 });for (const n of news.news) {console.log(`${n.publishedDateInUtc.slice(0, 10)} ${n.title}`);}
Error handling
Always handle rate limits (429) with exponential backoff:
python
import time, requestsdef fetch_with_retry(url, headers, params=None, retries=3):for attempt in range(retries):resp = requests.get(url, headers=headers, params=params)if resp.status_code == 429:wait = 30 * (2 ** attempt)print(f"Rate limited, waiting {wait}s...")time.sleep(wait)continuereturn respraise Exception("Max retries exceeded")
Sample response
All list endpoints return a similar shape. Here's a filings response:
json
{"filings": [{"id": "0000320193-24-000123","formType": "10-K","filingDateInEst": "2024-11-01","entity": {"name": "Apple Inc.","cik": "0000320193","ticker": "AAPL"},"periodOfReport": "2024-09-28","linkToFiling": "https://www.sec.gov/Archives/edgar/data/320193/..."}],"count": 42,"hasMore": true}
See each endpoint's page for full response field documentation: Filings, Insider Transactions, News.