I recently posted about an API I built for SEC EDGAR data. While writing the example code for that article, I kept looking at all the boilerplate — setting headers, building URLs, parsing responses — and thought, this should just be a pip install.
So I made one.
pip install sec-edgar-sdk
The whole thing is 6 methods
from sec_edgar import SecEdgar
api = SecEdgar("YOUR_RAPIDAPI_KEY")
# Get company info
api.company("AAPL")
# Search companies
api.search("tesla")
# Filing history
api.filings("TSLA", form="10-K", limit=5)
# Financial statements
api.financials("MSFT", statement="income_statement")
# Shortcuts
api.revenue("AAPL", limit=5)
api.net_income("MSFT", limit=3)
That's it. No configuration classes, no builder patterns, no 200-page docs. I wanted something where you read the method name and already know what it does.
What I actually use it for
I've been tracking revenue trends for a handful of companies. Before the SDK, the script looked like this:
import requests
url = "https://sec-edgar-data-api.p.rapidapi.com/v1/financials/AAPL"
headers = {
"x-rapidapi-key": "YOUR_KEY",
"x-rapidapi-host": "sec-edgar-data-api.p.rapidapi.com"
}
response = requests.get(url, headers=headers, params={
"statement": "income_statement", "limit": 5
})
data = response.json()
for item in data["statements"]["income_statement"]:
if item["concept"] == "revenue":
for year in item["data"]:
print(f"FY{year['fiscal_year']}: ${year['value']:,.0f}")
Now:
from sec_edgar import SecEdgar
api = SecEdgar("YOUR_KEY")
for year in api.revenue("AAPL", limit=5):
print(f"FY{year['fiscal_year']}: ${year['value']:,.0f}")
FY2025: $383,285,000,000
FY2024: $394,328,000,000
FY2023: $365,817,000,000
FY2022: $391,035,000,000
FY2021: $378,323,000,000
3 lines instead of 13. That's the whole point.
Comparing companies side by side
One thing I keep doing — quick earnings comparisons without opening a Bloomberg terminal I don't have:
from sec_edgar import SecEdgar
api = SecEdgar("YOUR_KEY")
for ticker in ["AAPL", "MSFT", "GOOG"]:
info = api.company(ticker)
rev = api.revenue(ticker, limit=1)
latest = rev[0]["value"] if rev else 0
print(f"{info['name']}: ${latest / 1e9:.1f}B")
Apple Inc.: $383.3B
Microsoft Corporation: $254.2B
Alphabet Inc.: $339.9B
Nothing fancy. Just the kind of thing I used to waste 20 minutes on.
Error handling
The SDK raises SecEdgarError with the status code and detail, so you're not guessing what went wrong:
from sec_edgar.client import SecEdgarError
try:
api.company("NOTREAL")
except SecEdgarError as e:
print(e.status_code) # 404
print(e.detail) # "Ticker not found"
The boring details
- Wraps the SEC EDGAR Data API on RapidAPI
- Free tier: 100 requests/month, no credit card
- Uses
requestsunder the hood (the only dependency) - Supports context managers (
with SecEdgar(...) as api:) - Python 3.9+
- MIT license
Source: github.com/LiamAltie/sec-edgar-sdk
If you're working with SEC data and have ideas for what else the SDK should do, I'm all ears. Thinking about adding async support and maybe a CLI, but honestly trying not to over-engineer it.
Top comments (2)
Six methods is refreshingly simple for an SDK. Most financial data wrappers try to do way too much and end up confusing.
Thanks! That was exactly the goal — if the API only has 4 endpoints, the SDK shouldn't need 40 methods. I'd rather people read the README once and never come back to it.