NSEPython Documentation

Its not matching with both the old and new websites.

All three are screenshots taken almost close time


But how that will be possible. You can see my code too. You may be fetching in local mode from pickle? Instead of live?

oi_data, ltp, crontime = oi_chain_builder(“NIFTY”,“latest”,“full”,“fetch”)
Iam just using the oi_data received from this method

Then God knows…Check my code. It is just scrapping from NSE only. See if you can spot any mistake there.


Finally found whats wrong…U have hardcoded the multiplication of oi by 20. If it’s only Banknifty data scrapper it was fine but for others, it gives wrong OI and Change in OI :face_with_head_bandage:

Fixed it. Also wrote your name in code as Thank you Gesture.

  1. Fixed the OI problem as mentioned here. NSEPython Documentation
  2. Added ATM Strike Function as mentioned here - Getting the ATM strikes for all the FNO stocks
  3. Removed Pickle as suggested by everyone.

Getting live quotes for stocks using stock codes.

There are two types of APIs that fetch info in NSE.


Equity API and Derivatives API fetches the structure in a different manner. You can just paste their output to a website like jsonformatter.org/json-viewer and study.


You can also alternatively use quote_equity() function instead of nse_eq().
You can also alternatively use quote_derivative() function instead of nse_fno().

This first function will paste the output from the Equity API and the second function will paste the output from Derivatives API.

Stocks API

To get LTP of any stock, You need to do this -

For Open, High, Low, Clsoe, You need to do this -

You can also find things like sector’s PE or sector’s name of which the stock belong -

Derivatives API

To get LTP of any derivative’s underlying, You need to do this -

These APIs show a very detailed level of data. You need to explore yourself using the JSON formats. If there is any significant stuff, I may create a separate functions for it later on.

You can also alternatively use option_chain() function instead of nse_optionchain_scrapper() .

Also, Added one dumb function -

def running_status(): 
    start_now=datetime.datetime.now().replace(hour=9, minute=15, second=0, microsecond=0)
    end_now=datetime.datetime.now().replace(hour=15, minute=45, second=0, microsecond=0)
    return start_now<datetime.datetime.now()<end_now

Just do running_status(). It will give true if the market is running and false if the market is not running.

The Holiday API

There are two types -

Here is how to use the function

or, holiday_master(type)

type = trading or clearing. By default, trading will be selected.

Here is how to see the holidays of FNOs -


The Results API


The API looks like this -


index has three types:

  • equities
  • debt
  • sme

period has four types:

  • Quarterly
  • Annual
  • Half-Yearly
  • Others



Default Value of index is equities and period is Quarterly in nse_results() function.

Example Usage:


The Event Calendar API


API Link: https://www.nseindia.com/api/event-calendar

Just type nse_events()

Pro Tip: You can do a cross search between FNO companies and the companies listed here.


The Past Results API

API Link: nseindia.com/api/results-comparision?symbol=JUSTDIAL

Usage print(nse_past_results('JUSTDIAL'))

1 Like


I have been using and building my own database for years on some of these APIs now, but didnt know bulk results API, events API existed. I was using



Thanks a lot for sharing those APIs. I think I can simplify some of my processing with your urls.

1 Like

TypeError: cannot unpack non-iterable NoneType object
Getting this error intermittently while using the function: df, ltp, crontime = oi_builder(“NIFTY”)
need to know a way to handle this

can we make the function to retry multiple times if there is no data?? because if i keep trying Iam getting data after some 10-15 seconds


Is there a way to get all expiry dates with new nseindia api without having to use quote or chain api?
An api that just returns expiry dates?

Does anybody have list of all the apis provided by nseindia?

def expiry_list(symbol):
    logging.info("Getting Expiry List of: "+ symbol)
    payload = nse_optionchain_scrapper(symbol,)
    payload = pd.DataFrame({'Date':payload['records']['expiryDates']})    
1 Like

I will add a try except.

why its not working on AWS Lambda …when i tried to get option chain data always showing timeout error even i provide full time limit i.e 15 min on Aws.