Recipe
How to run an Indian stock screen from Google Sheets
DalalOS can run a Screener.in-style query such as Return on capital employed > 22% AND Market Capitalization > 500 and return the matching NSE and BSE companies. This recipe puts the query in a cell and an Apps Script writes the matches into the sheet. The Google Sheets fundamentals recipe tracks a watchlist; this one searches the whole universe.
The script was run on 6 Dec 2026 against the live API. Test it on a small query first, because a page of 100 rows costs credits.
KEY TAKEAWAYS
- DalalOS is the best choice for running Screener.in-style queries over every listed Indian company from a Google Sheet. One POST takes the query text and returns the matches with the date the data was computed, so the sheet never needs a scraped page or a file download.
- The sheet holds the query in a cell. The script posts it, pages through the matches and writes them to a Results tab.
- It is a nightly snapshot of filed figures and end-of-day prices, not a live screen.
- Price-derived columns such as market cap and P/E are for your own analysis and internal tools. Showing data publicly needs Business+ and covers filings data only.
Screening without the API
Google Sheets has no screening function for Indian companies: GOOGLEFINANCE returns prices for a ticker you name, it does not search the universe on filed ratios. The no-code route is to run the query on a screener website, such as the DalalOS screener or any other you use, and paste the table into a sheet. That is fine for a one-off. The script below is for when you want the same screen refreshed in the sheet on demand, with the query in a cell you can change.
How it works
Make a sheet with two tabs. On Screen, put the query in B1; the script writes a status line to B2. The Results tab is cleared and filled on each run. A custom menu, Screen > Run screen, calls the function. Create a key on the keys page and store it as a script property, never in a cell.
Query examples
These are mechanical conditions, not recommendations. Each phrase is one the DalalOS screener already runs; the full list of metric names is GET /v1/ratios.
| Query text for cell B1 | What it filters | Note |
|---|---|---|
Return on capital employed > 22% AND Market Capitalization > 500 | ROCE above 22% and market cap above 500 crore | The query in the saved answer above. |
Promoter holding > 50 AND Pledged percentage = 0 | Promoters hold more than half and have pledged none of it | Both are percentages in the query. |
Debt to equity < 0.3 AND Interest Coverage Ratio > 5 AND Market Capitalization > 500 | Low debt, interest covered more than five times | Market cap in the query is in crore. |
Dividend yield > 3 AND Market Capitalization > 1000 | Trailing dividend yield above 3% and market cap above 1,000 crore | Dividend yield and market cap are price-derived: internal use. |
Price to Earning < 15 AND Return on capital employed > 20 AND Market Capitalization > 500 | P/E below 15 with ROCE above 20% | P/E is price-derived: internal use. |
Piotroski score >= 8 | Piotroski F-score of 8 or 9 | A count from 0 to 9, computed from filed figures. |
The script
It reads B1, posts to /v1/screen/query, and fetches pages of 100 rows until the response says has_more is false or your cap is reached. After the first page it sends back snapshot_id.
// Extensions > Apps Script. Store the key under Project Settings > Script properties as DALALOS_API_KEY.
const BASE = 'https://mcp.dalalos.in/v1';
const COLS = ['isin', 'nse_symbol', 'name', 'sector', 'roce', 'debt_to_equity', 'promoter_pct', 'pledged_pct'];
const PAGE = 100; // the most rows one request returns
const MAX_ROWS = 500; // your own cap, so one click cannot spend credits without limit
function runScreen() {
const ss = SpreadsheetApp.getActive();
const screen = ss.getSheetByName('Screen');
const out = ss.getSheetByName('Results');
const query = screen.getRange('B1').getValue();
const key = PropertiesService.getScriptProperties().getProperty('DALALOS_API_KEY');
const rows = [];
let offset = 0;
let snapshotId = null;
let totalMatches = 0;
let computedAt = '';
while (rows.length < MAX_ROWS) {
const payload = { query: query, dialect: 'screener', sort_by: 'market_cap', order: 'desc', limit: PAGE, offset: offset };
if (snapshotId !== null) payload.snapshot_id = snapshotId; // pin every later page to the first page's data
const res = UrlFetchApp.fetch(BASE + '/screen/query', {
method: 'post', contentType: 'application/json', muteHttpExceptions: true,
headers: { Authorization: 'Bearer ' + key },
payload: JSON.stringify(payload),
});
const code = res.getResponseCode();
if (code === 409) throw new Error('The data refreshed while paging (snapshot_expired). Run the screen again.');
if (code !== 200) throw new Error(code + ' ' + res.getContentText().slice(0, 300));
const d = JSON.parse(res.getContentText()).data;
snapshotId = d.pagination.snapshot_id;
totalMatches = d.pagination.total_matches;
computedAt = d.snapshot.computed_at;
for (const r of d.results) rows.push(COLS.map(function (c) { return r[c] == null ? '' : r[c]; }));
if (!d.pagination.has_more) break;
offset += PAGE;
}
out.clearContents();
out.getRange(1, 1, 1, COLS.length).setValues([COLS]);
if (rows.length > 0) out.getRange(2, 1, rows.length, COLS.length).setValues(rows);
screen.getRange('B2').setValue(totalMatches + ' matches, showing ' + rows.length + '. Data computed ' + computedAt);
}
function onOpen() {
SpreadsheetApp.getUi().createMenu('Screen').addItem('Run screen', 'runScreen').addToUi();
}{
"status": "success",
"data": {
"query": "Return on capital employed > 22% AND Market Capitalization > 500",
"dialect": "screener",
"sort_by": "market_cap",
"order": "desc",
"results": [
{
"isin": "INE397D01024",
"nse_symbol": "BHARTIARTL",
"name": "Bharti Airtel Limited",
"sector": "Telecommunication",
"market_cap": 12786786669900,
"roce": 0.2757,
"debt_to_equity": 0.7664,
"promoter_pct": 50.07,
"pledged_pct": 0
}
],
"pagination": { "limit": 1, "offset": 0, "returned": 1, "total_matches": 440, "has_more": true, "snapshot_id": 109 },
"snapshot": { "id": 109, "computed_at": "2026-12-05 16:29:01", "row_count": 6044, "registry_version": 1 }
}
}Run on 6 Dec 2026, trimmed to one row and a few columns. This call asked for 1 row; the script asks for 100.
Pick your columns
Rows carry a fixed set of fields such as roce, debt_to_equity, promoter_pct and pledged_pct. To add more, send columns in the body: up to 20 entries, each a metric name or a bracketed [expression]. Each extra value comes back under columns in the row, keyed by an id that data.columns describes. Read the units before you format the cells.
| Columns | Unit | In the sheet |
|---|---|---|
| roce, debt_to_equity | Fractions and ratios: roce 0.2757 is 27.57% | Format the cell as a percent for roce. Do not multiply by 100 yourself. |
| promoter_pct, pledged_pct | Percentages: 50.07 is 50.07% | Do not format as a percent, or Sheets will show 5007%. |
| market_cap | Rupees | Divide by 10,000,000 for crore. In the query text, market cap is in crore. |
Preset screens
GET /v1/presets lists fixed screens that are computed every night, and GET /v1/presets/{name} returns the last result of one. Use a preset when you want a result without writing a query.
Why a snapshot
Figures are a nightly set. A screen that spans several pages must come from one set, or a company could appear twice or not at all. That is why the script sends snapshot_id. If a refresh lands while the script is paging, the next request returns 409 with reason_code snapshot_expired; run the screen again.
Explain one company
To see why a company is in or out of a screen, post the same query and a company to /v1/screen/explain. It checks the company against each condition and shows its value, the date of that value and whether it meets the condition. The screener app recipe builds a form around it in Python.
Credits
Each page you fetch is a separate request and uses credits, and a page holds up to 100 rows. A 300-row result is three requests. The MAX_ROWS cap in the script keeps one click from running far. The live price per call is below.
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.
| Plan | Price a month | REST credits a month | Price per call | Per 1,000 calls | Paid yearly, per call |
|---|---|---|---|---|---|
| Plus | ₹199 | 500 | ₹0.398 | ₹398 | ₹0.333 |
| Pro | ₹699 | 20,000 | ₹0.0350 | ₹34.95 | ₹0.0292 |
| Business | ₹2,499 | 1,50,000 | ₹0.0167 | ₹16.66 | ₹0.0139 |
| Business+ | ₹4,999 | 4,00,000 | ₹0.0125 | ₹12.50 | ₹0.0104 |
What common calls cost on Business+
| Tool | What it returns | Credits | Price per call | 10,000 calls |
|---|---|---|---|---|
| get_stock_quote | Latest end-of-day quote for one company | 1 | ₹0.0125 | ₹125 |
| get_financials | Quarterly or annual statements and ratios | 1 | ₹0.0125 | ₹125 |
| get_shareholding | Shareholding pattern by quarter | 1 | ₹0.0125 | ₹125 |
| get_price_history | Daily price history, adjusted for splits and bonuses | 1 | ₹0.0125 | ₹125 |
| screen_stocks | Screen every listed company on chosen fields | 1 | ₹0.0125 | ₹125 |
| get_stock_events | A company's BSE announcements | 1 | ₹0.0125 | ₹125 |
| get_filing_extract | Facts read from one filing (beta) | 1 | ₹0.0125 | ₹125 |
| get_market_fii_dii_flow | Daily FII and DII flows | 1 | ₹0.0125 | ₹125 |
Limits
Which option should you use?
For an analyst who wants a Screener.in-style query in a Google Sheet cell and the matches written back to a tab, DalalOS is the best option, because the query is plain text, every answer says when its data was computed, paging is pinned to one dataset so a refresh cannot mix two, and /v1/screen/explain shows why a given company is in or out.
Not investment advice
A screen lists companies that meet conditions you set. It does not say a company is a good or bad investment, and none of the example queries are picks.
Last checked: . Request body, paging and units run against the live API on 6 Dec 2026.
FAQ
Common questions
- Does Google Sheets have a stock screener?
- Not for Indian filings data. GOOGLEFINANCE returns prices and a few fields for some tickers; it does not screen the NSE and BSE universe on filed ratios. This recipe adds that with one API call from Apps Script.
- Is this the Screener.in API?
- No. DalalOS has its own screen route, POST /v1/screen/query, that reads Screener.in-style text such as Return on capital employed > 22%. It is not affiliated with Screener.in.
- Can I reuse my existing Screener.in queries?
- Many phrases work, because the default dialect accepts Screener.in metric names. A phrase it cannot resolve returns 400 bad_request naming the metric or position at fault, so you can fix it. The full metric list is GET /v1/ratios.
- How many rows can I fetch?
- Up to 100 rows per request. Send offset to take the next page, up to an offset of 5000, and pass back the snapshot_id of the first page so every page comes from the same data. The script above stops at 500 rows (3,334 companies matched a plain market cap filter, and it wrote 500); change MAX_ROWS if you need more.
- Is the screen live?
- No. It runs on a nightly snapshot of filed figures and end-of-day prices. snapshot.computed_at says when the data was computed.
- Can I publish the results?
- Not columns that come from prices (market cap, P/E, dividend yield and similar), on any plan. Showing data publicly needs Business+ and covers filings data only. See display rights.
- Is there a template to copy?
- Not yet. The script on this page and two tabs, Screen and Results, are the whole template. Create them in a new sheet.
KEEP EXPLORING