How to get option chain for stock options using python API?
Hi @sunilkp1983
You must use the Option Chain API along with the instrument key of the stock for which you wish to retrieve the option chain.
Here is an example to list option chain of reliance industries stock.
import requests
url = 'https://api.upstox.com/v2/option/chain'
params = {
'instrument_key': 'NSE_EQ|INE002A01018',
'expiry_date': '2024-12-26'
}
headers = {
'Accept': 'application/json',
'Authorization': 'Bearer {your_access_token}'
}
response = requests.get(url, params=params, headers=headers)
print(response.json())
Additionally please refer to this instrument json file for instruments keys.
Thank you.
Thank youā¦
I tried this and its working fineā¦
1 Like