NSEPython Documentation

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.

Mother NSE has blocked all server requests.

is there any solution for that?

CURL Method. When I get time to update ; I will update this library with that.

You can’t do this as per the SEBI circular. https://archives.nseindia.com/content/circulars/WEB45032.pdf

The SEBI mandated Website Security Policy has been enforced on the new NSE website to
protect Investor data and prevent misuse or theft of information.
 Using scripts to download information or scrapping data from NSE website is not
permitted. Hence most pages have a “Download in (.csv)” option enabled on the front

They are free to file legal suit lol on a small retailer like me :stuck_out_tongue: .

Hahaha :smiley:

I tried with curl… But seems they blocked that also…

From Friday yes. Now two methods work -

Just get the cookies from Curl session


Json Token using Python

I will update later.

did you try with https://alternativeto.net/software/httpie/about/

I have really no clue what is it

Adding this to main library.

Updated New Version:

Refactored the NSE’s Request Scrapper with a try-except on the days NSE makes certain problems that need access to cookies.

New functions added -

nse_quote_ltp|() Function:

It will print the price of the BankNIFTY Index.

It will print the price of BankNIFTY Futures of the current expiry.

It will print the price of Reliance Futures of the current expiry.

It will print the price of Reliance.


nsefetch() Function:

We added a new function named nsefetch() which downloads the NSE website links and parse them into JSONs automatically.

Here is how you use it -

positions = nsefetch('https://www.nseindia.com/api/equity-stockIndices?index=SECURITIES%20IN%20F%26O')

Just the link inside the function! That’s it.

nse_quote() Function:

It acts as a universal function towards the quote system defined using nse_eq() and nse_fno(). It will automatically give the correct scrip info.

expiry_list() Function:

Usage: print(expiry_list('RELIANCE'))

nse_optionchain_ltp() Function:

This is the best function.

def nse_optionchain_ltp(payload,strikePrice,optionType,inp=0,intent=""):
    for x in range(len(payload['records']['data'])):
      if((payload['records']['data'][x]['strikePrice']==strikePrice) & (payload['records']['data'][x]['expiryDate']==expiryDate)):
          if(intent==""): return payload['records']['data'][x][optionType]['lastPrice']
          if(intent=="sell"): return payload['records']['data'][x][optionType]['bidprice']
          if(intent=="buy"): return payload['records']['data'][x][optionType]['askPrice']

Originally created for Artemis.

Here is the usage:


inp -

  • inp = 0 means current expiry. It is the default.
  • inp = 1 means next expiry and so on.

intent -

  • If you write your intent as a sell. It will take the bid price.
  • If you write your intent as a buy. It will take the ask price.

LTP is quite deceptive when you trade using ITM right?

pcr() Function:

Here is the usage:


As inp is 1 here, It will show PCR of next expiry!

inp -

  • inp = 0 means current expiry. It is the default.
  • inp = 1 means next expiry and so on.

nse_expirydetails() Function:

Originally created for Artemis, it shows the date of the expiry and number of days to expiry (DTE)



(datetime.date(2020, 9, 17), 10)

As inp is 1 here, It is showing PCR of next expiry!

Make sure to update to the latest version.