Is there any ongoing issue with the API/SDK regarding historical data? Today, my code failed to fetch intraday/historical data for indices (like Nifty and BankNifty), returning a DH-905 error (“Missing required fields, bad values for parameters etc.”), whereas the F&O segment data fetched without any issues.
Could you please confirm if anything changed for index parameters or if there’s a temporary glitch?
Hi @pawanyadavdelhi .
The following code contains the required parameters to fetch data for the indices. Use the same parameters and code to avoid missing any required parameters.
Do run the command on the cmd terminal -
pip install dhanhq==2.2.0
pip install Dhan-Tradehull==3.2.2
Refer this code -
from Dhan_Tradehull import Tradehull
client_code = ""
tsl = Tradehull(client_code, mode="pin_totp", pin="", totp_secret="")
hist_data = tsl.get_historical_data(tradingsymbol="NIFTY",exchange="INDEX",timeframe="1")
print("NIFTY : ",hist_data)
hist_data = tsl.get_historical_data(tradingsymbol="BANKNIFTY",exchange="INDEX",timeframe="1")
print("BANKNIFTY : ",hist_data)
Output

not possible with dhanhq only? i dont use tradehull the code was working fine till yesterday
the code is working fine now, it was probably a server issue yesterday?
Hi @pawanyadavdelhi
Thanks for bringing this up. @Tradehull_Imran may be able to assist here
Hi @pawanyadavdelhi ,
Share your code so that it can be reviewed and the necessary changes can be provided.
Hi @pawanyadavdelhi ,
The error you raised is caused by the exchange segment , we need to use INDEX - IDX_I and Equity - NSE_EQ