Skip to main content
Financial statements are the foundation of fundamental analysis. This guide shows you how to fetch income statements, balance sheets, and cash flow statements for any US public company using Python.

Prerequisites

  • Python 3.7+
  • A Financial Datasets API key (sign up here)
  • The requests library (pip install requests)

Step 1: Set Up Authentication

import requests

headers = {
    "X-API-KEY": "your_api_key_here"
}

Step 2: Fetch Income Statements

Use the Income Statements API to get revenue, expenses, and net income data.
ticker = "NVDA"
period = "annual"  # options: annual, quarterly, ttm
limit = 5          # number of periods to return

url = (
    f"https://api.financialdatasets.ai/financials/income-statements"
    f"?ticker={ticker}"
    f"&period={period}"
    f"&limit={limit}"
)

response = requests.get(url, headers=headers)
income_statements = response.json().get("income_statements")

for stmt in income_statements:
    print(f"{stmt['report_period']}: Revenue=${stmt['revenue']:,}, Net Income=${stmt['net_income']:,}")

Step 3: Fetch Balance Sheets

Use the Balance Sheets API to get assets, liabilities, and equity data.
url = (
    f"https://api.financialdatasets.ai/financials/balance-sheets"
    f"?ticker={ticker}"
    f"&period={period}"
    f"&limit={limit}"
)

response = requests.get(url, headers=headers)
balance_sheets = response.json().get("balance_sheets")

for stmt in balance_sheets:
    print(f"{stmt['report_period']}: Assets=${stmt['total_assets']:,}, Equity=${stmt['total_equity']:,}")

Step 4: Fetch Cash Flow Statements

Use the Cash Flow Statements API to get operating, investing, and financing cash flows.
url = (
    f"https://api.financialdatasets.ai/financials/cash-flow-statements"
    f"?ticker={ticker}"
    f"&period={period}"
    f"&limit={limit}"
)

response = requests.get(url, headers=headers)
cash_flow_statements = response.json().get("cash_flow_statements")

for stmt in cash_flow_statements:
    print(f"{stmt['report_period']}: Operating CF=${stmt['operating_cash_flow']:,}")

Step 5: Get All Statements in One Call

Use the All Financial Statements API to fetch all three statement types in a single request.
url = (
    f"https://api.financialdatasets.ai/financials"
    f"?ticker={ticker}"
    f"&period={period}"
    f"&limit={limit}"
)

response = requests.get(url, headers=headers)
data = response.json()

income_statements = data.get("income_statements")
balance_sheets = data.get("balance_sheets")
cash_flow_statements = data.get("cash_flow_statements")

Filtering by Date Range

Use report_period parameters to get statements within a specific date range:
url = (
    f"https://api.financialdatasets.ai/financials/income-statements"
    f"?ticker=NVDA"
    f"&period=quarterly"
    f"&limit=100"
    f"&report_period_gte=2023-01-01"
    f"&report_period_lte=2024-12-31"
)
Available date filters: report_period, report_period_lt, report_period_lte, report_period_gt, report_period_gte.

Available Tickers

Fetch the list of tickers with financial statement coverage:
GET https://api.financialdatasets.ai/financials/income-statements/tickers/
Coverage includes 17,000+ US tickers with 30+ years of history.

Next Steps