Get Mutual Fund NAV History and Returns via API (AMFI Data, Python)
Mutual funds are keyed by the AMFI scheme_code. Each code is one (scheme, plan, option) variant with its own NAV, so Direct and Regular, Growth and IDCW have different codes. NAVs come from AMFI's daily feed, with history back to 2006 for schemes that existed then.
1. Find the scheme code
import httpx
API = "https://bharatstockapi.com"
HEADERS = {"X-API-Key": "bsk_live_..."} # your key from the dashboard
r = httpx.get(f"{API}/v1/mf/schemes", headers=HEADERS,
params={"q": "flexi cap", "plan": "Direct", "option": "Growth",
"limit": 5})
r.raise_for_status()
for s in r.json()["data"]:
print(s["scheme_code"], s["scheme_name"])2. NAV history and trailing returns
code = "120503" # from step 1
nav = httpx.get(f"{API}/v1/mf/schemes/{code}/nav", headers=HEADERS,
params={"from": "2024-01-01", "to": "2024-12-31"}).json()
print(nav["count"], nav["data"][0])
ret = httpx.get(f"{API}/v1/mf/schemes/{code}/returns", headers=HEADERS).json()
print(ret["returns_pct"]) # 1m, 3m, 6m, 1y, 3y, 5y, since_inceptionThings to know
- NAV defaults to the last year,
limitup to 5000 points. - Returns under a year are point-to-point. One year and longer are annualized (CAGR).
- A horizon without enough history is
null. - Free keys get a recent NAV window. Paid plans get the full archive.
To see which funds hold a given stock instead, read find mutual funds holding a stock. Concept: what NAV is.