DHAN API · DHANHQ API
One API for Dhan and every other broker
Looking at DhanHQ API? Connect Dhan to Quantsapp and use one REST + WebSocket API for it and 19 other brokers - every account, every order update on one socket, and code that survives broker changes.
- REST + WebSocket
- Python SDK
- 20 brokers
- Multi-account
- NSE F&O
ex.place_order( accounts=[A, B], legs=[...])WHY ONE API
Every broker API is different. Yours doesn’t have to be.
Integrating broker APIs yourself
- A different login, order format and error codes for every broker
- A separate order-update stream for each account
- Positions merged by hand across accounts
- Code breaks when a broker changes its packets
- Changing brokers means a new integration
With the Quantsapp Orders API
- One login, one order format, one set of responses
- Every update from every account on one WebSocket
- Combined positions and order status in one call
- Broker changes handled by Quantsapp
- Change brokers by changing one value
| DhanHQ API directly | Through Quantsapp | |
|---|---|---|
| Brokers covered | Dhan only | Dhan + 19 other brokers |
| Several accounts | Each account separately | All accounts in one request |
| Order updates | A stream per account | One WebSocket for every account |
| If the broker changes its API | You update your code | Quantsapp absorbs the change |
| Changing brokers later | Write a new integration | Change one value |
WHAT YOU GET
Built for algo traders and multi-account order management
One API, every broker
The same requests and responses for all 20 brokers. No broker SDKs, no broker-specific order formats.
REST and WebSocket
Every call over REST (HTTP/1.1, 2 and 3) or over a WebSocket - pick what suits your latency and stack.
One socket for every update
Order updates from all your accounts, at every broker, arrive on a single WebSocket, tagged with the account.
Many accounts, many brokers
Several accounts with the same broker - yours and your family’s - and accounts across brokers, side by side.
Place once, everywhere
One place-order request goes to several accounts at once, with its own lot multiplier for each.
Combined positions
Get positions account by account or combined, and order status for all accounts, without stitching broker responses.
Multi-leg with margin benefit
Send a whole strategy in one request; buy legs can go first so the hedge margin applies to the sell legs.
Broker changes? Not your problem
When a broker changes its packets or endpoints, Quantsapp absorbs it. Your code keeps working.
Switch brokers, keep your code
The broker is one value in the account id. Move brokers and the rest of your integration stays as it is.
A FEW LINES
One order, two brokers, one stream
Log in with your API key, place a two-leg spread in your Dhan account and a second account with different lot multipliers, and receive every order update on one callback.
import quantsapp
session = quantsapp.Login(
api_key="<API_KEY>", secret_key="<SECRET_KEY>",
).login()
# Every order update, from every account, arrives here (one socket)
def on_update(update):
print(update)
ex = quantsapp.Execution(
session_context=session, order_updates_callback=on_update,
)
v = ex.variables
# One bull call spread, placed in two accounts at two brokers
ex.place_order(
broker_accounts=[
{"broker": v.Broker.DHAN, "client_id": "<CLIENT_1>", "lot_multiplier": 1},
{"broker": v.Broker.ZERODHA, "client_id": "<CLIENT_2>", "lot_multiplier": 2},
],
exchange=v.Exchange.NSE_FNO,
product=v.Order.ProductType.NRML,
order_type=v.Order.OrderType.LIMIT,
validity=v.Order.Validity.DAY,
margin_benefit=True, # buy legs go first
legs=[
{"qty": 65, "price": 120.5, "instrument": "NIFTY:27-Oct-26:c:23200", "buy_sell": "b"},
{"qty": 65, "price": 62.0, "instrument": "NIFTY:27-Oct-26:c:23400", "buy_sell": "s"},
],
)curl https://tradeapi.quantsapp.com/v1/order/place_order \
--request POST \
--header "X-API-Token: <JWT_FROM_LOGIN>" \
--header "Content-Type: application/json" \
--data '{
"accounts": { "dhan,<CLIENT_1>": 1, "zerodha,<CLIENT_2>": 2 },
"exchange": "NSE-FO", "product": "nrml", "order_type": "limit", "validity": "day",
"settings": { "margin_benefit": true },
"legs": [
{ "qty": 1, "price": 120.5, "symbol": "NIFTY", "segment": "o", "opt_type": "c",
"expiry": "27-Oct-26", "strike": 23200, "buy_sell": "b" },
{ "qty": 1, "price": 62.0, "symbol": "NIFTY", "segment": "o", "opt_type": "c",
"expiry": "27-Oct-26", "strike": 23400, "buy_sell": "s" }
]
}'- zerodha,110073SELL 130 · NIFTY 27-Oct 23400 CEpartial
- dhan,AB1234SELL 65 · NIFTY 27-Oct 23400 CEplaced
- zerodha,110073BUY 130 · NIFTY 27-Oct 23200 CEcompleted
- dhan,AB1234BUY 65 · NIFTY 27-Oct 23200 CEcompleted
ONE WEBSOCKET
Every order update, from every account, in one place
Fills, partial fills, rejections and cancellations from all your accounts - at every broker - stream on a single socket, each tagged with its broker account. No per-broker sockets to keep alive, no polling.
Orders placed through the API also show in the Quantsapp app, next to everything else.
USE IT FOR
Who it’s for
Algo traders
Run your strategy in your own code and let the Orders API handle execution, order status and positions for every account.
Family and multiple accounts
Place the same trade in all your accounts with one request, and see their orders and positions together.
Traders with more than one broker
Keep one integration while you trade with several brokers - or move between them.
GET STARTED
From sign-up to first order
- Connect your brokersIn Quantsapp, Trade → Brokers: connect Dhan and any other accounts (guided video for each broker).Connect a broker →
- Get your API keyCreate your API key and secret in Quantsapp. Keep them private.Create API keys →
- Set up a static IPNeeded to place orders: Quantsapp’s shared IP from ₹250/month + GST, or your own.
- Write your codepip install quantsapp, or call the REST and WebSocket endpoints from any language.API docs →
PRICING
Pay per order, or go unlimited
Covers NSE F&O for now. Reading orders, positions and order updates needs no static IP.
Write it once. Trade it with every broker.
Connect your broker, create your API key and place your first order through the Orders API.
Frequently asked questions
Is this the official Dhan API?
No. Dhan’s own API is DhanHQ API. Quantsapp connects to your Dhan account through Dhan’s official API and gives you one Orders API on top - the same code for Dhan and 19 other brokers. Orders go to your own Dhan account. Dhan is a trademark of its owner.
Why use Quantsapp instead of DhanHQ API directly?
If you only ever trade one Dhan account, the broker’s API may be enough. Quantsapp helps when you have several accounts or brokers, want one order-update stream for all of them, combined positions, or code that keeps working if Dhan changes its API or you change brokers.
How do I connect my Dhan account?
In Quantsapp, go to Trade → Brokers and connect Dhan (there is a guided video for each broker). Then create your API key and secret on the Orders API keys page in Quantsapp and log in to the API with them.
Do I need a static IP?
Yes, to place orders. SEBI rules require orders sent through an API to come from a static IP. Quantsapp’s shared static IP costs ₹250/month + GST per broker (a dedicated IP is ₹750/month + GST), or you can use your own. Reading orders and positions needs none.
What if my broker changes its API?
Quantsapp handles it. Your code talks to one Quantsapp format, so when a broker changes its packets or endpoints, the change is absorbed on Quantsapp’s side and your code keeps working.
Can I switch brokers without rewriting my code?
Yes. The broker is just part of the account id ("broker,client_id") in your requests. Connect the new broker, change that value, and the rest of your code stays the same.
How much does the Orders API cost?
₹20 per successful order placed through the API, or unlimited orders for ₹1,499/month on the yearly plan (₹2,999 on the monthly plan). Placing orders also needs a static IP (from ₹250/month + GST).
Which markets does it cover?
NSE F&O (futures and options on NSE) for now.
Is there a Python SDK?
Yes - pip install quantsapp. It is open source on GitHub and covers login, orders, positions and the live order-update stream. The REST and WebSocket docs also include JavaScript examples.
Broker names are trademarks of their owners and are used only to identify the brokers Quantsapp connects to. Derivatives trading carries substantial risk. Disclaimer