How to Calculate Free Cash Flow from the Financials API (Annual Data)
Annual rows from GET /v1/stocks/{ticker}/financials?period_type=annual carry cash_flow_operating and capex (purchase of property, plant, equipment and intangibles). Free cash flow is cash_flow_operating - capex.
import httpx
API = "https://bharatstockapi.com"
HEADERS = {"X-API-Key": "bsk_live_..."} # your key from the dashboard
r = httpx.get(f"{API}/v1/stocks/RELIANCE/financials", headers=HEADERS,
params={"period_type": "annual", "page_size": 10})
r.raise_for_status()
for row in r.json()["data"]:
cfo, capex = row.get("cash_flow_operating"), row.get("capex")
fcf = cfo - capex if cfo is not None and capex is not None else None
print(row["fiscal_year"], row["consolidation_type"], fcf)Handle missing values
- A field is
nullwhen the filing did not report it. Check forNonebefore subtracting, as above. - Rows carry
consolidation_type. Do not subtract or compare across consolidated and standalone rows. See consolidated vs standalone. - Rows are most recent period first.
Concept: what free cash flow is.