Option chain how to get data through api

how can we use ?
curl --location
–header ‘access-token: JWT’
–header ‘client-id: ClientId’
–header ‘Content-Type: application/json’
–data ‘{}’

{
"UnderlyingScrip":13,
"UnderlyingSeg":"IDX_I",
"Expiry":"2025-02-27"
}

as i am new, i want clear code to get the option chain

Hi @Sunil_Gupta :

Below is how you can get the option chain:

  • tsl.get_option_chain(Underlying: str, exchange: str, expiry: int) → pd.DataFrame | None
  • Arguments:
    • Underlying (str): The symbol of the underlying asset (e.g., “NIFTY”, “BANKNIFTY”, “RELIANCE”).
    • exchange (str): The exchange where the options are traded (e.g., “NSE”, “NFO”, “MCX”).
    • expiry (int): Index of the expiry date in the list of available expiry dates (0 for the nearest expiry).
  • Returns:
    • pd.DataFrame: A formatted DataFrame containing the option chain data with details like strike price, call/put LTP, OI, volume, etc.
    • None: Returns None if there is an error or no expiry data is found.
  • Sample Code:

option_chain = tsl.get_option_chain(Underlying="NIFTY", exchange="INDEX", expiry=0)

Do check out this video: