Home / Tutorials / Financial data
Financial data

Convert XBRL financial statements to JSON

Turn the XBRL in any 10-K or 10-Q into JSON statements: income statement, balance sheet, cash flow and cover page, with periods and units.

Every 10-K and 10-Q carries its financial statements as XBRL, a tagged XML format. /v1/xbrl-to-json reads the filing's XBRL and returns each statement as JSON, grouped the way the company presents them.

Convert Apple's fiscal 2025 10-K

import os
import requests

BASE = "https://secfeedapi.com"
HEADERS = {"Authorization": f"Bearer {os.environ['SECFEED_KEY']}"}

r = requests.get(f"{BASE}/v1/xbrl-to-json", params={"accessionNo": "0000320193-25-000079", "cik": 320193},
                 headers=HEADERS, timeout=120)
r.raise_for_status()
x = r.json()
print("sections:", list(x.keys()))

def current(facts):
    """The value for the full fiscal year (or year-end instant), ignoring segment breakdowns."""
    for f in facts:
        if "segment" not in f:
            return f
    return facts[0]

inc = x["StatementsOfIncome"]
for tag in ["RevenueFromContractWithCustomerExcludingAssessedTax", "GrossProfit", "OperatingIncomeLoss", "NetIncomeLoss", "EarningsPerShareDiluted"]:
    f = current(inc[tag])
    print(f"{tag:55} {f['value']:>15} {f['period'].get('endDate')}")
bs = x["BalanceSheets"]
for tag in ["CashAndCashEquivalentsAtCarryingValue", "AssetsCurrent", "Assets", "StockholdersEquity"]:
    if tag in bs:
        f = current(bs[tag])
        print(f"{tag:55} {f['value']:>15} {f['period'].get('instant')}")
print("auditor:", x["AuditorInformation"]["AuditorName"][0]["value"])

Output:

sections: ['CoverPage', 'AuditorInformation', 'StatementsOfIncome', 'StatementsOfComprehensiveIncome', 'BalanceSheets', 'ConsolidatedBalanceSheets', 'StatementsOfShareholdersEquity', 'StatementsOfCashFlows', '_meta']
RevenueFromContractWithCustomerExcludingAssessedTax        416161000000 2025-09-27
GrossProfit                                                195201000000 2025-09-27
OperatingIncomeLoss                                        133050000000 2025-09-27
NetIncomeLoss                                              112010000000 2025-09-27
EarningsPerShareDiluted                                            7.46 2025-09-27
CashAndCashEquivalentsAtCarryingValue                       35934000000 2025-09-27
AssetsCurrent                                              147957000000 2025-09-27
Assets                                                     359241000000 2025-09-27
StockholdersEquity                                          73733000000 2025-09-27
auditor: Ernst & Young LLP

How the JSON is organized

  • Top level keys are the statements the company filed: StatementsOfIncome, BalanceSheets, StatementsOfCashFlows, StatementsOfShareholdersEquity, plus CoverPage and AuditorInformation.
  • Inside each statement, keys are XBRL concept names such as NetIncomeLoss or Assets. Company specific concepts carry the company prefix, for example aapl_....
  • Each concept is a list of facts. A fact has value, period (startDate and endDate for durations, instant for balance sheet dates), unitRef and decimals.
  • Facts broken down by a dimension, such as revenue by product line, have a segment with the axis and member. The helper above skips those to get the consolidated number.

Values are strings exactly as filed. decimals: "-6" means the filer rounded to millions; the value itself is in full units.

Use the period to pick a column

A 10-K income statement has three fiscal years, so RevenueFromContractWithCustomerExcludingAssessedTax holds many facts. Filter on period.endDate to pick a year, and on the absence of segment for the total.

Quicker: latest statements by ticker

If you only need the latest totals, /v1/financial-statements?ticker=NVDA&formType=10-K finds the latest filing for you and returns the income statement, balance sheet and cash flow.

Next steps

More financial data tutorials

Run this tutorial with your own key

500 free API calls a month. Every example on this page works on the free plan.

Get free API key →