Connect Dhan to AlgoCrab — Complete Setup Guide
Complete DhanHQ API setup guide for AlgoCrab: Client ID, access token, verification, first strategy, best practices, options algo tips, and troubleshooting.
AlgoCrab Team · Published 10 July 2026 · 14 min read

Dhan + AlgoCrab overview
Dhan's developer stack (DhanHQ) is popular with active F&O traders. AlgoCrab integrates Dhan for connect, orders, positions, holdings, funds, historical data, and live market data — one of the more complete broker implementations on the platform.
Unlike Zerodha's OAuth redirect, Dhan connection is typically token-based: you provide Client ID and Access Token from the Dhan developer portal.
Dhan's API supports order placement, position management, holdings, funds, historical data for backtesting, and live market data streaming — making it one of the most complete broker integrations on AlgoCrab.
Prerequisites
Active Dhan trading account with API access enabled.
Client ID and Access Token from Dhan's developer documentation / portal (see https://dhanhq.co/docs/latest/).
AlgoCrab account ready to open Connect Broker → Dhan.
A plan for token refresh if Dhan rotates access tokens on a schedule — expired tokens stop live algos.
Step 1 — Create DhanHQ credentials
Log in to Dhan's developer section and create or view your API application.
Copy Client ID and generate/copy the Access Token as per Dhan's latest UI.
Screenshot placeholder: [Screenshot: Dhan developer portal API credentials].
Store tokens offline. Never embed them in public TradingView scripts.
Step 2 — Connect Dhan inside AlgoCrab
Go to Connect Broker → Dhan.
Paste Client ID and Access Token into the form. Screenshot placeholder: [Screenshot: AlgoCrab Dhan connect form].
Submit and wait for a successful connection state.
No OAuth browser hop is required for the standard Dhan token flow on AlgoCrab.
Step 3 — Verify the connection
Open Broker Panel: confirm funds/margin.
Load order book and positions — empty books are OK.
Optional: place and cancel a safe limit order to confirm routing.
Screenshot placeholder: [Screenshot: AlgoCrab broker panel with Dhan connected].
Step 4 — First strategy on Dhan
Backtest a simple options or futures rule on liquid index instruments.
Enable stop-loss / target fields before Start.
Start with minimal lots. Watch rejects related to margin or freeze quantity.
Dhan's modify-order support on AlgoCrab helps when you need controlled amendments — still prefer strategy-level exits over manual chaos.
Best practices for Dhan algo trading
Dhan users often run options algos — ensure margin checks are enabled before live deployment.
Keep API rate limits in mind when running multiple strategies on the same account.
Dhan's API supports order placement, positions, holdings, funds, historical data for backtests, and live market data — one of the most complete integrations on AlgoCrab.
For options traders: Dhan's modify-order support on AlgoCrab helps with controlled amendments — still prefer strategy-level exits over manual order management.
If you also trade on Zerodha or Angel One, AlgoCrab's multi-broker dashboard lets you assign strategies per broker and manage capital allocation deliberately.
Common errors and fixes
401 / auth failures: Regenerate Access Token and reconnect.
Rate limits: Reduce parallel strategies or polling intensity.
Symbol mapping issues: Select instruments via AlgoCrab search so Dhan tokens map correctly.
Historical fetch timeouts: Large history jobs can take time; retry off-peak if needed.
Token expiry: Follow Dhan's documentation for token refresh — AlgoCrab handles session management once initial connection succeeds.
FAQs
Q: Is Dhan better than Zerodha for algos? A: Depends on brokerage, margins, and your workflow. AlgoCrab supports both — compare brokers, not just platforms.
Q: Can I run Dhan and Zerodha together? A: Yes. Multi-broker is a core AlgoCrab use case — connect both and assign strategies carefully.
Q: Does Dhan require static IP? A: No, Dhan works without static IP for most use cases. Check Dhan's latest API docs for any changes.
Disclaimer
Educational broker integration guide — not investment advice. Confirm DhanHQ terms and token policies on official docs.


