Get Indian mutual fund NAV in JavaScript
Search a scheme, read its latest NAV and pull a date range of history, using only Node.js 18+ (built-in fetch, no packages).
You need an API key: request a free beta key. Keep it in an environment variable, never in code you publish.
export EJI_KEY=your-key-here node nav.mjs
The script
Save it as nav.mjs (the .mjs extension allows top-level await). Every success response wraps the result in data; failures come back with a non-200 status and a message, which the helper turns into an exception.
// Node 18+ (built-in fetch). Run: EJI_KEY=your-key node nav.mjs
const BASE = process.env.EJI_BASE ?? "https://fin.ejiapi.com";
const headers = { "x-api-key": process.env.EJI_KEY ?? "YOUR_KEY" };
async function get(path) {
const res = await fetch(BASE + path, { headers });
const body = await res.json();
if (!res.ok) throw new Error(`${res.status} ${body.detail ?? body.message}`);
return body.data; // every success response wraps the result in `data`
}
// 1. Search by name, then use the scheme code
const found = await get("/api/mf/search?query=parag%20parikh%20flexi&limit=3");
console.log(found.map((s) => `${s.schemeCode} ${s.schemeName} (${s.planName}, ${s.optionName})`));
// 2. Latest NAV
const fund = await get("/api/mf/scheme-code/122639");
console.log(fund.schemeName, fund.latestNav, fund.latestNavDate);
// 3. NAV history for a date range
const hist = await get("/api/mf/nav-history/scheme-code/122639?start=2026-10-01&end=2026-10-10");
for (const { date, nav } of hist) console.log(date, nav);
// 4. Errors: an unknown code throws with the API's message
try {
await get("/api/mf/scheme-code/0");
} catch (e) {
console.log("error:", e.message);
}Output
[ '122639 Parag Parikh Flexi Cap Fund (Direct Plan, Growth)', '153964 Parag Parikh Flexi Cap Fund (Direct Plan, Monthly IDCW Payout)', '122640 Parag Parikh Flexi Cap Fund (Regular Plan, Growth)' ] Parag Parikh Flexi Cap Fund 93.9483 2026-11-06 2026-10-01 88.2569 2026-10-05 88.762 2026-10-06 88.997 2026-10-07 88.8389 2026-10-08 87.6555 2026-10-09 88.9258 error: 404 Scheme not found
Notes
- Search returns every plan and option of a fund (Direct, Regular, Growth, IDCW). Pick the code of the variant you want; Direct Growth is
122639here. - Do not call the API from browser code: your key would be visible to every visitor. Call it from a server, a serverless function or a script. See authentication.
- Python version of the same flow: NAV in Python.
Data comes from public disclosures and is for information, not investment advice. Sample outputs were produced on 2026-11-08 and change as new data is published.