Skip to content

India · Broker API

Build a Dhan API trading bot with your AI coding agent.

Super Algo Kit helps you build a Dhan API algo trading bot on DhanHQ v2 inside your own AI coding agent. DhanHQ covers NSE, BSE and MCX, and Dhan account holders get the trading APIs free. Tokens last 24 hours, and since 1 April 2026 order calls need a whitelisted static IP. The kit paper tests first; live waits for your authorize command.

Dhan (DhanHQ API v2) logo

broker facts

Dhan (DhanHQ API v2)

What it is
Dhan's REST API with a market feed, order-update streams, super orders and forever orders.
Markets
NSE and BSE equity, derivatives and currency, plus MCX commodities.
Login
24-hour tokens from the web app, a TOTP call, or an API key (valid 12 months) with a browser step.
Static IP
Needed to place, modify and cancel orders. After a change, it cannot be edited for 7 days.
Paper option
A sandbox is reported, shaped like the live API but with no streaming or real-time quotes.
Order limits
10 a second, 250 a minute, 1,000 an hour and 7,000 a day. 25 modifications per order.
API cost
Trading APIs free for Dhan users. Data APIs cost extra; the amounts are not confirmed by the kit.

From the kit's Dhan card, checked 2026-09-30. Confirm current terms on Dhan's own site.

Paper first

A Dhan bot, built paper first.

Super Algo Kit runs inside the coding agent you already use. It interviews you, writes the spec with pass marks set first, then builds, backtests and paper-tests. Real money starts only when you type the authorize command.

Type this in your coding agent
Build me a pivot breakout bot for Dhan that buys in-the-money NIFTY options. Paper only.

The plan, step by step

Tick them off as you go.

How Dhan API access and login work

Dhan gives you three ways to get an access token. Generate one in the web app, call a TOTP method, or use an API key with a browser consent step. Each token lasts 24 hours from the moment it is made.

Scripted TOTP login is allowed for your own account, because Dhan documents it for API-only flows. Keep the PIN and TOTP seed in a secret store, never in the repository or chat. Platforms that serve other users apply to Dhan as partners.

Static IP for Dhan API algo trading

Since 1 April 2026, Indian brokers accept API orders only from a registered static IP. Dhan requires one to place, modify and cancel orders, super orders and forever orders; fetching orders needs none. You set primary and secondary IPs in the web app or through the API, as IPv4 or IPv6.

Each person needs a unique static IP, and after a change it cannot be edited for 7 days. Run the bot at home only if your provider gives that line a static IP, or rent a server. Backtests and paper trading send no orders, so they need no static IP. This is a summary, not legal advice.

Can you paper trade with Dhan?

A Dhan sandbox is reported, open without a Dhan account, with trading and data APIs shaped like the live ones. It has no streaming data, no real-time quotes and no realistic fills or slippage. Use it to test order flow and error paths, not strategy results.

For strategy results, Super Algo Kit uses its own paper trading, which sends no orders to Dhan. Paper first, live only when you say.

Dhan API limits and costs to plan for

These are Dhan's documented limits as the kit read them on 30 September 2026. The docs do not say whether order limits count per key, IP or account.

  • Order APIs: 10 a second, 250 a minute, 1,000 an hour, 7,000 a day.
  • At most 25 modifications per order.
  • Data APIs: 5 a second and 100,000 a day. Quotes: 1 a second.
  • Market feed: 5 connections per user, 5,000 instruments each.
  • Trading APIs are free; data APIs carry extra charges shown on Dhan's platform.

What Super Algo Kit does with DhanHQ

The kit puts every call behind its own adapter, even though the official Python client is MIT-licensed. Your agent never holds your live keys or places live orders.

  • Makes a fresh token each day and waits in a clear state if that fails.
  • Redacts addresses in logs, because the TOTP call and feed address carry secrets.
  • After a timeout, looks the order up by its client tag before any resend.
  • Treats an order still in transit as undecided, never as a rejection.
  • Reads the registered IP at start-up and blocks orders on a mismatch.
  • Caps order messages at 5 to 8 a second, with a risk gate and kill switch.

Before you rely on it

Gotchas to plan for.

  • A token lasts 24 hours from creation, not until a fixed clock time. Make a fresh one each morning.
  • Renewal works only for still-active tokens made in the web app.
  • The TOTP call and the feed address carry secrets; keep them out of logs and error reports.
  • Too many feed connections can escalate to a block, so back off with jitter when reconnecting.
  • Dhan's sandbox has no quotes, so no strategy can run start to finish there.
  • A newer Dhan documentation site exists; re-read it before release.

FAQ

Dhan: questions.

Is the Dhan API free for algo trading?

Dhan says individuals with a Dhan account get the trading APIs free. Its data APIs carry extra charges shown on the Dhan platform, and the kit has not confirmed the amounts. Super Algo Kit includes trading costs in every backtest.

Does Dhan have a sandbox for paper trading?

A Dhan sandbox is reported, open without a Dhan account, but it has no streaming data or real-time quotes. Use it for order-flow and error tests, not strategy results. Super Algo Kit's own paper trading sends no orders and needs no static IP.

Can I generate a Dhan access token with TOTP?

Yes. Dhan documents a TOTP token call for API-only flows, and each token lasts 24 hours. Super Algo Kit allows this for your own account only and keeps the PIN and TOTP seed in a secret store.

Do I need a static IP for Dhan API orders?

Yes, for live orders. Dhan requires a whitelisted static IP to place, modify and cancel orders. A changed IP cannot be edited again for 7 days. Super Algo Kit blocks a live release until your IP is registered.

Is Super Algo Kit affiliated with Dhan?

No. Super Algo Kit is not affiliated with or endorsed by Dhan. The name is used only to say the kit works with the DhanHQ API. You use your own Dhan account and keys.

Keep reading

More guides.

Dhan (DhanHQ API v2) and its logo are trademarks of their owner, used here only to say that Super Algo Kit can work with it. Super Algo Kit is not affiliated with or endorsed by Dhan. Super Algo Kit is development software. It is not investment advice, a signal service or a promise of performance. Trading involves substantial risk, including the loss of all capital you trade with.