I am using the DhanHQ API for my algorithmic trading setup

Hi Dhan Team,
I need to fetch historical Open Interest (OI) data for F&O Options on a 5-minute timeframe. My goal is to analyze OI buildups (Spikes) compared to the 20-period moving average.

Could you please guide me on:

  1. Which specific API endpoint provides the historical OI (Open Interest) candles for Options?

  2. Is there a limit on how many days of intraday OI data I can fetch?

Hey @Anand_Dabhi ,

To fetch historical OI data for an options contract, you can use our Expired Option Data API. This endpoint provides open, high, low, close, implied volatility, volume, open interest, and spot information as well

You may check the same here Expired Options Data - DhanHQ Ver 2.0 / API Document

Also, you can fetch up to 5 years of data using this Expired Option endpoint.

1 Like

Thank you

Hi, is it possible to fetch historical option chain data for contracts which have not yet expired but they have been live for a few days from the Expired Options Data API or is there another end point for it?

Hi @ps24 ,

You will be able to fetch data for all active option contracts, as the data works on a rolling expiry basis. Just keep in mind that expiry selection is done using three codes:

  • 1 → Near expiry

  • 2 → Next expiry

  • 3 → Far expiry

These automatically adjust based on the date you choose. For example, if you select a date between 27th and 30th November, expiry code 1 will correspond to the nearest expiry during that period, followed by 2 and 3 for the next and far expiries respectively.

Thanks!