NSE end-of-day data in Python
Two calls cover most end-of-day needs: index levels with valuation, and a stock's daily history including delivery percentage. This guide uses the Market Data API and pandas.
You need an API key: request a free beta key. Keep it in an environment variable, never in code you publish.
Script
Index names follow NSE's spelling in the data (for example Nifty 50 and Nifty Bank); list them first with /api/market/indices if unsure. Equity history takes the NSE symbol and an optional start date.
import os
import requests
import pandas as pd
BASE = os.environ.get("EJI_BASE", "https://fin.ejiapi.com")
HEADERS = {"x-api-key": os.environ.get("EJI_KEY", "YOUR_KEY")}
def get(path, **params):
r = requests.get(BASE + path, params=params, headers=HEADERS, timeout=30)
r.raise_for_status()
return r.json()["data"]
# Index levels with valuation (latest day)
idx = pd.DataFrame(get("/api/market/indices"))
print(idx[idx["indexName"].isin(["Nifty 50", "Nifty Bank"])][["indexName", "date", "close", "pe", "pb", "divYield"]].to_string(index=False))
# End-of-day history for one stock, with delivery percentage
eq = pd.DataFrame(get("/api/market/equity/TCS/history", start="2026-10-26"))
eq["date"] = pd.to_datetime(eq["date"])
eq = eq.set_index("date")
print(eq[["close", "volume", "deliveryPct"]])
print("average delivery %:", round(eq["deliveryPct"].mean(), 1))
eq["return_pct"] = eq["close"].pct_change() * 100
print(eq["return_pct"].round(2).dropna().to_list())Output
indexName date close pe pb divYield
Nifty 50 2026-11-06 25030.35 20.65 3.07 1.41
Nifty Bank 2026-11-06 59086.00 13.06 1.78 1.06
close volume deliveryPct
date
2026-10-26 2535.0 4326029 51.66
2026-10-27 2496.9 4337081 56.55
2026-10-28 2460.0 2540047 38.06
2026-10-29 2478.0 3427569 55.37
2026-10-30 2502.6 3016983 47.09
2026-11-02 2501.7 2817192 53.40
2026-11-03 2499.1 3488517 53.07
2026-11-04 2436.0 3142051 51.70
2026-11-05 2495.7 6767948 61.84
2026-11-06 2498.5 4922308 45.78
average delivery %: 51.5
[-1.5, -1.48, 0.73, 0.99, -0.04, -0.1, -2.52, 2.45, 0.11]Notes
- Delivery percentage is the share of traded quantity that was taken for delivery rather than squared off the same day. NSE publishes it with its end-of-day files.
- Closes are as reported for the day; they are not adjusted for splits or bonuses.
- Data is end of day, published after the close, not live quotes. Freshness per data group is on the status page.
- More endpoints (movers, futures, options summary, corporate actions, IPOs) are in the reference.
Data comes from public disclosures and is for information, not investment advice. Sample outputs were produced on 2026-11-08 and change as new data is published.