Algo trading with Dhan
Connect your Dhan account to MyAlgoMate and automate your execution — one-click orders, risk controls and fast exits, no coding required.
Connecting Dhan
MyAlgoMate connects to Dhan through Dhan's official DhanHQ API. You generate an API Key and Secret from your Dhan profile, subscribe to the Data API, whitelist a static IP as Dhan requires, and then enter your Client ID, API Key and API Secret into the broker login form in MyAlgoMate.
Use Dhan with
Your Dhan account works with all 6 of these MyAlgoMate products — plus custom automation of your own strategy.
- Stockmock and Algotest strategy automation tool (Time Based Straddle Strangle)
- Trademate
- Copy Trading Software
- TradeBridge
- Cloud Server for Algo Trading
- RMS Tool
- Custom strategy automation — your own logic, automated; you set the rules and stay in control.
Setting up Dhan
Step 1 — Generate your DhanHQ API Key and Secret
- Log in to web.dhan.co.
- Click My Profile and open Access DhanHQ APIs. If this is your first time, click Request Access.
- Toggle to API key and fill in:
- App name — e.g. MyAlgoMate
- Redirect URL — set it to http://web.dhan.co/
- Postback URL — optional, you can leave it blank
- Your API Key and API Secret are generated — copy both. They are valid for 12 months from the date you generate them, so set a reminder to renew before they expire.
- Note your Client ID as well — this is your Dhan client id, shown in your Dhan profile.
Step 2 — Subscribe to the DhanHQ Data API
- Dhan's Trading API is free, but MyAlgoMate needs live market data through Dhan, which comes from the Data API subscription — ₹499 plus applicable taxes per month, renewing every 30 days.
- The amount is debited automatically from your Dhan account, so keep sufficient balance. Dhan emails you a notification on each renewal.
Adding Dhan as a child account in copy-trading software? You can skip the paid Data API — Dhan's free API is enough for a child account. The Data API subscription is only required for the master account.
Step 3 — Register your static IP (mandatory)
Dhan requires a registered static IP for placing orders through the API (SEBI and exchange algo-trading guidelines). It applies to the order-placement APIs — orders sent from an IP that is not whitelisted are rejected with the error DH-905 Invalid IP.
- In Dhan web, add your static IP against your account. You can set up a primary and a secondary IP.
- Which IP to use: if you run MyAlgoMate on your own machine, use your ISP's static IP; if you run it on a cloud machine, use that cloud server's static IP.
- ⚠️ Once an IP is set up, you cannot change it for the next 7 days — double-check it before you save.
No static IP or cloud machine yet? Our Cloud Server for Algo Trading is a cloud machine specialised for algo trading, and it comes with its own static IP you can whitelist.
Step 4 — Enter the details in MyAlgoMate
- Open the broker login form in MyAlgoMate and enter your Client ID, API Key and API Secret, then save.
What you need to collect
To connect Dhan, the broker login form in MyAlgoMate needs three details:
- Client ID — your Dhan client id, shown in your Dhan profile
- API Key — generated under My Profile → Access DhanHQ APIs
- API Secret — generated alongside the API Key
Two more things are set on Dhan's side rather than entered here: your Data API subscription, and a whitelisted static IP.
About the Data API subscription
Dhan splits its APIs in two. The Trading API — used to place and manage orders — is free. The Data API, which provides live market data, is a paid subscription: ₹499 plus applicable taxes per month, renewing every 30 days. It is billed by Dhan (not by MyAlgoMate) and debited automatically from your Dhan account, so keep sufficient balance; Dhan emails you on each renewal. MyAlgoMate needs live market data from Dhan, so a master or standalone Dhan account needs this subscription.
One exception — copy trading: if you add Dhan as a child account in copy-trading software, its free API is enough, so no paid Data API subscription is needed for that child account. It is only required for the master account.
Static IP — required by Dhan
SEBI and exchange algo-trading guidelines require a registered static IP for API order placement. Add it in Dhan web — you can set a primary and a secondary IP. Orders coming from an IP that is not whitelisted are rejected with the error DH-905 Invalid IP, so check that your detected source IP matches the one you whitelisted. Use your ISP's static IP if you run MyAlgoMate locally, or your cloud machine's static IP if you run it on a server. Note that once an IP is set, you cannot change it for the next 7 days.
If you don't have a static IP, our Cloud Server for Algo Trading is a cloud machine built for algo trading and includes a static IP you can whitelist.
Redirect URL
When you generate the API key, set the Redirect URL to http://web.dhan.co/
Keep your keys private
Your API Key and API Secret are the keys to your own trading account — never share them with anyone. MyAlgoMate provides the automation technology; you set the rules and stay in control of your own trades.
Dhan — questions
Do I need a paid subscription to use Dhan with MyAlgoMate?
It depends on how Dhan is used. Dhan's Trading API is free, but its Data API — which provides live market data — is a paid subscription at ₹499 plus applicable taxes per month, renewing every 30 days and debited automatically from your Dhan account. A master or standalone Dhan account needs it. If you are adding Dhan as a child account in copy-trading software, the free API is enough and no paid subscription is needed.
I'm using Dhan as a child account in copy trading — do I still need the paid Data API?
No. When Dhan is added as a child account in copy-trading software, its free API is enough — you don't need the paid Data API subscription for that child account. It is only required for the master account.
What Dhan details does MyAlgoMate need?
Three: your Client ID, your API Key and your API Secret. You generate the API Key and Secret in Dhan web under My Profile → Access DhanHQ APIs, and enter all three in the broker login form in MyAlgoMate. Separately, you must whitelist a static IP on Dhan's side.
How long are my Dhan API Key and Secret valid?
Your DhanHQ API Key and Secret are valid for 12 months from the date you generate them. Set a reminder to regenerate them before they expire so your connection keeps working.
Do I need a static IP for Dhan API trading?
Yes — SEBI and exchange algo-trading guidelines require a registered static IP for API order placement. Add it in Dhan web; you can set a primary and a secondary IP. Orders from an IP that is not whitelisted are rejected with the error DH-905 Invalid IP. Use your ISP's static IP if you run MyAlgoMate on your own machine, or your cloud machine's static IP if you run it on a server. Once an IP is set you cannot change it for 7 days. If you don't have one, our Cloud Server for Algo Trading includes a static IP.
What Redirect URL should I set when generating my Dhan API key?
Set it to http://web.dhan.co/
Why are my Dhan orders rejected with DH-905 Invalid IP?
That error means the IP your orders are coming from does not match the static IP whitelisted on your Dhan account. Check the detected source IP against the one you whitelisted in Dhan web and make sure they match. Remember that once an IP is set, it cannot be changed for 7 days.
Automate on Dhan, the compliant way
Connect in minutes, automate without code, and stay in control — with a team that answers.

