Option chain data horizontal and vertical

i am working on code where i need data of particlar option chain,say +/- 4 ATM range at strike price ( all horizontal data including option greek,oi,volume,iv )and OHLC,volume data for underlyning.Its more than week but code showing erroe of wrong security i’d.Please help me.If there existing pacage for data fetching using api.Ex-nifty50 underlyning , option chain for nearest expiry.

Hey @monty_dabas ,

Here is the request structure for fetching the option chain data:

Option Chain
dhan.option_chain(
under_security_id=13, # Nifty
under_exchange_segment=“IDX_I”,
expiry=“2025-09-30”
)

You may also refer our library: GitHub - dhan-oss/DhanHQ-py: The official Python client for communicating with the Dhan API.

Additionally to fetch security id you may use https://images.dhan.co/api-data/api-scrip-master-detailed.csv