Compare Sector Peers by P/E, ROE and ROCE with One API Call
GET /v1/stocks/compare computes ratios in bulk for one sector, so a peer table is a single request. Parameters: sector (exact name, for example Financial Services), sort (market_cap, pe_ratio, pb_ratio, roe or roce) and limit (max 100, default 20).
import httpx
API = "https://bharatstockapi.com"
HEADERS = {"X-API-Key": "bsk_live_..."} # your key from the dashboard
r = httpx.get(f"{API}/v1/stocks/compare", headers=HEADERS,
params={"sector": "Financial Services",
"sort": "pe_ratio", "limit": 10})
r.raise_for_status()
for s in r.json()["data"]:
print(f'{s["symbol"]:12} P/E {s["pe_ratio"]} ROE {s["roe"]}')The P/E here is the same current P/E served by /v1/stocks/{ticker}/ratios and the screener. For a wider filter than one sector use the screener filters.