Mutual fund NAV in Google Sheets
Add one small function and type =FUNDNAV(122639) in any cell to get that scheme's latest NAV. Spreadsheets cannot send an API key in a header on their own, so this uses Google Apps Script.
Faster way: the Sheets Lab in the Explorer builds all of this for you. Add your funds there, copy one script, and it adds the formulas, an EJI API menu for your key, and a ready portfolio sheet with XIRR. The steps below are the manual version.
You need an API key: request a free beta key. Keep it in an environment variable, never in code you publish.
Steps
- Open your sheet, then Extensions → Apps Script.
- In the Apps Script editor open Project Settings (gear icon), find Script properties, and add a property named
EJI_KEYwith your key as the value. This keeps the key out of the sheet itself, so people you share the sheet with cannot read it from a cell. - Go back to the code editor, delete what is there, paste the function below and save.
function FUNDNAV(code) {
const key = PropertiesService.getScriptProperties().getProperty("EJI_KEY");
const res = UrlFetchApp.fetch("https://fin.ejiapi.com/api/mf/scheme-code/" + code, {
headers: { "x-api-key": key }
});
return JSON.parse(res.getContentText()).data.latestNav;
}
// In a cell: =FUNDNAV(122639)- In a cell type
=FUNDNAV(122639). The first time, Google asks you to authorise the script to connect to an external service. Allow it.
Good to know
- It does not refresh by itself. Sheets caches custom function results and recalculates only when the inputs change. For a daily refresh, add a time-driven trigger (Apps Script, the clock icon) that rewrites the values.
- Quotas. Each cell that uses the function is one API request against your monthly quota, and Google also limits script fetches per day. Put the scheme codes in a column and keep the list short.
- Find scheme codes with the explorer, or
/api/mf/search. - We ran this in a real Google Sheet and
=FUNDNAV(122639)returned the scheme's latest NAV. - If you see
Exception: Attribute provided with invalid value: Header:null, the script could not find your key. Check that the script property is named exactlyEJI_KEY(capital letters, underscore, no spaces) and that you clicked Save script properties. Then re-enter the formula, because Sheets keeps the old error in the cell until it recalculates.
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.