How to Load NSE & BSE Historical Prices into a Pandas DataFrame
GET /v1/stocks/{ticker}/prices returns daily rows, most recent first, in a data array with a pagination block. page_size goes up to 1000, so a year of data is one call.
The loop
import httpx
API = "https://bharatstockapi.com"
HEADERS = {"X-API-Key": "bsk_live_..."} # your key from the dashboard
import pandas as pd
def fetch_prices(ticker, start, end):
rows, page = [], 1
with httpx.Client(base_url=API, headers=HEADERS, timeout=30) as c:
while True:
r = c.get(f"/v1/stocks/{ticker}/prices",
params={"from": start, "to": end,
"page": page, "page_size": 1000})
r.raise_for_status()
body = r.json()
rows += body["data"]
if page >= body["pagination"]["total_pages"]:
break
page += 1
df = pd.DataFrame(rows)
df["trade_date"] = pd.to_datetime(df["trade_date"])
return df.sort_values("trade_date").set_index("trade_date")
df = fetch_prices("RELIANCE", "2025-01-01", "2025-12-31")
print(df[["close", "adjusted_close", "volume"]].tail())Which column to use
adjusted_closefor charts and returns. It is bonus/split-adjusted, so an ex-date does not show up as a fake crash.close,volumeand turnover are raw as-traded values.delivery_pctis the share of traded volume that was delivered.
Free keys get the most recent year of history; paid plans get the full archive. See adjusted vs raw close and computing returns.