Summary
I am using the Dhan Data API (Data APIs plan is active) with the official DhanHQ-py client.
For NIFTY Index (security_id = 13, exchange segment = "IDX_I"), both option chain expiries and intraday historical data calls are consistently returning a failure dict with JSON parse errors, even during live market hours.
This makes it impossible to fetch NIFTY option chain or intraday candles via Data APIs.
Environment
- Library:
DhanHQ-py (latest from PyPI, v2.x)
- Auth:
client_id + access-token (Data API subscription)
- Instrument: NIFTY Index
security_id = 13
exchange_segment = "IDX_I"
instrument_type = "INDEX"
Code to Reproduce
import os, json
from dhanhq import dhanhq
from dotenv import load_dotenv
load_dotenv()
CLIENT_ID = os.getenv("DHAN_CLIENT_ID")
ACCESS_TOKEN = os.getenv("DHAN_ACCESS_TOKEN")
dhan = dhanhq(CLIENT_ID, ACCESS_TOKEN)
# 1) NIFTY option chain expiry_list
expiries = dhan.expiry_list(13, "IDX_I")
print("expiry_list raw:", type(expiries), expiries)
with open("nifty_expiries_raw.json", "w") as f:
json.dump(expiries, f, indent=2)
# 2) NIFTY intraday minute data
intraday = dhan.intraday_minute_data(
security_id=13,
exchange_segment="IDX_I",
instrument_type="INDEX",
from_date="2025-12-20", # example trading day
to_date="2025-12-20"
)
print("intraday raw:", type(intraday), intraday)
with open("nifty_intraday_raw.json", "w") as f:
json.dump(intraday, f, indent=2)
======================================================================================
### **Actual Output**
For expiry_list(13, "IDX_I"):
python
{'status': 'failure',
'remarks': 'Extra data: line 1 column 5 (char 4)',
'data': ''}
For intraday_minute_data(...):
python
{'status': 'failure',
'remarks': 'Expecting value: line 1 column 1 (char 0)',
'data': ''}
So instead of a list of expiries or a list of OHLCV records, the SDK returns a single dict with status: failure and a JSON parse error in remarks.
### **Expected Behaviour**
expiry_list(13, "IDX_I") should return a list of expiry objects for NIFTY Index, as per the v2 option-chain documentation.
intraday_minute_data(...) should return a list/iterable of intraday OHLCV records for the requested date range.
### Notes / Questions
- Is this a known issue with the underlying /v2/optionchain/expirylist and historical data endpoints for Data API users?
-
- Has the response format changed (e.g. wrapped in another JSON field) and not yet updated in DhanHQ-py?
-
- Could you please share:
-
- A working curl example for NIFTY option chain expiries (v2)
-
- A working intraday historical example for NIFTY Index
-
- so that I can test against the raw HTTP response and update my scripts accordingly?
-
Thanks.
Summary
I am using the Dhan Data API (Data APIs plan is active) with the official DhanHQ-py client.
For NIFTY Index (security_id = 13, exchange segment = "IDX_I"), both option chain expiries and intraday historical data calls are consistently returning a failure dict with JSON parse errors, even during live market hours.
This makes it impossible to fetch NIFTY option chain or intraday candles via Data APIs.
Environment
DhanHQ-py(latest from PyPI, v2.x)client_id+access-token(Data API subscription)security_id = 13exchange_segment = "IDX_I"instrument_type = "INDEX"Code to Reproduce