How to get option chain for Nifty using python api

in payload to build the option chain you need to use ‘instrument_key’: ‘NSE_Index|Nifty 50’, instead of
‘instrument_key’: ‘NSE_FO|Nifty 50’

not working @rushi1192

you are passing payload as data where as you should pass data as parameters in python use params instead of data

1 Like

now working , i got mistakenly use other url to parse . thank you for provide your help

1 Like

is it working with this code?

1 Like

yes. I try a new data frame in the end

import requests
import json

url = “https://api.upstox.com/v2/option/chain

params = {
** ‘instrument_key’: ‘NSE_INDEX|Nifty Bank’,**
** ‘expiry_date’: ‘2024-02-29’ # format YYYY-MM-DD**
}

headers = {
** ‘Content-Type’: ‘application/json’,**
** ‘Accept’: ‘application/json’,**
** ‘Authorization’: f’Bearer {access_token}',**
}

response = requests.request(“GET”, url, headers=headers, params=params)

response= json.loads(response.text)
daily_nf_live = pd.json_normalize(response[‘data’])

print(daily_nf_live)

1 Like

thanks it is working good

1 Like

Hey there I wanted to know if there is an API available for MCX ? and also wanted to get in touch for Uplink Business if you guys can help me out?

how to get put/call optionchain using websocket

@Dewanshi_Ramani, to get real-time option chain data using the Upstox API, you’ll need to provide mode values to the “option_chain” parameter. Detailed instructions can be found here: Market Data Feed | Upstox Developer API

For a list of option contracts and other details, you can utilize the REST endpoint documented here: Put/Call Option Chain | Upstox Developer API

@Tanmay_Joshi we do not support MCX as of now. For business API, please share your email and phone number. We will have someone reach out to discuss your needs.

Apologies for the delayed response here.

Dear sir,

How to get option chain data using websocket.

give me a source code

Dear sir,

How to get indexff and marketff data using websocket , give me a source code

Please refer to the Sample Websocket Implementation examples on GitHub for guidance on connecting to the websocket.

To obtain option chain data, subscribe to the websocket in option_chain mode, one of the three subscription modes available. For further details, please see our API Documentation.

1 Like