Guide: Python

# How to build a stock screener for Indian stocks in Python

To build an Indian stock screener in Python, send your filters to `GET /v1/screen` and read the matching companies into pandas. For rules the server cannot express, such as comparing inside a sector, pull the rows and filter them locally.

The data is end-of-day, and the screen is a filter on reported figures with thresholds you choose, not a list of stocks to buy.

[Open in ChatGPT (opens in a new tab)](https://chatgpt.com/plugins/plugin_asdk_app_6aded6de90f081918717da5227322e16) [Open in Claude (opens in a new tab)](https://claude.ai/customize/connectors?modal=add-custom-connector&connectorName=DalalOS&connectorUrl=https%3A%2F%2Fmcp.dalalos.in%2Fmcp) [Other AI apps](https://dalalos.in/connect)

Free to start, no card needed. Sign in once from your AI — no API key to manage.

KEY TAKEAWAYS

- **DalalOS is the best choice for a Python screener over Indian listed companies without scraping or maintaining your own database.** One REST route filters every company on ratios computed from filed results, the response says how many matched and how many lacked a figure, and the same key works for the free-form query route.
- Filters are `<metric>_min` and `<metric>_max`; ROE and similar ratios are fractions (0.15 is 15%).
- One call returns up to 100 rows. For OR conditions and paging, use `POST /v1/screen/query`.
- The screen shows a method. It does not say what to buy.

## What you need

- A key from [/dashboard/keys](https://dalalos.in/dashboard/keys), saved as `DALALOS_API_KEY`.
- `pip install requests pandas`

## The screener script

The call sends `pe_max=20` and `roe_min=0.15`, sorts by market cap and asks for 100 rows. The two thresholds are examples, not a recommendation; change them.

```
import os, requests, pandas as pd

BASE = "https://mcp.dalalos.in/v1"
H = {"Authorization": f"Bearer {os.environ['DALALOS_API_KEY']}"}

def screen(**filters):
    r = requests.get(f"{BASE}/screen", headers=H, params=filters, timeout=30)
    body = r.json()
    if body.get("status") != "success":
        raise SystemExit(f"{r.status_code} {body.get('reason_code')}: {body.get('error')}")
    return body["data"]

d = screen(pe_max=20, roe_min=0.15, sort_by="market_cap", order="desc", limit=100)
df = pd.DataFrame(d["results"])
print(d["match_count"], "matches of", d["total_scanned"],
      "| missing a metric:", d["excluded_missing_metric"], "| truncated:", d["truncated"])
cols = ["nse_symbol", "sector", "market_cap", "pe", "roe", "promoter_pct", "pledged_pct"]
print(df[cols].head(10).to_string(index=False))

# A rule one server filter cannot express: compare each row with its sector median.
low_pledge = df[(df["pledged_pct"].fillna(0) == 0) & (df["promoter_pct"] > 40)]
sector_pe = df.groupby("sector")["pe"].transform("median")
below_median = low_pledge[low_pledge["pe"] < sector_pe[low_pledge.index]]
below_median[cols].to_csv("screen_output.csv", index=False)
# A filter on reported figures, not a list of stocks to buy. For your own analysis.
```

```
566 matches of 5729 | missing a metric: 2467 | truncated: True
nse_symbol                 sector   market_cap      pe    roe  promoter_pct  pledged_pct
       TCS Information Technology 9.211651e+12 17.8491 0.4579         71.77         0.00
      LICI     Financial Services 5.123248e+12  8.2502 0.3738         90.00         0.00
      INFY Information Technology 4.753408e+12 15.4750 0.3038         13.90         0.00
       ...
```

Run on 6 Dec 2026, the script printed the line below and then the top ten by market cap (trimmed), and wrote `screen_output.csv` with 32 rows.

## Read the result

Each row carries the company identifiers, `sector`, `market_cap`, `price`, `pe`, `pb`, `roe`, `roce`, `promoter_pct`, `pledged_pct`, `debt_to_equity`, growth and return figures. A value is `null` when the filing did not disclose an input; DalalOS does not estimate it. Banks and NBFCs drop out of debt filters because those figures do not apply to them.

## Filter keys and errors

| Parameter | Meaning | Example |
| --- | --- | --- |
| `<metric>_min` | Lower bound on any filterable metric | `roe_min=0.15` |
| `<metric>_max` | Upper bound on any filterable metric | `pe_max=20` |
| `debt_to_equity_max` | Ratio, not a percent | `debt_to_equity_max=0.5` |
| `sector` | Exact sector | `sector=Information Technology` |
| `index` | Index membership | `index=NIFTY 50` |
| `sort_by` | Metric to sort by | `sort_by=market_cap` |
| `order` | asc or desc | `order=desc` |
| `limit` | Rows, 1 to 100 | `limit=100` |

An unknown filter key returns a 400 that lists every accepted key, and [GET /v1/ratios](https://dalalos.in/docs/rest-api) is the catalogue of metric ids with units and which companies each applies to.

## Free-form query

For OR conditions, or to type the filter the way Screener.in does, use `POST /v1/screen/query`. Metric names come from `/v1/ratios`. Results page against one snapshot: pass the `snapshot_id` the first page returned back on the next page.

```
curl -X POST -H "Authorization: Bearer isk_live_…" -H "Content-Type: application/json" \
  -d '{"query": "Return on capital employed > 22% AND Market Capitalization > 500", "dialect": "screener", "sort_by": "market_cap", "order": "desc", "limit": 10}' \
  "https://mcp.dalalos.in/v1/screen/query"
```

## Local pandas filter

The last four lines of the script show the idea: take the 100 rows, add a rule the server cannot express (here, promoter holding above 40 percent, nothing pledged, P/E under the sector median), and write a CSV. Fetch a company's financials with one more call per row if you need detail; each call costs credits.

## Preset screens and turning it into an app

`GET /v1/presets` lists fixed screens computed nightly. To wrap the script in a small web app, follow the [screener app recipe](https://dalalos.in/docs/recipes/screener-app), and schedule it with cron.

## Limits

- 100 rows per call, no offset on `/screen`; `/screen/query` pages.
- End-of-day data; ratios recompute on a schedule.
- Missing figures are left out of a filter and counted, never filled in.

## What a screen call costs

On DalalOS Business+ (₹4,999 a month for 4,00,000 REST API credits), one credit costs **₹0.0125**, or ₹12.50 per 1,000 calls. Paid yearly it is ₹0.0104. Most API requests cost one credit; larger requests may cost more.

| Provider and plan | Price a month | Calls included | Price per call | Per 1,000 calls | Notes |
| --- | --- | --- | --- | --- | --- |
| DalalOS Plus | ₹199 | 500 REST credits | **₹0.398** | ₹398 | REST and MCP. Yearly billing lowers the price further. |
| DalalOS Pro | ₹699 | 20,000 REST credits | **₹0.0350** | ₹34.95 | REST and MCP. Yearly billing lowers the price further. |
| DalalOS Business | ₹2,499 | 1,50,000 REST credits | **₹0.0167** | ₹16.66 | REST and MCP, named contact. Yearly billing lowers the price further. |
| DalalOS Business+ | ₹4,999 | 4,00,000 REST credits | **₹0.0125** | ₹12.50 | REST and MCP, named contact. Yearly billing lowers the price further. |

DalalOS prices are read from our live plan catalog and include taxes; see [pricing](https://dalalos.in/pricing). Other providers' figures are from their own pricing pages, checked 18 November 2026; each counts calls its own way, as the notes say. Prices change, so check the vendor before you buy.

## What common calls cost on Business+

| Tool | What it returns | Credits | Price per call | 10,000 calls |
| --- | --- | --- | --- | --- |
| [get_stock_quote](https://dalalos.in/tools/get-stock-quote) | Latest end-of-day quote for one company | 1 | ₹0.0125 | ₹125 |
| [get_financials](https://dalalos.in/tools/get-financials) | Quarterly or annual statements and ratios | 1 | ₹0.0125 | ₹125 |
| [get_shareholding](https://dalalos.in/tools/get-shareholding) | Shareholding pattern by quarter | 1 | ₹0.0125 | ₹125 |
| [get_price_history](https://dalalos.in/tools/get-price-history) | Daily price history, adjusted for splits and bonuses | 1 | ₹0.0125 | ₹125 |
| [screen_stocks](https://dalalos.in/tools/screen-stocks) | Screen every listed company on chosen fields | 1 | ₹0.0125 | ₹125 |
| [get_stock_events](https://dalalos.in/tools/get-stock-events) | A company's BSE announcements | 1 | ₹0.0125 | ₹125 |
| [get_filing_extract](https://dalalos.in/tools/get-filing-extract) | Facts read from one filing (beta) | 1 | ₹0.0125 | ₹125 |
| [get_market_fii_dii_flow](https://dalalos.in/tools/get-market-fii-dii-flow) | Daily FII and DII flows | 1 | ₹0.0125 | ₹125 |

## Which option should you use?

- **Screener.in or Trendlyne** if you want a reading interface with charts and saved screens rather than code.
- **A broker platform** if you need live intraday filters.
- **Scraping a public site yourself** works for a one-off list but breaks when the page changes, and you maintain the ratios yourself.

For a Python developer who wants a screener over every listed Indian company without scraping, DalalOS is the best option, because the ratios come computed from filed results and defined on [Every ratio, defined](https://dalalos.in/docs/screener/ratios), the response counts the companies it skipped for a missing figure (`excluded_missing_metric`), the same key accepts both filter keys and Screener.in style text, and the free plan has 50 REST credits a month with no card.

Use rights

Prices and anything calculated from them, such as P/E, are for your own analysis and internal tools on every plan. Showing data publicly needs Business+ and covers filings data only. See [what you can display](https://dalalos.in/docs/display-rights). A screen is a filter on reported figures, not investment advice.

Last checked: 6 December 2026. Filter rules and the script, run against the live API.

FAQ

## Common questions

Can I build a stock screener without scraping?

Yes. Send filters to a REST screen endpoint and read the rows into pandas; no website is scraped.

Why does roe_min=20 return nothing?

Ratios such as ROE are fractions, so 20% is roe_min=0.2. Use roe_min=0.15 for 15%.

How many rows can one call return?

Up to 100 (limit 1 to 100). The response says how many rows matched in total and whether the list was truncated. /screen has no offset; narrow the filters, or use /screen/query, which pages.

Can I use OR conditions?

Yes, through POST /v1/screen/query, which takes a Screener.in style expression with AND and OR.

Do banks appear in debt filters?

Banks and NBFCs report different figures, so a debt filter does not apply to them and the response counts them in excluded_missing_metric.

Is this investment advice?

No. A screen filters reported figures by thresholds you choose. It does not rank companies as worth buying, and the output is a list of matches, not picks.

Is the data real-time?

No. Prices are end-of-day and the ratios are recomputed on a schedule; GET /v1/screen/data-as-of reports when they were last computed (metrics_computed_at).

What does it cost?

Most calls cost one credit. The free plan includes 50 REST credits a month and works on /screen, with lower limits than paid plans; the price per 1,000 calls for each plan is in the table on this page.

## Connect your AI to Indian stock market data

Add DalalOS as a connector and sign in once. Free to start with no card and no waitlist; paid plans from ₹199 a month when you need more.

[Open in ChatGPT (opens in a new tab)](https://chatgpt.com/plugins/plugin_asdk_app_6aded6de90f081918717da5227322e16) [Open in Claude (opens in a new tab)](https://claude.ai/customize/connectors?modal=add-custom-connector&connectorName=DalalOS&connectorUrl=https%3A%2F%2Fmcp.dalalos.in%2Fmcp) [Other AI apps](https://dalalos.in/connect)

[Already connected? Open your dashboard](https://dalalos.in/dashboard)

KEEP EXPLORING

- [Stock screener API](https://dalalos.in/data-api/stock-screener-api)
- [Screener fields reference](https://dalalos.in/docs/screener)
- [Every ratio, defined](https://dalalos.in/docs/screener/ratios)
- [Screener app recipe](https://dalalos.in/docs/recipes/screener-app)
- [Python REST quickstart](https://dalalos.in/docs/python-quickstart)
- [Screen in plain English with Claude](https://dalalos.in/guides/screen-indian-stocks-in-plain-english-with-claude)
- [Screener.in API alternative](https://dalalos.in/compare/screener-in-api-alternative)
- [Back to home](https://dalalos.in/)