Update for API Traders: New Changes in DhanHQ API Authentication Process and Updates

@Hardik after setting up the api key can i continue from the next time by simply generating the access token or should i do this process every time after the expiry. Just wanted to know the best process involved with lesser human intervention

1 Like

ISP in India does not provide static IP in basic plans and it chargeble also. We are already paying for data, brkerage and taxes. Better to stop trading. SEBI is to get fine from market manupulators.
@dhan whatever you do, keep it simple for retail traders.


am i making any mistake in checking the AAAA records ? could you please help ?

You can get a free cloud server from Oracle. It will have a free static IP. Problem solved :slightly_smiling_face:

1 Like

I too hit this issue. @Hardik , this should have been documented.

I too I am hitting this issue.

Further checking tells me that size of access token generated using api key and secret key is short few bytes when compared with the one generated using dhan web. @Hardik Is this expected?

1 Like

One more point to add when i tried today morning with same payload using api token alternate requests are being successful but few of them are failing due to invalid input. I think its some cache issue at server level please check it.

Note: I am validating it with the api’s which do not have payload like positions i am facing the same error here too

This is expected

@Hardik
How to use totp using python for api keys based authentication?

h tt ps: // dhanhq . co/ docs/v2 / authentication

I assume, we don’t need step1 and step2 , because instead of tokenId, we will need totp for step3.
But step3 url, doesn’t mention anything about totp. It only mentions tokenId.

What’s the post url to use totp based authentication with api keys?

same issue, new access code seems working with python but with c++ old access token works but not the new token generated thru apikey

Okay, thanks. Now seems to work.

@Hardik I am using 1Cliq. Do I need to do register Static IP with dhan for my account?

I was able to get token but orders are not getting placed.
Can you give me a simple script which would use token and send an order to Dhan? I will study it and make changes to my bot.

I unable to generate OTP for TOTP activation from dhan web. What is happening? I was expecting Dhan to respond to user queries today as it is very close to Oct 1st but this transition is becoming a nightmare. Emails to help at dhan dot co too is not getting them to respond.

1 Like

Where did you get the URL from? I feel documentation is bare minimum and does not provide end to end clarity of the process at all. @Hardik please help here.

1 Like

@Hardik

I am a small Algo developer who does trading for myself, 5-10 trades a day. I use Google Script which runs 24/7 automatically from Google cloud, gives order and gets report using Dhan trading API. It automatically send notification using telegram. Till this time I used to access Google sheet ones in a month to change the access token, since you changed duration to 24 hours, now I generate access token using mobile, copy that and paste in google sheet using mobile on the go. Sometimes I use laptop as per my convenience. In future I will store access token using telegram itself, hence Google sheet is not at all required to be accessed. Using your API key I can generate access token with refresh method, every day, automatically, but as per your customer care it is not yet supported. Now how your static API will come in to effect. I am OK with the speed or facilities I am getting. In this scenario no way static IP is useful or required.
Please confirm can I continue with present system or I have to close the Dhan Account.

1 Like

Boss but it very difficult to manage static IP, i normally use wifi,
Please suggest how can i manage

@Hardik

I was able to get access token via api key method, but non of my stgs are able to send orders.

{ “errorType”: “Input_Exception”, “errorCode”: “DH-905”, “errorMessage”: “Missing required fields, bad values for parameters etc.” }

I have wasted lot of time troubleshooting this.
I am now planning to move my algos to Zerodha as I have well established login process and glitch free process for getting the token etc.
Even you web login cannot be automated because of your QR code based login process else I could have easily automated the process of getting token on daily basis.
make things user friendly and not just good looking.

Hi, you are mistaking static ip with wifi. Static IP in this trading sense is your public ip address which is assigned to your router by you ISP.