DhanHQ Superfast Trading APIs Update: Trading APIs are now FREE for all

Hi All,

We have an super update on our superfast trading APIs - DhanHQ (www.dhanhq.co)

We have received sincere appreciation from the trading community and technology companies for DhanHQ: Superfast trading APIs, since the day we launched. Our engineering team is very proud of the fact that some of our partners have integrated trading APIs in less than 5 days.

While designing the APIs, we were very sure of the user persona - geeks, algo & systematic traders. As a technology first company that is building Dhan as its trading & investing platform - we understand this better than most folks. Hence, we not only came up with clear-crisp API documentation but with a developer kit where one can try & hit the APIs, validate the same and integrate faster.

When we launched, we kept our Open APIs free of cost and we did not charge anything. However, to make sure that these trading APIs are consumed by serious traders only, we kept an eligibility criterion of 25 executed orders in the last 30 days. The segments that qualify for this criterion are futures, options, currency & commodities. So whoever fulfils this eligibility, can generate an access token from web.dhan.co. Follow these steps to generate a token- My Profile >> DhanHQ Trading APIs >> Access Token.

While we had our own rationale behind keeping this eligibility criteria, many of our users queried and questioned the eligibility criterion. One of the most asked and valid ones was that users trade only in the equity segment, so how can they access APIs? Very valid, and we acknowledge that with a solution that solves this.

Here we are with an update:

Starting today, we have provisioned our APIs into two sections:

  1. Trading APIs for trade execution
  2. Data APIs for data consumption

Trading APIs include Order Placement, Orderbook & Tradebook, Positions, Portfolio, Funds, etc. All the APIs are directly related to the user’s trading and account. We have removed the eligibility criteria of 25 trades. These Trading APIs are now accessible to all the users from day-1 of account opening and are completely free of cost. These are the APIs related to the user’s trading account and all activities & data belong to the user.

Data APIs include historical data & market feeds data (coming soon). This data is related to exchange. This requires heavy infrastructure to maintain at our side. For this, users still need to fulfill the eligibility criterion of 25 order execution in the last 30 days to get it free. We have also kept the option to pay INR 499 per month for non-eligible users. If the Data APIs are free, it is subject to misuse, hence we want to be sure the same is consumed by serious users only. For a regular and serious trader, executing 25 orders in the last 30 days should be easy. We feel if anyone is not executing 25 orders in the last 30 days, there is no direct trading use-case for Data APIs.

There is more news for DhanHQ superfast trading APIs - we will be soon launching more APIs for special order types. This means, you will have APIs for:

  • Basket Order APIs
  • SIP in Stocks APIs
  • Forever Order APIs (GTT)
  • Draft Order APIs

We feel that more and more users will opt for algo / system based trading in the coming days, and hence as a technology first trading platform - we want to ensure we do our best to help the most advanced super traders who want to build trade execution systems on top of our APIs.

For all of us at Dhan, building an incredible product experience is a journey by choice and we want to Raise the Bar for investing & trading products in India.

Happy Trading!


Algo trading platforms are costly.
Only professional traders can use that.

If DHAN Option trader app can add some algo functions (Programed trade) it will helpful for Option trading.

Great news. How do I get access to trading APIs and can we use it to trade in cash and derivatives segment both?

Hi @anilmm2005

We have same APIs for trading in cash or derivatives segments, so yes - its free for both. To get access, on web.dhan.co please request for access under the My Profile section > Dhan APIs on left menu.

You will get access with option to create Access Tokens in a few minutes

Thanks for the prompt response @PravinJ . I have created the same. will explore the same soon

Hi, I was just checking the python based example on api. When I am executing the code given as example from my computer it takes very long time (2-3 minutes). Am i using a wrong way? I just used the order details api.

It takes a sec or so to execute at my end here. Something might not be proper at your end. kindly check once

Hi @gudiya Priyanka
The python based example on api.dhan.co is just for reference. You need to write your own python code with reference on this link. The API based trading is faster than any other platform, it takes less than a second to successfully execute order. After you reported, we tried at our end and it is working fine. Can you please optimise system at your end. Let us know for any help.

hi, I am trying to build the algo. However, other things are fine. How to get the trading symbol and security id. In API docs I could not locate it. Please guide.

Hi @gudiya

You can find the scripmaster in API Documentation under the description of parameters >> securityID

Here is the screenshot for your reference.

FYI- All our APIs are mapped with security ID. This scripmaster gets updated every day in the morning.

I am facing issues of excessively high time lag for any request for dhan python api for two system( one widows and another ubuntu). However, in my one of the windows system it is very fast. Not able to figure out why this is happening. This is something to do with requests.
I did not face any issues for accessing any other website through python requests. Even zerodha is working fine, even fyers is working fine.
Is the python requests for dhan api are designed differently? Attaching a screenshot for the time taken for accessing the holding. It took more than 6 minutes. (time taken is mentioned at the last line of the screenshot). I have removed headers from the screenshot for security.

Hi @gudiya

Almost similar issue was reported by few more developers in the past. We went through the logs and found that the time taken by our system to respond once the request is received is in milliseconds. Almost all the time is consumed in sending the request. We asked the users to go through the code. To verify, you can send the curl command request from server and observe the time diff.

Let us know, how this is working.

@Naman @Dhan_Help @PravinJ

Is it possible to create baskets programmatically and place basket orders using DhanHQ API ?

Is it possible to execute orders with “tradingSymbol” with out mentioning “securityId” ? “tradingSymbol” can be generated from code automatically. But for “securityId” we need to keep looking at the scrip master everyday.

Yes checked with curl. it is working fine.
Writing wrapper to call curl commands from python. Thanks for the help.

@Naman @Dhan_Help @PravinJ any thoughts on these would be great.

Hi @t7support

Basket Order API : Though you can create the basket programmatically and execute it via Dhan API now, but soon we are also coming up with the API specific to basket order.

We have your feedback with us on ‘tradingSymbol Vs securityId’ . We have purposely mapped all our APIs with security Id because it is standard for all the platforms as these are provided by exchange.

@gudiya wrappers are good idea. But for now we have come up with official Python library on PyPi. Here is the link for your reference- dhanhq · PyPI

I tried the dhanhq library. The same issue of large lag is there in library too.

Hi @gudiya
We want to connect with you on brief video call. Please send me your email Id at feedback@dhan.co or DM me here.

Thanks. A decade ago when I was trading with Interactive Brokers API they needed just the symbol name to trade and it was very convenient. Just like we search symbol name in Dhan app and place trade. We don’t need to find a security ID and type in. Scanning an excel file to find the security ID is an extra step that could be avoided. So can you please modify the API to facilitate trading via API with just tradingsymbol ?

@Naman @Dhan_Help

what would be the correct data json for placing an option order let’s say for “BANKNIFTY08SEP2239700CE” with security ID 46461. On your docs only equity example is given. Tried few things but it isn’t working yet on options for me.