Indian Stock Market Data in Python: Quickstart with the BharatStock SDK
The official bharatstock package is a thin typed client over the REST API. It sends your X-API-Key header, parses JSON into objects, handles pagination, and retries with back-off when it gets a 429.
Install and authenticate
pip install bharatstockPass your bsk_live_... key directly, or set the BHARATSTOCK_API_KEY environment variable and omit it.
Fetch a stock, batch quotes and search
from bharatstock import BharatStock
client = BharatStock(api_key="bsk_live_...")
stock = client.stocks.get("RELIANCE")
print(stock.company_name, stock.metrics.pe_ratio, stock.metrics.roe)
for q in client.stocks.quotes(["TCS", "INFY", "HDFCBANK"]):
print(q.symbol, q.close, q.change_pct)
for hit in client.search("tata"):
print(hit.symbol, hit.company_name)Price history
page = client.stocks.prices("RELIANCE", from_date="2026-01-01", page_size=100)
print(page.total_items, page.total_pages)
for row in page:
print(row.trade_date, row.close, row.adjusted_close)List endpoints return a Page you can iterate directly. Next: load prices into pandas, or see the full API reference.