Quick answer
DhanHQ is Dhan’s API for Indian markets: order placement, super orders, forever orders, portfolio and funds are free, while Data APIs (live feed, market depth, historical candles) need a monthly plan. You authenticate with your client id and an access token generated on web.dhan.co, where you also choose how long it stays valid.
Dhan (DhanHQ) API at a glance
- Pricing
- Trading APIs free; Data APIs on a monthly plan
- Availability
- Indian residents with a Dhan account
- Paper trading
- DhanHQ sandbox for testing order flows
- Integration type
- REST + API key
- In AlgoGP
- Design and backtest in AlgoGP, connect the exported code
- Auth
- Client id + access token header
- Trading APIs
- Free
- Data APIs
- Monthly subscription
- SDK
- Python
dhanhq
Build a Dhan (DhanHQ) strategy with AlgoGP
AlgoGP does not connect to Dhan (DhanHQ) natively yet. Dhan (DhanHQ) uses plain HTTPS with an API key, so it is a good candidate for a native adapter; it is not built in yet.
- 1
Design and backtest in AlgoGP
Describe the strategy to the copilot and backtest it on years of normalized history. The result does not depend on any vendor.
- 2
Export the Python project
Every project exports
strategy.py,market_data.py,brokers.pyandlive.py. The strategy only sees bars, cash, positions and orders, never a vendor’s wire format. - 3
Plug in Dhan (DhanHQ)
Implement the four adapter methods (
account,positions,submit_market_orderand a candle fetcher) with Dhan (DhanHQ)’s SDK, or keep a built-in platform for paper trading and add Dhan (DhanHQ) when you go live.
Built-in brokers for the same markets: Alpaca, Tradier, Interactive Brokers, OKX.
Dhan (DhanHQ) API: frequently asked questions
Is the Dhan API free?
Trading APIs are free; Data APIs require a paid plan.
How long does a Dhan access token last?
You choose the validity when generating it on web.dhan.co.
Design and backtest your Dhan (DhanHQ) strategy first
AlgoGP turns an idea into Python and tests it on years of history before you connect it to Dhan (DhanHQ). The exported code keeps the broker behind four small adapter methods.
- AI copilot writes and revises the rules
- Backtests with realistic costs
- Exported Python ready to wire to Dhan (DhanHQ)
Free plan, no card required.
Dhan (DhanHQ) alternatives
- Zerodha Kite Connect API GuideIndia’s largest broker: Kite Connect REST and WebSocket APIs for NSE, BSE and MCX, with an access token minted by a daily login.
- Upstox API GuideUpstox Developer API: free REST and WebSocket trading and market data for Indian equities and F&O, with daily OAuth tokens.
- Angel One SmartAPI API GuideAngel One’s free SmartAPI for Indian equities, F&O and commodities: log in with client code, PIN and a TOTP, then trade over REST.
- FYERS API GuideFYERS API v3: free trading, quotes and history for Indian markets, with an app id, secret and a daily OAuth access token.
Independent guide. AlgoGP is not affiliated with Dhan (DhanHQ). Limits, prices and availability change; confirm them in the official documentation. Nothing here is investment advice.