I Was Tired of Parsing XBRL, So I Built a SEC EDGAR API

Published: (March 13, 2026 at 09:24 PM EDT)
3 min read
Source: Dev.to

Source: Dev.to

Cover image for I Was Tired of Parsing XBRL, So I Built a SEC EDGAR API

Introduction

If you’ve ever tried to pull financial data from the SEC’s EDGAR system, you probably know where this is going.

I wanted to build a stock screener. Simple idea — just show me revenue trends for a few companies. Should take an afternoon, right?

Nope. First you need a company’s CIK number (Apple is 0000320193 — don’t ask me why it’s zero‑padded to 10 digits). Then you download their XBRL filings, which are nested XML with namespaces like us-gaap:RevenueFromContractWithCustomerExcludingAssessedTax. Different companies use slightly different tags for the same concept, and the whole process quickly becomes a rabbit hole.

I spent way too long on this, so I wrapped the whole thing in a REST API. Pass a ticker, get JSON back. Done.

Company Info

GET /v1/company/AAPL
{
  "cik": "320193",
  "ticker": "AAPL",
  "name": "Apple Inc.",
  "sic": "3571",
  "sic_description": "Electronic Computers",
  "fiscal_year_end": "0926",
  "state": "CA"
}

No CIK lookup needed—just the ticker.

Financial Statements

GET /v1/financials/AAPL?statement=income_statement&limit=3
{
  "ticker": "AAPL",
  "name": "Apple Inc.",
  "statements": {
    "income_statement": [
      {
        "concept": "revenue",
        "label": "Revenue from Contract with Customer",
        "unit": "USD",
        "data": [
          {
            "fiscal_year": 2025,
            "fiscal_period": "FY",
            "value": 383285000000.0,
            "filed": "2025-10-31",
            "form": "10-K"
          }
        ]
      }
    ]
  }
}

Revenue, net income, EPS, operating expenses — all the stuff that took hours to extract from XBRL, now in one call.

Getting Apple’s Revenue in Python

import requests

url = "https://sec-edgar-data-api.p.rapidapi.com/v1/financials/AAPL"
headers = {
    "x-rapidapi-key": "YOUR_API_KEY",
    "x-rapidapi-host": "sec-edgar-data-api.p.rapidapi.com"
}
params = {"statement": "income_statement", "limit": 5}

response = requests.get(url, headers=headers, params=params)
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}")
FY2025: $383,285,000,000
FY2024: $394,328,000,000
FY2023: $365,817,000,000

That stock screener I mentioned? Finally built it.

Other Endpoints

Search Companies (fuzzy matching)

GET /v1/company?q=tesla

Filing History (10‑K, 10‑Q, 8‑K, etc.)

GET /v1/filings/TSLA?form=10-K&limit=5

Balance Sheet and Cash Flow

GET /v1/financials/MSFT?statement=balance_sheet
GET /v1/financials/MSFT?statement=cash_flow

The API covers all 10,000+ SEC‑registered public companies. Data comes directly from SEC EDGAR (data.sec.gov), so it updates as companies file.

Why Not Just Use an Existing API?

Most alternatives charge $50+/month for basic access or expose dozens of endpoints when you only need a few. I wanted something a junior developer could pick up in five minutes. If the documentation is longer than a README, it’s probably too complicated.

Try It Out

Free tier on RapidAPI — 100 requests/month, no credit card required:

SEC EDGAR Data API on RapidAPI

I also run a bot at @SECEdgarBot that tweets when notable filings drop and flags interesting financial signals. Still early, but it’s been fun to build.

All data sourced from SEC EDGAR (data.sec.gov) — publicly available US government data.

0 views
Back to Blog

Related posts

Read more »

Travigo

Travel as fast as you speak with Gemini! Where live agents meet immersive storytelling & 3D navigation. This project was created for entering the Gemini Live Ag...

Micro games

Hey Gamers! 👾 As part of the Rapid Games Prototyping module, we are tasked with reviewing a peer's game. The challenge is to analyse a prototype built in just...