Skip to content

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.

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, 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

How filters are written on GET /v1/screen
ParameterMeaningExample
<metric>_minLower bound on any filterable metricroe_min=0.15
<metric>_maxUpper bound on any filterable metricpe_max=20
debt_to_equity_maxRatio, not a percentdebt_to_equity_max=0.5
sectorExact sectorsector=Information Technology
indexIndex membershipindex=NIFTY 50
sort_byMetric to sort bysort_by=market_cap
orderasc or descorder=desc
limitRows, 1 to 100limit=100

An unknown filter key returns a 400 that lists every accepted key, and GET /v1/ratios 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, 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.

Price per API call: DalalOS plans and other providers
Provider and planPrice a monthCalls includedPrice per callPer 1,000 callsNotes
DalalOS Plus₹199500 REST credits₹0.398₹398REST and MCP. Yearly billing lowers the price further.
DalalOS Pro₹69920,000 REST credits₹0.0350₹34.95REST and MCP. Yearly billing lowers the price further.
DalalOS Business₹2,4991,50,000 REST credits₹0.0167₹16.66REST and MCP, named contact. Yearly billing lowers the price further.
DalalOS Business+₹4,9994,00,000 REST credits₹0.0125₹12.50REST and MCP, named contact. Yearly billing lowers the price further.

DalalOS prices are read from our live plan catalog and include taxes; see 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+

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

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, 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. A screen is a filter on reported figures, not investment advice.

Last checked: . 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.

KEEP EXPLORING