Skip to content


Getting Started


DhanAPI is a state-of-the-art platform for you to build trading and investment services & strategies.

It is a set of REST-like APIs that provide integration with our trading platform. Execute & modify orders in real time, manage portfolio, access live market data and more, with lightning fast API collection.

We offer resource-based URLs that accept JSON or form-encoded requests. The response is returned as JSON-encoded responses by using Standard HTTP response codes, verbs, and authentication.

  Developer Kit
  Developer Kit
  DhanHQ Python Client
  DhanHQ Python Client


For Partners

Once the partner is onboarded through offline channel, Dhan team will share Partner credentials for Login. When the Dhan user, login to the partner’s application, the consent flow server-to-server and the partner gets the consent id. Partner has to put credentials in header. Thereafter, the partner starts browser based login flow. Dhan user login using Dhan credentials (email/phone/password/pin). Login flow terminates with redirection to partner server with token id. Finally, the partner shall fetch the user details and access token.


Partner need to add partner_id & partner_secret in the header. The response of this flow will have consent-id. Use this consent-id for the next browser based flow.


STEP 2:<consentId>

This flow will terminate on a partner's server with URL <partner-redirect-url>?tokenid= <tokenId>. Use this token-id in the next GET call.


STEP 3:<token-Id>

In this step, you need to add partner_id & partner_secret in header again.
This flow will end with end user details like ClientId, UCC, PoA status etc..


For Individual Traders

Individual traders can directly get their Access Token from All Dhan users are eligible to get free access to Trading APIs. Here's how to get your Access Token:

  • Login to

  • Click on My Profile and navigate to 'DhanHQ Trading APIs and Access'


All GET and DELETE request parameters go as query parameters, and POST and PUT parameters as form-encoded. User has to input an access token in the header for every request.

curl --request POST \
--url \
--header 'Content-Type: application/json' \
--header 'access-token: JWT' \
--data '{Request JSON}'

Install Python Package directly using following command in command line.

pip install dhanhq

This installs entire DhanHQ Python Client along with the required packages. Now, you can start using DhanHQ Client with your Python script.

You can now import 'dhanhq' module and connect to your Dhan account.

from dhanhq import dhanhq

dhan = dhanhq("client_id","access_token")


Error responses come with the error code and message generated internally by the system. The sample structure of error response is shown below.

    "errorCode": "",
    "httpStatus": "",
    "internalErrorCode": "",
    "internalErrorMessage": ""

Rate Limit

Rate Limit Order APIs Data APIs Non Trading APIs
per second 25 10 20
per minute 250 1000 Unlimited
per hour 1000 5000 Unlimited
per day 7000 10000 Unlimited

Order Modifications are capped at 25 modifications/order