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.
Prerequisites
You’ll need the following Python libraries installed:
pip install pandas requests
pandasis used for working with tabular datarequestsallows 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
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.comto 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
Symbolcolumn.
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
his is a clean list of all current Nifty 50 symbols, ready for further analysis or automation.
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.
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.
yes interested can you guide me on how to fetch constituents for other major indices