Features
Now, let’s take a look at how to add Dhan account in Stocks Developer.
Letβs understand how to add a Dhan account in AutoTrader Web.
AutoTrader Web uses Dhan trading APIs which are complete FREE.
Demo
Platforms
Dhan broker has two methods of API login which is represented by two different platforms given below:
- DHAN_V2_AT_IPV6
- Requires one time setup & it does auto-login every day (recommended platform)
- Problems: Sometimes it fails to login due to unreliable login apis of Dhan (See Common Issues)
- If you see login errors, you can temporarily switch to βDHAN_V2_IPV6β platform
- The login issues have been reported multiple times to Dhan; but they did not fix it
- DHAN_V2_IPV6
- Requires you to everyday manually generate access_token in Dhan & copy it into our system
- Use it when you face issues with automated login platform (DHAN_V2_AT_IPV6)
- Note: The system is designed to auto-generate tokens for this platform as well. So every morning you can click Validate All button to check if your token is regenerated. Only if you observe failure, then you need to manually generate token.
Platform 1: DHAN_V2_AT_IPV6
Step 1 – Generate API Key
- Login to Dhan trading website
- Open menu on top right by clicking your profile picture
- Click Dhan HQ Trading APIs
- By default, it shows you “Access Token“. You need to switch to “API key” by clicking the toggle button.
- API Details:
- Application Name: MyTradingApp
- Redirect Url: https://webx.stocksdeveloper.in/auth/dhan
- Postback Url: https://apix.stocksdeveloper.in/postback/dhan
- Click Generate API Key (See screenshots below)
- Static IP
- API screen has an option to setup static IPs
- See Step 3 below to understand how to get primary & secondary static IP
- Register both primary & secondary static IP with Dhan
Step 2 – Setup TOTP
The same API page has an option to setup TOTP.
- Enable TOTP
- Scan the QR code in your authenticator app like “Google Authenticator”
- Important: Copy the TOTP Key (long 15 to 30 random characters)
- Save TOTP Key as we will need it in next step
- Click Enable TOTP button
Step 3 – Add your Dhan account
- Go to AutoTrader Web menu (Settings -> Trading Accounts)
- Click Create button
- Select Broker as Dhan
- Select Platform as DHAN_V2_AT_IPV6
- Dhan Client ID
- Click Auto Assign IP button to get your static IP
- MPIN
- TOTP Key
- 10 digit Phone number registered with Dhan account
- API Key (shown on Dhan API screen)
- API Secret (shown on Dhan API screen)
- Give a nickname
- Click Validate & Save
- Thatβs it, you have successfully added your Choice account. Do not forget to read these known limitations.
Screenshots
Platform 2: DHAN_V2_IPV6
Step 1 – Generate Access Token
- Login to Dhan trading website
- Open menu on top right by clicking your profile picture
- Click Dhan HQ Trading APIs
- By default, it shows you “Access Token“.
- API Details:
- Application Name: MyTradingApp
- Postback Url: https://apix.stocksdeveloper.in/postback/dhan
- Click Generate Access Token
- Static IP
- API screen has an option to setup static IPs
- See Step 2 below to understand how to get primary & secondary static IP
- Register both primary & secondary static IP with Dhan
Step 2 – Add your Dhan account
- Go to AutoTrader Web menu (Settings -> Trading Accounts)
- Select Broker as Dhan
- Click Create button
- Select Platform as DHAN_V2_IPV6
- Dhan Client ID
- Enter Access Token
- Note: Access token expires everyday, remember to re-generate every morning and update
- Give a nickname
- Click Validate & Save
- Static IP:
- Edit your account
- Click Auto Assign IP button to get your static IP
- Register both primary & secondary static IP with Dhan
- Thatβs it, you have successfully added your Choice account. Do not forget to read these known limitations.
Common Issues
Here are some common errors faced on Dhan broker
- Login failed: Error from Dhan: [DH-906 – Invalid Token]
- Login failed: Please regenerate the API token on Dhan & update in our system
- Login failed: Error from Dhan: TOTP Validation Failed: [RS-0060] Too many requests, please try again after some time
- Login failed: Error from Dhan: Dhan Consent API Failed: [CONSENT_LIMIT_EXCEED] Consent limit Exceeded
Solution
If you observe any of these errors, then please switch the Dhan’s ‘DHAN_V2_IPV6‘ platform which requires you to manually generate ‘access_token’ everyday and update it in our system.
This is explained in the beginning of the demo video given below.