Dhan API (Algo Trading) Review

Dhan Logo

0.79%9,79,483 Clients

Dhan offers powerful, feature-rich APIs through its DhanHQ API suite, enabling traders, developers, and fintechs to build custom trading platforms and algorithmic strategies. The REST and streaming APIs provide access to live market data, historical data, positions, margins, portfolio, and fast order execution across major Indian exchanges.

The APIs are designed for online clients and are compatible with multiple programming languages. Dhan also provides SDKs, sample code, and detailed documentation, making it easier to integrate trading, data, and post-trade workflows into your own applications.

API benefits

  • Programmatic access to trading and market data for custom platforms and algos
  • Covers end-to-end trading lifecycle: orders, positions, funds, and postbacks
  • Rich market data: quotes, live feeds, full market depth, historical and options data
  • Conditional triggers for strategy automation using technical indicators and price rules
  • Supports multiple asset classes and segments across leading Indian exchanges
  • Technical annexure with clear codes for instruments, products, feeds, and errors
  • Designed for developers, active traders, and startups building on top of Dhan

Dhan API Details

API Brokerage Charge

No additional charges for API access; standard brokerage applies

API Document Linkhttps://dhanhq.co/docs/v2/
API Data Format

REST (JSON), Python SDK support

API Offer Type

Trading APIs, Market Data APIs, WebSocket APIs, Authentication APIs, Portfolio & Position APIs, Trader’s Control APIs, Forever Order APIs, Super Order APIs

API Exchange Support

NSE, BSE, MXC

API OS Support

Windows, macOS, Linux

API Support Features

Real-time order management, EDIS integration, Live Market Feed, and Historical Data

API Order Types

Market, Limit, SL, SL-M, Bracket (BO), Cover (CO), AMO, and Forever Orders

Dhan API Rate Limit

To ensure system stability and fair usage, Dhan enforces the following rate limits

  • Order APIs: 10 requests/sec | 250 requests/min | 7,000 requests/day.
  • Data APIs: 5 requests/sec | 100,000 requests/day.
  • Quote APIs: 1 request/sec | Unlimited per minute/hour/day.
  • Order Modifications: Capped at 25 modifications per order

Dhan API Key

Individual traders can directly generate an Access Token from the Dhan web platform. All Dhan users get free access to Trading APIs.

Steps to Generate Access Token

  1. Login to web.dhan.co
  2. Go to My ProfileAccess DhanHQ APIs
  3. Generate the Access Token with 24-hour validity
  4. Optionally, add a Postback URL to receive order updates

Users can also generate tokens using the API endpoint if TOTP is enabled.

Renew Token

Users can renew their active token for another 24 hours using the Renew Token API.

Important Notes

  • Renewing a token expires the current token immediately
  • Only active tokens can be renewed
  • Expired tokens cannot be refreshed

API Key & Secret

Dhan also provides OAuth-based authentication using API Key and Secret credentials.

Steps to Generate API Key & Secret

  1. Login to web.dhan.co
  2. Go to My ProfileAccess DhanHQ APIs
  3. Switch to the API Key section
  4. Enter:
    • App Name
    • Redirect URL
    • Optional Postback URL
  5. Generate the API Key and Secret

Authentication Flow

After generating the API Key and Secret, users must complete the following steps to generate the Access Token.

STEP 1: Generate Consent

This API validates the App ID and Secret and creates a login session for the user authentication process.

STEP 2: Browser-Based Login

  1. Open the login endpoint in a browser
  2. Login using Dhan credentials
  3. Complete 2FA authentication using OTP, PIN, or password
  4. After successful login, the user is redirected to the registered Redirect URL
  5. A tokenId is received in the redirect URL

STEP 3: Consume Consent

This API validates the:

  • API Key
  • API Secret
  • tokenId

After successful verification, the Access Token is generated, which is used for all API authentication and trading requests.

Dhan API Types Offered

  1. Trading APIs: Covers the full lifecycle of an order, including Placement, Modification, and Cancellation.
  2. Advanced Order Types: Access to specialized tools like Super Orders (Bracket/Cover) and Forever Orders (GTT).
  3. Data APIs: Provides Live Market Feeds via WebSockets and Historical Data for backtesting strategies.
  4. Portfolio & Positions: Real-time access to Holdings, current open positions, and daily profit/loss.
  5. Funds & Margin: APIs to check Available Limits and manage fund allocations.
  6. EDIS & Control: Secure EDIS flows for selling holdings and Trader's Control for risk management.

Conclusion

DhanHQ Ver 2.0 stands out as a developer-friendly, high-speed API suite that prioritises transparency and performance. With its "zero-cost" API model and extensive documentation, it provides both retail traders and institutional developers with the tools necessary to execute sophisticated trading strategies with precision.

Zerodha (India's Best & No. 1 Broker)

  Special Offer - Free Equity Delivery and Mutual Funds

  • Brokerage-free equity delivery trades.
  • Brokerage-free Direct Mutual Fund.
  • Pay ₹20 per trade for Intraday & F&O.
  • The best trading platform in India.

Open Instant Demat Account Read Reviews

Frequently Asked Questions

Founded in 2021, Dhan is an online broking company offering financial services. Dhan offers online stock trading and investing services in India. Dhan has developed technologically advanced trading platforms.

Dhan allows its customers to open a 2-in-1 account. The account opening and account maintenance charges are Zero.

The company has a simple pricing model. Dhan charges Rs 20 per trade for intraday trading in Equity, ETF, Currency, F&O and Commodity segments. Dhan is offering a 50% discount to its female customers and charges a brokerage of Rs 10 per trade for intraday trades.

Dhan customers can generate API token using web.dhan.co. To create an API token, simply follow the instructions below:

  1. Login to web.dhan.co.
  2. Go to your profile.
  3. Click on "Dhan HQ APIs & Access."
  4. On the following page, you will have the option to create an access token.

Yes, Dhan APIs are free of charge. Dhan offers two APIs: Trading API and Data API. Trading APIs are absolutely free of cost. The data APIs are free if customers have executed 25 trades in the last 30 days. If they do not, they can get the data API access by paying Rs 499 + taxes.

Dhan offers trading API and data API to its clients.

Trading API - Trading APIs provide access to order placement, position, portfolio, funds, special orders and much more.

Data API - Data APIs allow access to historical data, data for any scrip or live market feeds.

Yes, there are no separate subscription charges for using the DhanHQ API.

The current limit for Order APIs is 7,000 requests per day.

Yes, the Live Market Feed API uses WebSockets to provide real-time tick-by-tick data.

Yes, Dhan provides a dedicated Historical Data API for fetching past candle information.

Dhan Competitors Review

Information on this page was last updated on Monday, July 8, 2024

Zerodha (Flat Rs 20 Per Trade)

Special Offer - Invest brokerage-free Equity Delivery and Direct Mutual Funds (truly no brokerage). Pay flat Rs 20 per trade for Intra-day and F&O. Open Instant Account and start trading today.

Zerodha (Flat Rs 20 Per Trade)
Invest brokerage-free Equity Delivery and Direct Mutual Funds (truly no brokerage). Pay flat Rs 20 per trade for Intra-day and F&O. Open Instant Account and start trading today.

Zerodha (India's Best & No. 1 Broker)

  Special Offer - Free Equity Delivery and Mutual Funds

  • Brokerage-free equity delivery trades.
  • Brokerage-free Direct Mutual Fund.
  • Pay ₹20 per trade for Intraday & F&O.
  • The best trading platform in India.

Open Instant Demat Account Read Reviews
⚖️
Compare Brokers

Compare brokers side-by-side to choose the right one.

Are you a Dhan Customer?