Option chain streaming

Is there a way I can stream option chain of given stocks? “https://api.upstox.com/v2/option/chain” gives all the data I want…But I am not able to call it continuously because of API limitation. How to solve this issue?

To address the issue mentioned above, you can utilize our market WebSocket with the option_chain mode. This will provide you continuous feed of the given option contracts. For further information, please review the various modes available in the Market Data Feed WebSocket.

Hope the above information helps, Thank you.

Can you give the code for fetching option chain of a specific stock. For example, Reliance,

import requests

url = 'https://api.upstox.com/v2/option/contract?instrument_key={}&expiry_date=2024-06-27'
headers = {
    'Accept': 'application/json',
    'Authorization': 'Bearer {your_access_token}'

response = requests.get(url, headers=headers)

# Print the response content

What should I keep as instrument_key, I tried to check the CSV, unable to figure out.

import requests
url = "https://api.upstox.com/v2/option/chain"
headers = {'Accept': 'application/json','Authorization' = f'Bearer {your_access_token}'}
response = requests.get(url, headers=headers, params=params)
response = response['data']

Download the csv file from https://assets.upstox.com/market-quote/instruments/exchange/NSE.csv.gz From this csv file, you have to find the instrument key for your stock. For example if you want reliance, the key will be NSE_EQ|INE002A01018. Pass this key as “key” variable in params

1 Like