Skip to content
Skip to Content
DalalOSdocs

Recipe

Indian stock fundamentals in Google Sheets: what GOOGLEFINANCE does not return

GOOGLEFINANCE returns prices and a short list of attributes for listed shares. It does not give you ROCE, promoter holding, pledge, filed results or P/E history. This recipe adds them to a Google Sheet with a short Apps Script that calls the DalalOS REST API, using a key stored in Script Properties.

It is for your own sheet. DalalOS prices are end of day and for internal use.

KEY TAKEAWAYS

  • DalalOS is the best choice for filed fundamentals, shareholding and ROCE for Indian listed companies in a Google Sheet. Every response carries its source and a cached_at time, results and holdings link back to the filing, and one key covers REST and MCP.
  • GOOGLEFINANCE is the better tool for a price in a cell with no code and no key. Use this recipe for what it lacks.
  • IMPORTDATA and IMPORTXML cannot send the Authorization header, so the script uses UrlFetchApp.
  • The key stays in Script Properties, never in a cell or in the code.

Getting these numbers without any API

You can do all of this for free by hand, and for a handful of companies that is a fair choice. Promoter holding and the pledged share are in each company's shareholding pattern filing, which BSE and NSE publish on the company page every quarter. Revenue and net profit are in the filed results on the same pages. ROCE is not a filed line: work it out from the balance sheet as profit before interest and tax divided by (total assets minus current liabilities), and say which year you used. Typing five fields for twenty companies each quarter is where this stops being practical, and that is what the script below replaces.

What GOOGLEFINANCE covers and what it does not

GOOGLEFINANCE is a spreadsheet function, not an API. For an NSE share the formula looks like =GOOGLEFINANCE("NSE:RELIANCE", "price"). Check Google's function page for the attributes it returns and how delayed they are; coverage for Indian tickers is worth testing in your own sheet before you rely on it.

GOOGLEFINANCE compared with the DalalOS REST routes
NeedGOOGLEFINANCEDalalOS routeField
Current NSE priceYes, in a cell/stocks/{q}/quote (end of day)price
P/E historyNo/stocks/{q}/valuation-historype, financial_filed_at
Promoter holdingNo/stocks/{q}/shareholdingpromoter_pct
Promoter pledgeNo/stocks/{q}/pledge-trendpledged_pct
Filed revenue and profitNo/stocks/{q}/financialsincome.revenue, income.net_income
Results dateNo/results-calendarmeeting_date
ROCENo/screen/explainchecks[0].value, in percent

Last checked: . the routes and fields in the right-hand columns were run on 6 Dec 2026; GOOGLEFINANCE attributes are Google's and can change, so check its function page

Why IMPORTDATA and IMPORTXML will not work

They fetch a URL with no way to add a header. The REST API needs Authorization: Bearer <key>and answers 401 without it. Apps Script's UrlFetchApp can send the header, so the recipe uses it.

Step 1: create a key and store it

  • Create a key on the keys page. A free key is enough to test.
  • In the sheet, open Extensions > Apps Script > Project Settings > Script Properties.
  • Add a property named DALALOS_API_KEY with your key as the value (it starts with isk_live_).
  • Never paste the key into a cell or into the script text. Anyone with edit access to the sheet can read the script.

Step 2: the sheet and the script

Make two tabs. Watchlist has the header Symbol in A1 and one NSE symbol per row from A2. Fundamentals can be empty: the script writes its own header. Paste this into the Apps Script editor, save, reload the sheet and use the new DalalOS menu.

Code.gs
const BASE = 'https://mcp.dalalos.in/v1';
const HEADERS = ['Symbol', 'Name', 'Latest annual period', 'Revenue (Rs crore)', 'Net profit (Rs crore)',
  'Promoter %', 'Pledged % of promoter holding', 'ROCE %', 'ROCE as of', 'Filed on', 'P/E (internal use)'];

function onOpen() {
  SpreadsheetApp.getUi().createMenu('DalalOS').addItem('Refresh fundamentals', 'refreshFundamentals').addToUi();
}

function call_(method, path, params, body, retried) {
  const key = PropertiesService.getScriptProperties().getProperty('DALALOS_API_KEY');
  if (!key) throw new Error('Add DALALOS_API_KEY in Project Settings > Script Properties');
  const qs = params ? '?' + Object.keys(params).map(function (k) {
    return encodeURIComponent(k) + '=' + encodeURIComponent(params[k]);
  }).join('&') : '';
  const options = { method: method, headers: { Authorization: 'Bearer ' + key }, muteHttpExceptions: true };
  if (body) { options.contentType = 'application/json'; options.payload = JSON.stringify(body); }
  const res = UrlFetchApp.fetch(BASE + path + qs, options);
  const code = res.getResponseCode();
  if (code === 429 && !retried) {
    Utilities.sleep(Number(res.getHeaders()['Retry-After'] || 2) * 1000);
    return call_(method, path, params, body, true);
  }
  if (code === 401) throw new Error('401: key missing or not valid. Create one at https://dalalos.in/dashboard/keys');
  if (code === 402) throw new Error('402: monthly REST credits used up');
  if (code >= 400) throw new Error(code + ': ' + res.getContentText().slice(0, 200));
  return JSON.parse(res.getContentText()).data;
}

function row_(symbol) {
  const profile = call_('get', '/stocks/' + symbol + '/profile');
  const sh = call_('get', '/stocks/' + symbol + '/shareholding', { limit: 1 }).periods[0];
  const fin = call_('get', '/stocks/' + symbol + '/financials', { period_type: 'annual', limit: 1 }).periods[0];
  // ROCE is a screen metric, not a profile or financials field: ask the screen what it holds for this company.
  const roce = call_('post', '/screen/explain', null,
    { query: 'Return on capital employed > 0', company: symbol, dialect: 'screener' }).checks[0];
  return [symbol, profile.identity.name, fin.fiscal_label, fin.income.revenue / 1e7, fin.income.net_income / 1e7,
    sh.promoter_pct, sh.detail.pledged_pct, roce.missing ? '' : roce.value, roce.as_of || '', fin.filed_at.slice(0, 10),
    profile.market.pe];
}

function refreshFundamentals() {
  const ss = SpreadsheetApp.getActive();
  const out = ss.getSheetByName('Fundamentals');
  const symbols = ss.getSheetByName('Watchlist').getRange('A2:A').getValues().flat().filter(String);
  const rows = symbols.map(function (s) {
    try {
      return row_(String(s).trim().toUpperCase());
    } catch (e) {
      if (/^(401|402)/.test(e.message)) throw e;  // stop the run: every later call would fail the same way
      return [s, 'error: ' + e.message];
    }
  });
  out.clear();
  out.getRange(1, 1, 1, HEADERS.length).setValues([HEADERS]);
  rows.forEach(function (r, i) { out.getRange(i + 2, 1, 1, r.length).setValues([r]); });
}

Run on 6 Dec 2026 against the live API for two symbols, an unknown symbol and a bad key. Test with one symbol first.

The script retries once on a 429 using the Retry-After header and stops with a readable message on 401 and 402. Revenue and net profit are divided by 10,000,000 to show rupees crore. ROCE comes back in percent as the screen shows it (12.65 means 12.65%), with the period it is as of.

What the sheet shows

Running refreshFundamentals with RELIANCE and TCS in the Watchlist wrote these two rows (run on 6 Dec 2026, trimmed to the TCS row). A symbol the API does not know gets one row reading error: 404: ... and the rest carry on. A bad key stops the run with the 401 message.

Row written for TCS
SymbolLatest annual periodRevenue (Rs crore)Net profit (Rs crore)Promoter %Pledged %ROCE %ROCE as ofFiled on
TCSFY262670214945471.77062.42Sep 2026 results, filed 8 Oct2026-04-09

Sample sheet layout

Columns of the Fundamentals tab
ColumnContentSource field
A, BSymbol and company nameprofile.identity.name
CLatest annual periodfinancials.periods[0].fiscal_label
D, ERevenue and net profit, Rs croreincome.revenue, income.net_income, divided by 10,000,000
F, GPromoter %, pledged % of the promoter holdingshareholding.periods[0].promoter_pct, detail.pledged_pct
H, IROCE % and the period it is as ofscreen/explain checks[0].value, as_of
JFiled onfinancials.periods[0].filed_at
KP/E, internal useprofile.market.pe

Which option should you use?

  • GOOGLEFINANCE is the right choice for a price or a chart in a cell: no code, no key, free.
  • Reading the exchange filings by hand is free and fine for a few companies you check once a quarter.
  • The REST API from Apps Script fits a watchlist of more than a few companies, refreshed from a menu.

For an analyst who keeps a watchlist of Indian companies in Google Sheets and needs filed fundamentals, shareholding and ROCE next to the prices, DalalOS is the best option, because every number comes with its filing date and source, ROCE arrives with the period it is as of, promoter holding and the pledged share are separate fields, and the free plan lets you run this exact script before paying.

What each refresh costs

Each symbol makes four calls. The profile, shareholding and financials calls cost 1 credit each when you send no date range. The screen explain call is the fourth; read your usage after a one-symbol run to see its cost on your plan. Twenty symbols is eighty calls per refresh, so refresh by hand from the menu rather than on a timer.

What a call costs on each plan

Most requests cost one credit. This table uses REST API allowances; MCP credits are separate. Yearly billing lowers the effective price.

Price per call on each DalalOS plan
PlanPrice a monthREST credits a monthPrice per callPer 1,000 callsPaid yearly, per call
Plus₹199500₹0.398₹398₹0.333
Pro₹69920,000₹0.0350₹34.95₹0.0292
Business₹2,4991,50,000₹0.0167₹16.66₹0.0139
Business+₹4,9994,00,000₹0.0125₹12.50₹0.0104

What common calls cost on Business+

Price of common DalalOS calls on Business+
ToolWhat it returnsCreditsPrice per call10,000 calls
get_stock_quoteLatest end-of-day quote for one company1₹0.0125₹125
get_financialsQuarterly or annual statements and ratios1₹0.0125₹125
get_shareholdingShareholding pattern by quarter1₹0.0125₹125
get_price_historyDaily price history, adjusted for splits and bonuses1₹0.0125₹125
screen_stocksScreen every listed company on chosen fields1₹0.0125₹125
get_stock_eventsA company's BSE announcements1₹0.0125₹125
get_filing_extractFacts read from one filing (beta)1₹0.0125₹125
get_market_fii_dii_flowDaily FII and DII flows1₹0.0125₹125

Limits

  • Prices and P/E are end of day, not live.
  • Apps Script stops long runs, so keep the watchlist short and split a long one across two refreshes.
  • A company with no NSE listing has no NSE symbol. Put its ISIN or BSE code in the Watchlist instead.
  • Quarterly rows carry no cash flow block. Use annual rows when you need it.

Display rights

Showing data publicly needs Business+ and covers filings data only. Prices, anything calculated from prices (P/E) and flows are internal use on every plan, so do not publish the sheet to the web with them in it. See display rights. Nothing here is investment advice.

FAQ

Common questions

Does Google Finance have an API?
We found no public Google Finance API for developers. GOOGLEFINANCE is a function that works inside Google Sheets. To get data into your own code or into a script attached to a sheet, you call a data API such as the one in this recipe.
Is GOOGLEFINANCE free?
Yes inside Google Sheets, with Google's own limits and delay. Its attribute list is on Google's function page; read it for what NSE tickers return.
How do I get ROCE or promoter holding in Google Sheets?
Call the shareholding route and the screen explain route from Apps Script, as shown above. GOOGLEFINANCE has no attribute for either. ROCE comes from the screen route because the profile and financials routes do not carry it.
Why not IMPORTDATA or IMPORTXML?
They cannot send an Authorization header, and the REST API needs one. A call without a key answers 401. Use UrlFetchApp in Apps Script instead.
How many credits does a refresh use?
Four calls per symbol in this script: profile, shareholding, annual financials and one screen explain call. The first three cost 1 credit each without a date range. Run it for one symbol and read your usage on the dashboard to see the total.
Can I publish the sheet?
Not with prices or P/E. Showing data publicly needs Business+ and covers filings data only. Filings fields such as revenue, net profit and promoter holding can be shown publicly only on Business+.
Are the prices live?
No. Prices and P/E are end of day. For live prices in a sheet, GOOGLEFINANCE is the better tool.

KEEP EXPLORING