Indian Stock Market API in Python: NSE and BSE Data Guide (2026)

To use an Indian stock market API in Python reliably, pick a documented API with an official Python package instead of a scraper. Use a licensed price-feed vendor such as TrueData or Global Datafeeds for ticks and candles, and an event API such as Drishti for announcements, earnings and news on the National Stock Exchange of India (NSE) and BSE.
This guide covers that choice, then walks through the Drishti Python SDK (software development kit): install, a first call, and a daily watchlist digest in pandas with error handling and pagination. Drishti is our product, so weigh that when you read this comparison.
Key takeaways
- Packages that read public exchange web pages suit exploration. Plan for breakage, blocking and licence questions before shipping on them.
- Split the job: a price-feed vendor for ticks and OHLC (open, high, low, close) candles, an event API for filings and news, a broker API for orders.
pip install drishti-sdkgives you typed helpers such asget_news(),get_announcements()andget_earnings()that return adatalist and ahas_nextflag.- Catch
DrishtiApiErrorfor HTTP failures. The client already retries 408, 409, 425, 429, 500, 502, 503 and 504 responses with backoff. - The free Sandbox covers REST (request and response over HTTP) calls. Live WebSocket streams, which push events over one open connection, need a paid plan.
On this page
- Why NSE API Python searches lead to scrapers
- Indian stock market API Python options by data job
- Install the Drishti Python SDK
- Make your first call
- What you want in Python and the SDK method for it
- Build a daily watchlist digest with pandas
- Errors, retries and rate limits
- Live events over WebSocket
- Frequently asked questions
- Start with the Sandbox and one watchlist
Why NSE API Python searches lead to scrapers
Search for an NSE API in Python and the first results are usually nsetools, scraping tutorials and unofficial wrappers. nsetools describes itself as retrieving publicly available data from the official website without authentication, which makes it quick to try in a notebook.
The trade-off shows up when that notebook becomes a job that runs every morning. A library that reads public web pages depends on page structure and request patterns the site owner can change without notice, and your job fails until the maintainers catch up.
Exchange websites can also throttle or block clients that make many automated requests. And reading a page is different from having the right to store it or show it to your users. That is no criticism of the maintainers: it is the difference between a learning tool and a dependency behind a client report.
Indian stock market API Python options by data job
Start from the data your code needs: prices, company events and orders are different products.
| If your build needs | Consider | Why it may fit | Check before choosing |
|---|---|---|---|
| AI-summarised announcements, earnings, concalls, news with sentiment, alerts, from Python | Drishti (drishti-sdk on PyPI) | Official Python SDK with typed helpers, pagination, retries and a WebSocket client | No tick or OHLC prices and no orders; Sandbox has no WebSockets |
| Real-time ticks and historical prices for NSE, BSE and Multi Commodity Exchange (MCX) | TrueData | Authorised vendor with WebSocket, TCP and REST APIs and the official truedata package | API pricing is not published; the licence covers the subscriber's own use |
| Real-time, delayed, historical and option chain data into platforms or algos | Global Datafeeds | Authorised NSE and MCX vendor since 2010 with WebSocket, REST and FIX (Financial Information eXchange), plus the ws-gfdl Python wrapper | The wrapper is labelled beta; pricing is on request |
| Company research in a web interface | Tijori Finance | Filings and news timeline, results and 6,000+ operational metrics | Public developer APIs are limited; no self-serve SDK found |
| Screeners, scores and an events calendar | Trendlyne | DVM (durability, valuation, momentum) scores, alerts, Excel Connect and MCP plans from ₹299/month | No self-serve public API documentation found |
| Ready-made scans for results, announcements and concalls | StockScans | Free entry tier, watchlists and dashboards, data from CMOTS | No public developer API listed |
This is a product-fit comparison, not a ranking. We have not benchmarked these providers side by side. If you need to place orders, use a broker API such as Kite Connect, Upstox or DhanHQ.
A practical setup uses two sources: TrueData or Global Datafeeds for prices, and Drishti for the company events that explain why a price moved. Drishti is an independent market-intelligence API built on official exchange-backed sources. It does not scrape NSE or BSE websites.
Install the Drishti Python SDK
You need Python 3.10 or newer and an API key from the Sandbox. Install the SDK and pandas:
pip install drishti-sdk pandas
Export the key as the DRISHTI_API_KEY environment variable so it stays out of your source. The client sends it in the X-API-Key header to https://developers.manasija.in. The Python SDK reference lists every helper and option.
Make your first call
This script reads the latest news for two symbols, the smallest useful test of your key and the response shape.
import os
from drishti_sdk import DrishtiApiError, DrishtiClient
with DrishtiClient(api_key=os.environ["DRISHTI_API_KEY"]) as client:
try:
news = client.get_news(symbols=["RELIANCE", "TCS"], limit=5)
except DrishtiApiError as exc:
print(f"Drishti returned HTTP {exc.status_code}: {exc.body}")
raise
for item in news["data"]:
print(item.get("date"), item.get("symbol"), item.get("sentiment"), item.get("title"))
print("more pages:", news["has_next"])
Every list helper returns the same envelope: data holds plain dictionaries and has_next says whether another page exists, so pd.DataFrame(result["data"]) works directly. When we ran this on 21 October 2026, it printed five headlines with positive or neutral sentiment and more pages: True.
One detail to plan for: a news item can name several companies, and the symbol field then joins them with colons, such as TCS:INFY. Split on : if you group results by company.
What you want in Python and the SDK method for it
All helpers take keyword arguments. Date filters use from_ with an underscore, because from is a Python keyword.
| What you want in Python | SDK method | Useful arguments |
|---|---|---|
| Company news with sentiment | get_news() | symbols, sentiment, from_, to, page, limit |
| NSE and BSE announcements with AI summaries | get_announcements() | symbols, scrip_codes, categories, detailed |
| Quarterly results and earnings tables | get_earnings(), get_earnings_detail() | symbols, quarter, detailed |
| Upcoming results dates | get_upcoming_earnings() | symbols, scrip_codes |
| Concall analysis and transcripts | get_concalls(), get_concalls_transcript() | symbols, quarter |
| 52-week high or low, price and volume alerts | get_alerts() | symbols, type, important |
| Block deals | get_block_deals() | symbols, exchange |
| Symbol metadata | get_symbols_metadata() | symbols, scrip_codes |
BSE API Python: use scrip codes
Most helpers accept scrip_codes alongside symbols. Pass a BSE scrip code such as "500325" when your watchlist comes from BSE data.
NSE announcements in Python, beyond this guide
If announcements are all you need, our announcements-only tutorial goes deeper on categories, detailed=True and deduplication.
Build a daily watchlist digest with pandas
The digest pulls the last 24 hours of announcements, earnings and news for five symbols, follows every page and puts the result in one DataFrame.
import os
from datetime import datetime, timedelta, timezone
import pandas as pd
from drishti_sdk import DrishtiApiError, DrishtiClient
WATCHLIST = ["RELIANCE", "TCS", "INFY", "HDFCBANK", "ITC"]
COLUMNS = ["id", "date", "symbol", "title", "summary"]
since = (datetime.now(timezone.utc) - timedelta(days=1)).isoformat()
def fetch_all(method):
rows, page, has_next = [], 1, True
while has_next:
result = method(symbols=WATCHLIST, from_=since, page=page, limit=50)
rows += result["data"]
has_next, page = result["has_next"], page + 1
return rows
frames = []
with DrishtiClient(api_key=os.environ["DRISHTI_API_KEY"]) as client:
for kind in ("announcements", "earnings", "news"):
try:
rows = fetch_all(getattr(client, f"get_{kind}"))
frames.append(pd.DataFrame(rows, columns=COLUMNS).assign(kind=kind))
except DrishtiApiError as exc:
print(f"{kind} skipped: HTTP {exc.status_code} {exc.body}")
digest = pd.concat(frames, ignore_index=True).drop_duplicates("id")
digest["headline"] = digest["title"].fillna(digest["summary"]).str.slice(0, 100)
digest = digest.sort_values(["symbol", "date"], ascending=[True, False])
print(digest.to_string(index=False, columns=["symbol", "kind", "date", "headline"]))
fetch_all keeps requesting pages until has_next is false, so a busy day does not silently cut off at 50 rows. Announcements and earnings have no title, so the headline falls back to the AI summary. drop_duplicates("id") removes a record that appears twice when new items arrive during pagination.
Each source sits in its own try block, so one failing endpoint still leaves you the other two sections. On our run it made three requests and returned two HDFC Bank announcements, ten news items and no earnings for that day.
To send it instead of printing it, swap the last line for digest.to_html() in an email body or digest.to_csv() as an attachment, then schedule the script with cron or a continuous integration (CI) job before market open.
Errors, retries and rate limits
DrishtiApiError carries status_code and body, so you can log the server's message. A 401 means the key is wrong or missing; a 400 usually means a bad argument, such as an invalid date string.
The client retries 408, 409, 425, 429, 500, 502, 503 and 504 responses with exponential backoff, tunable through retry_max_retries and the delay options. All five official SDKs pass one shared conformance test suite, so this behaviour matches across languages.
Sandbox allows 10 requests per minute and 1,000 REST requests per day, with 1,000 one-time trial credits. The digest uses three requests on a quiet day. Starter, at ₹2,000 a month, raises the limit to 60 requests per minute.
Live events over WebSocket
For alerts rather than a daily digest, client.websocket() opens an async session that subscribes to news, announcements, earnings, concalls, alerts or block_deals for your symbols. It reconnects and resubscribes on its own.
WebSockets are available on paid plans: Starter monitors 100 symbols and Pro 1,000. The WebSocket guide covers subscriptions and event shapes; keep a REST catch-up query for downtime.
Drishti does not provide tick-by-tick prices or submit orders, so pair the stream with a price-feed vendor or a broker API when your strategy needs those.
Frequently asked questions
Is there an official NSE API for Python?
NSE offers data through its own subscription products and through authorised vendors. We did not find a self-serve Python package published by the exchange. In practice you choose a vendor with a Python library, such as TrueData's truedata, Global Datafeeds' ws-gfdl, or Drishti's drishti-sdk for company events.
Is nsetools safe to use in production?
It works well for learning and personal analysis. For production, plan for page changes, request blocking and whether you may store or redistribute the data.
How do I get NSE announcements in Python?
Install drishti-sdk, call get_announcements(symbols=[...], from_=...) and loop while has_next is true. Add detailed=True for the long summary and extracted fields.
Can I get live stock prices in Python from Drishti?
No. Drishti covers announcements, earnings, concalls, news, alerts and block deals. Use TrueData or Global Datafeeds for tick and OHLC prices, and a broker API to place orders.
Start with the Sandbox and one watchlist
Create a free key on the Drishti Sandbox, export it as DRISHTI_API_KEY and run the first-call script. Then swap in your own five symbols and schedule the digest. The Python SDK reference has every method when you want to add concalls or alerts, and the SDK comparison hub covers the other four languages.
Product pages, package registries and documentation checked on 21 October 2026. Prices and features change, so confirm on each provider's site before you buy. This article is not investment advice.



