Resolve a ticker to its SEC identity, pull annual income statements, and print revenue with the exact filing that backs the number — no hallucinated figures. Every EDGAR-sourced row carries citation fields so your agent can quote a figure and prove where it came from.
Step 1 - Load your API key
import os
import requests
BASE = "https://api.financialdataapis.com/v1"
KEY = os.environ["FDA_KEY"]
HEADERS = {"X-API-Key": KEY}Step 2 - Resolve the company
Call the profile endpoint to confirm the ticker and capture the canonical CIK:
profile = requests.get(
f"{BASE}/company/AAPL/profile",
headers=HEADERS,
timeout=30,
)
profile.raise_for_status()
company = profile.json()
print(f"{company['name']} (CIK {company['cik']}, {company['exchange']})")
print(f"data_source: {company['data_source']}")Step 3 - Fetch annual income statements
financials = requests.get(
f"{BASE}/company/AAPL/financials",
params={"statement": "income", "period": "annual"},
headers=HEADERS,
timeout=30,
)
financials.raise_for_status()
data = financials.json()
print(f"data_source: {data['data_source']}")Step 4 - Print revenue with its citation
for row in data["items"][:3]:
citation = (
f"{row['form']} filed {row['filing_date']} "
f"(FY{row['fiscal_year']}, period {row['period']}, "
f"as reported: {row['filed_as_reported']})"
)
print(f"Revenue: ${row['revenue']:,.0f} — {citation}")Expected output:
Revenue: $383,285,000,000 — 10-K filed 2025-10-31 (FY2025, period 2025-09-30, as reported: True)Handle the 202 cache-miss case
A freshly resolved company may not be ingested yet. The financials endpoint enqueues ingestion and
returns 202 with a Retry-After header — retry rather than failing:
import time
if financials.status_code == 202:
retry_after = int(financials.headers.get("Retry-After", "10"))
print(f"Queued ingestion, retrying in {retry_after}s...")
time.sleep(retry_after)
financials = requests.get(
f"{BASE}/company/AAPL/financials",
params={"statement": "income", "period": "annual"},
headers=HEADERS,
timeout=30,
)
financials.raise_for_status()
data = financials.json()Next steps
- See the full Financial Statements reference for the curated and raw XBRL shapes.
- Browse the rest of the Fundamentals reference — filings, holdings, metrics, estimates, and news.