How to fetch NSE and BSE stock data in Python
A practical Python guide to fetching Indian stock market data without scraping: financial statements, historical prices, company search and shareholding through a stable API.

Scraping NSE and BSE pages works until the markup changes, a session cookie expires, or the site decides your request looks automated. For a side project that is annoying. For a product used every day, it is a maintenance tax that never ends.
A market data API gives you the same public information as a structured response. You spend your time on the product instead of repairing a parser. This guide uses Python and plain HTTP requests, so it works in a script, a notebook or a backend service.
What you need
- Python 3.10 or newer.
- An API key from your Fincrux dashboard.
- The requests package, or any HTTP client you already use.
Create a key at /dashboard/api-keys, then keep it in an environment variable. Do not commit the key to a repository, and do not expose it in browser code.
pip install requests
export FINCRUX_API_KEY="your_api_key"Fetch a company financial record
The financials endpoint returns the company record for a trading symbol. That includes the statements, shareholding and the last update time. The API key is passed as a query parameter.
import os
import requests
API_KEY = os.environ["FINCRUX_API_KEY"]
BASE_URL = "https://api.fincrux.org"
response = requests.get(
f"{BASE_URL}/api/financials/RELIANCE",
params={"api_key": API_KEY},
timeout=30,
)
response.raise_for_status()
company = response.json()
print(company["company_name"])
print(company["last_updated"])Keep the raw response. Store it with the timestamp returned by the API so you can tell stale data from a fresh filing. Financial statements change when a company files, not every minute, so caching is expected.
Get historical prices
Historical OHLC data lives on a separate endpoint because it has a different update cadence from annual filings. Ask for the range you need instead of downloading the full history on every request.
prices = requests.get(
f"{BASE_URL}/api/historicals/RELIANCE",
params={"api_key": API_KEY},
timeout=30,
).json()Search companies and build a universe
The search endpoint is useful for a ticker picker. The all-companies endpoint is better for a scheduled job that refreshes your local company directory. Fetch the directory once, cache it, and search locally when possible.
matches = requests.get(
f"{BASE_URL}/api/search/tata",
params={"api_key": API_KEY},
timeout=30,
).json()
universe = requests.get(
f"{BASE_URL}/api/all_companies",
params={"api_key": API_KEY},
timeout=60,
).json()Handle limits and failures like a production client
- Set a timeout on every request. A hanging request is worse than a fast error.
- Retry idempotent GET requests with a short backoff, not in a tight loop.
- Read the error body before retrying. Authentication and rate-limit errors need different handling.
- Cache financial statements for the day and prices for the interval your product actually needs.
- Show the last updated timestamp next to the number, not in a hidden debug panel.
The free Hobby plan is enough to validate the endpoints and build the first screen. When the product starts serving real users, move to a plan with the request rate you need. The important part is that the data contract stays the same while your traffic grows.

