Rajandran R Creator of OpenAlgo Sketchmaker, RagZ. Building GenAI Applications. Telecom Engineer turned Full-time Derivative Trader. Mostly Trading Nifty, Banknifty, High Liquid Stock Derivatives. Trading the Markets Since 2006 onwards. Using Market Profile and Orderflow for more than a decade. Designed and published 100+ open source trading systems on various trading tools. Now the recent curiosity on building Trading AI Agents.

How to Fetch Nifty 50 Symbols Using Python and Pandas

4 min read

To fetch Nifty 50 symbols in Python, download NSE’s official constituent file ind_nifty50list.csv with requests and load it into a Pandas DataFrame; the Symbol column gives you all 50 tickers. This tutorial walks through the script, shows the output, and adds an updated 2026 version that works for other NSE indices too.

If you’re just getting started with financial data analysis in Python, one of the most common tasks is fetching a list of stock symbols. In this article, we’ll walk through how to retrieve the latest Nifty 50 companies directly from the official National Stock Exchange of India (NSE) website and load them into a Pandas DataFrame.

We’ll keep it simple and beginner-friendly.

Python for traders, the quick way in

BEGINNER FRIENDLY · RATED 5.0

Python for traders, the quick way in

A crash course that gets you from zero to writing your own market data scripts.

  • Python basics with market examples
  • Fetch, clean and chart price data
  • Lifetime access
Start learning →by Marketcalls
Key takeaways
  • NSE publishes the Nifty 50 list as a CSV at nsearchives.nseindia.com, with company name, industry, symbol, series and ISIN.
  • Two libraries are enough: pandas and requests.
  • The same URL pattern works for Nifty Next 50, Nifty 100, Nifty 500, Bank Nifty and sector indices.
  • The constituents change at index rebalancing, so download the list fresh instead of hard coding it.
  • Add “.NS” to each symbol if you want to use the list with yfinance.

Prerequisites

You’ll need the following Python libraries installed:

pip install pandas requests
  • pandas is used for working with tabular data
  • requests allows us to download content from the web

The NSE’s Official Source

The NSE provides the Nifty 50 list as a downloadable CSV file. The direct link to this file is:

https://nsearchives.nseindia.com/content/indices/ind_nifty50list.csv

How to Fetch Nifty 50 Symbols: The Complete Code

Here’s a complete Python script that does everything for you:

import pandas as pd
import requests
from io import StringIO

url = "https://nsearchives.nseindia.com/content/indices/ind_nifty50list.csv"

headers = {
    "User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36",
    "Accept-Language": "en-US,en;q=0.9",
    "Referer": "https://www.nseindia.com/market-data/live-equity-market"
}

with requests.Session() as session:
    session.headers.update(headers)
    session.get("https://www.nseindia.com", timeout=5)  # Warm-up to set cookies

    response = session.get(url, timeout=10)
    
    if response.status_code == 200:
        csv_content = response.content.decode('utf-8')
        df = pd.read_csv(StringIO(csv_content))
        print(df['Symbol'])  # Show the stock symbols
    else:
        print(f"Failed to retrieve data. Status code: {response.status_code}")

Understanding the Code

  • We start a session with custom headers to mimic a real browser.
  • We make a quick warm-up request to nseindia.com to establish cookies and prevent errors.
  • Then, we download the CSV file containing the Nifty 50 stocks.
  • Finally, we load it into a DataFrame and print only the Symbol column.

What the Output Looks Like

When you run the script, you’ll get an output like this:

0       ADANIENT
1     ADANIPORTS
2     APOLLOHOSP
3     ASIANPAINT
4       AXISBANK
5     BAJAJ-AUTO
6     BAJFINANCE
7     BAJAJFINSV
8            BEL
9     BHARTIARTL
10         CIPLA
11     COALINDIA
12       DRREDDY
13     EICHERMOT
14       ETERNAL
15        GRASIM
16       HCLTECH
17      HDFCBANK
18      HDFCLIFE
19    HEROMOTOCO
20      HINDALCO
21    HINDUNILVR
22     ICICIBANK
23           ITC
24    INDUSINDBK
25          INFY
26      JSWSTEEL
27        JIOFIN
28     KOTAKBANK
29            LT
30           M&M
31        MARUTI
32          NTPC
33     NESTLEIND
34          ONGC
35     POWERGRID
36      RELIANCE
37       SBILIFE
38    SHRIRAMFIN
39          SBIN
40     SUNPHARMA
41           TCS
42    TATACONSUM
43    TATAMOTORS
44     TATASTEEL
45         TECHM
46         TITAN
47         TRENT
48    ULTRACEMCO
49         WIPRO
Name: Symbol, dtype: object

This is a clean list of all current Nifty 50 symbols, ready for further analysis or automation.

Updated Version (2026): Reusable Function for Any NSE Index

When I re-ran the script on 10 November 2026, the warm-up request to the NSE home page returned HTTP 403, but the CSV download itself still worked (HTTP 200). The archive file does not need the cookie, so the updated way to fetch Nifty 50 symbols below skips the warm-up, raises a clear error if the download fails, and wraps everything in a function you can reuse for any index:

import pandas as pd
import requests
from io import StringIO

BASE = "https://nsearchives.nseindia.com/content/indices/"
HEADERS = {
    "User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36",
    "Accept-Language": "en-US,en;q=0.9",
}

def fetch_index(file_name="ind_nifty50list.csv"):
    """Download an NSE index constituent CSV and return it as a DataFrame."""
    response = requests.get(BASE + file_name, headers=HEADERS, timeout=15)
    response.raise_for_status()
    df = pd.read_csv(StringIO(response.content.decode("utf-8")))
    df.columns = df.columns.str.strip()
    return df

nifty50 = fetch_index()
print(len(nifty50), "stocks")
print(nifty50[["Symbol", "Industry"]].head())
print(nifty50["Industry"].value_counts().head(3))

symbols = nifty50["Symbol"].tolist()
yf_tickers = [s + ".NS" for s in symbols]   # Yahoo Finance format
print(yf_tickers[:5])

nifty50.to_csv("nifty50_symbols.csv", index=False)

Output (10 November 2026):

50 stocks
       Symbol            Industry
0    ADANIENT     Metals & Mining
1  ADANIPORTS            Services
2  APOLLOHOSP          Healthcare
3  ASIANPAINT   Consumer Durables
4    AXISBANK  Financial Services
Industry
Financial Services                12
Healthcare                         5
Automobile and Auto Components     5
Name: count, dtype: int64
['ADANIENT.NS', 'ADANIPORTS.NS', 'APOLLOHOSP.NS', 'ASIANPAINT.NS', 'AXISBANK.NS']

The script also saves nifty50_symbols.csv so your screener or backtest can load the list offline.

Other NSE Index Files

These file names worked with the same function on 10 November 2026:

IndexFile name
Nifty 50ind_nifty50list.csv
Nifty Next 50ind_niftynext50list.csv
Nifty 100ind_nifty100list.csv
Nifty 500ind_nifty500list.csv
Nifty Bankind_niftybanklist.csv
Nifty ITind_niftyitlist.csv
NSE index constituent CSV files

Nifty 50 Constituents Change: July 2025 vs November 2026

The output above was generated in July 2025. Comparing it with the file downloaded from NSE on 10 November 2026 shows why you should always fetch the list fresh:

No longer in the July 2025 listNew in the November 2026 list
HEROMOTOCOBSE
INDUSINDBKINDIGO
TATAMOTORSMAXHEALTH
WIPROTMPV
Changes in Nifty 50 symbols between the two downloads

In the November 2026 file, Financial Services is the largest sector with 12 of the 50 stocks.

Common Errors and Fixes

  • HTTP 403 or timeout: NSE blocks requests without a browser-like User-Agent. Keep the headers, add a timeout and retry after a short pause.
  • KeyError: ‘Symbol’: column names can carry stray spaces. Use df.columns.str.strip() as in the updated version.
  • Symbols with special characters: M&M and BAJAJ-AUTO contain characters that some APIs need encoded. Check your broker or data API’s symbol format.
  • Stale lists: cached CSVs go out of date after each rebalancing. Re-download before running a screener.

Where to Go From Here

Once you have the list, you can easily:

  • Fetch live stock prices using an API
  • Backtest trading strategies
  • Track fundamental metrics
  • Build dashboards or alerts

This technique isn’t limited to Nifty 50 either. You can use similar methods to pull data for Nifty Next 50, Bank Nifty, or sector-specific indices. Most of them follow a similar URL structure.

For example, you can feed the symbols into a TradingView style Nifty 50 heatmap, a Nifty 50 market cap treemap with Plotly, or download their price history with yfinance.

Final Thoughts

Fetching clean and up-to-date data from a trusted source like NSE is the first step toward building reliable market analytics. This script is fast, simple, and can be plugged into bigger systems like screeners or algo trading pipelines.

If you’re building trading tools or automations in Python, this is a great piece of reusable code to have in your toolkit.

Let me know if you’d like to explore how to fetch other index constituents or even set up a live data pipeline.

Frequently Asked Questions

Where can I download the Nifty 50 stock list as CSV?

NSE publishes it at nsearchives.nseindia.com/content/indices/ind_nifty50list.csv. The file has company name, industry, symbol, series and ISIN code.

How do I get Nifty 50 symbols for yfinance?

Download the NSE list, take the Symbol column and add “.NS” to each ticker, for example RELIANCE.NS.

How often does the Nifty 50 list change?

NSE reviews index constituents periodically, so the list changes a few times a year. Fetch Nifty 50 symbols fresh rather than hard coding them.

Can I fetch Bank Nifty or Nifty 500 constituents the same way?

Yes. Replace the file name with ind_niftybanklist.csv or ind_nifty500list.csv in the same function.

Related: Nifty 50

Python Elite membership

MEMBERSHIP

Python Elite membership

15 Python, AI and algo trading programs in one plan, including QuantFlow and AI Bootcamp live mentorship.

  • Python from fundamentals to trading apps
  • Backtesting, broker APIs and OpenAlgo
  • Live QuantFlow and AI Bootcamp sessions
View Python Elite →by Marketcalls

Learn by watching: free videos every week

Market Profile, order flow, Python, AI and OpenAlgo tutorials on YouTube.

Rajandran R Creator of OpenAlgo Sketchmaker, RagZ. Building GenAI Applications. Telecom Engineer turned Full-time Derivative Trader. Mostly Trading Nifty, Banknifty, High Liquid Stock Derivatives. Trading the Markets Since 2006 onwards. Using Market Profile and Orderflow for more than a decade. Designed and published 100+ open source trading systems on various trading tools. Now the recent curiosity on building Trading AI Agents.

One Reply to “How to Fetch Nifty 50 Symbols Using Python and…”

  1. yes interested can you guide me on how to fetch constituents for other major indices

Leave a Reply

Get Notifications, Alerts on Market Updates, Trading Tools, Automation & More