Stock Screener API Filters: Python Examples (P/E, ROE, Debt, Holdings)
GET /v1/screener filters stocks on pre-computed metrics, refreshed daily. Each filter parameter is metric.operator.value. Repeat the parameter to AND conditions together. Operators are gt, lt, gte, lte and eq.
A value + quality screen
import httpx
API = "https://bharatstockapi.com"
HEADERS = {"X-API-Key": "bsk_live_..."} # your key from the dashboard
params = [
("filter", "pe_ratio.lt.15"),
("filter", "roe.gt.12"),
("filter", "debt_to_equity.lt.1"),
("filter", "market_cap.gt.10000"),
("sort_by", "roe"),
("sort_order", "desc"),
("page_size", 50),
]
r = httpx.get(f"{API}/v1/screener", headers=HEADERS, params=params)
r.raise_for_status()
for s in r.json()["data"]:
print(s["symbol"], s["pe_ratio"], s["roe"], s["debt_to_equity"])Pass the filters as a list of tuples, as above. A plain dict cannot repeat the filter key.
Useful variations
- Promoter-heavy:
promoter_holding.gte.50. - Momentum:
return_1y.gt.30sorted byreturn_1y. - One sector or exchange: add
sector=Information Technologyorexchange=NSE.
For the concepts, read how to build a stock screener. Metric names are listed in the reference.