Welcome
NSEPython is a Python library to get publicly available data on NSE website ie. stock quotes, historical data, live indices, etc. Thanks for using NSEPython . Let’s get you up and running.
Versions
There are two versions of NSEPython depending on the execution environment. While it’s technically feasible to combine these versions into a single program, doing so could introduce latency. Given the financial nature of this program, time is of the essence.
NSEPython Edition | Compatibility | Tested Environments |
---|---|---|
Local Edition | Laptops (Windows 9, 10) | Windows 9, Windows 10 |
Server Edition | Servers (AWS, Google Colab, DigitalOcean) | AWS, Google Colab, DigitalOcean |
Installation
Access NSEPython for laptops, specifically tailored for Windows 9 and Windows 10 compatibility. To use it, open up your terminal in the desired directory and run the following command:
pip install nsepython
Leverage NSEPython designed for server environments, seamlessly functioning on AWS, Google Colab, and DigitalOcean. To use it, open up your terminal in the desired directory and run the following command:
pip install nsepythonserver
Support and Beta Functions
- If you have other doubts or want to check out the beta functions, visit the NSEPython Discussions forum.
- If you have feature requests, you can submit them at the NSEPython Feature Request forum.
Upgrade
pip install --upgrade nsepython
In case of Server Edition, The command will be –
pip install --upgrade nsepythonserver
Getting Started
To Initialize, You need to do from nsepython import *
Note that – If You have installed nsepythonserver
, You need to write nsepythonserver
instead of nsepython
. The tutorials and documentaions will use the notion of nsepython
for simplicity.
Then here is the way to fetch the Indices of NSE –
Input
from nsepython import *
print(indices)
Output
['NIFTY', 'FINNIFTY', 'BANKNIFTY']
Unofficed Session Tutorials
If You have never used Python, Jupyter and are beginner stumbling into this project, Go through this link Basics of NSEPython Using Python and Jupyter.
Google Cloud, AWS, Servers
This local version of NSEPython does not work with AWS, Google Cloud and web servers. It is not a problem of Python Request. Nse’s robots.txt has blocked all webservers all together.
See here NSE Robots Txt
User-agent: *
Disallow: /static/htmls/
Disallow: /static/src/
Disallow: /server/
Disallow: /api/
Sitemap: https://www.nseindia.com/sitemap.xml
Sitemap: https://www.nseindia.com/sitemap-stocks.xml
The server edition use the curl method and initiate shell commands using Python. The curl method does not run on local computers.
The server edition is also firewalled heavily by NSE. Like if You must use Indian Servers to access the API. It completely blocks some countries!
ENVIRONMENT ERROR
If you are facing problem in running with the basic functions, visit the NSEPython Discussions forum and state your configuration for further evaluation.
WARNING
Exercise caution to prevent inadvertently coding endless loops into your scripts. Such loops can lead to increased server loads on NSE’s end, potentially prompting them to reinforce their firewalls. This could create numerous issues for enthusiasts like us, similar to what happened with their previous website.