dhanhq
The official Python client for communicating with the DhanHQ API
Decision gist · record as of 2026-08-14
Yes, if you trade on the Dhan platform and need programmatic order execution or market data access. The library has low install friction, active maintenance, permissive licensing, and no known vulnerabilities. However, v2.2.0 contains breaking changes from v2.1.0, so verify compatibility with your codebase or pin to v2.0.2 if stability is critical. Requires valid Dhan credentials and is only useful if you already have a Dhan trading account.AI-flagged interpretation of the facts on this page — verify before relying
Before you install
- Requires valid Dhan broker credentials (client_id and access_token) obtained through OAuth or PIN/TOTP authentication; API access is tied to a Dhan trading account.
- Low install friction with a pure Python wheel and four standard runtime dependencies (pandas, requests, websockets, pyOpenSSL).
- Marked as active maintenance with a recent release in April 2026, though repository metadata is not publicly available.
License · maintenance · safety
MIT LICENSE (permissive) — Licensed under MIT, a permissive license that allows commercial and private use with minimal restrictions, making it safe to integrate into most projects.
last release 2026-04-24 (112 days)
0 known vulnerabilities (OSV.dev, 2026-08-14) · 73,452 downloads/mo, #14,996 on PyPI
Alternatives
Verify before relying
pip install dhanhq
from dhanhq import DhanContext, dhanhq
dhan_context = DhanContext("client_id", "access_token")
dhan = dhanhq(dhan_context)
dhan.place_order(security_id='1333', exchange_segment=dhan.NSE, transaction_type=dhan.BUY, quantity=10, order_type=dhan.MARKET, product_type=dhan.INTRA, price=0)- Whether Python version requirements are enforced (requires_python is unspecified in metadata)
- Stability guarantees for v2.2.0 given the documented breaking changes from v2.1.0
- Real-world latency and reliability of websockets-based market feed under production load
What it is and what it does
DhanHQ-py is the official Python client for the Dhan trading platform's REST and WebSocket APIs. It abstracts the complexity of communicating with Dhan's trading infrastructure, allowing developers to place and manage orders, stream real-time market data, retrieve historical candles, and query account positions and balances programmatically. The library wraps HTTP requests via the requests library and real-time feeds via websockets, with data serialization handled by pandas.
The package is designed for traders and algorithmic trading systems that need to automate execution and data collection on the Dhan platform. It handles authentication via DhanLogin (OAuth or PIN/TOTP flows), manages credentials through a DhanContext object to reduce credential sprawl, and provides a high-level API for common trading workflows such as placing market or limit orders, querying order status, fetching option chains, and accessing fund details. Version 2.2.0 introduced 200-level market depth, expired options data, super orders for risk management, and IP whitelisting capabilities.
Use it for
- Automate equity and derivatives order placement and cancellation on NSE and BSE exchanges without manual intervention.
- Build algorithmic trading strategies that consume real-time market depth and tick data via the live market feed.
- Retrieve historical OHLC candles and option chain data for backtesting and analysis workflows.
- Monitor and manage open positions, holdings, and account margins programmatically.
- Implement swing trading systems using Forever Orders (single or OCO) for automated risk and profit management.
Worth the install?
AI-flagged interpretation of the facts on this page. Verify before relying on it.
Yes, if you trade on the Dhan platform and need programmatic order execution or market data access.
The library has low install friction, active maintenance, permissive licensing, and no known vulnerabilities. However, v2.2.0 contains breaking changes from v2.1.0, so verify compatibility with your codebase or pin to v2.0.2 if stability is critical. Requires valid Dhan credentials and is only useful if you already have a Dhan trading account.
Install
dhanhq on PyPI
Before you install
Low install friction with a pure Python wheel and four standard runtime dependencies (pandas, requests, websockets, pyOpenSSL). Marked as active maintenance with a recent release in April 2026, though repository metadata is not publicly available.
Requires valid Dhan broker credentials (client_id and access_token) obtained through OAuth or PIN/TOTP authentication; API access is tied to a Dhan trading account.
License in practice
Licensed under MIT, a permissive license that allows commercial and private use with minimal restrictions, making it safe to integrate into most projects.
Quickstart
pip install dhanhq
from dhanhq import DhanContext, dhanhq
dhan_context = DhanContext("client_id", "access_token")
dhan = dhanhq(dhan_context)
dhan.place_order(security_id='1333', exchange_segment=dhan.NSE, transaction_type=dhan.BUY, quantity=10, order_type=dhan.MARKET, product_type=dhan.INTRA, price=0)
Verify before relying
- Whether Python version requirements are enforced (requires_python is unspecified in metadata)
- Stability guarantees for v2.2.0 given the documented breaking changes from v2.1.0
- Real-world latency and reliability of websockets-based market feed under production load
Package facts
| License | MIT LICENSE permissive |
| Python support | Not specified |
| Install friction | Low. Pure-Python wheel |
| Runtime dependencies | 4 packagespandasrequestswebsocketspyOpenSSL |
| Maintenance | Actively maintained 112 days since the last release |
| First released | |
| Downloads | 73,452 / month, #14,996 on PyPI 30-day window, as of 2026-08-14 |
| Known vulnerabilities | None known OSV.dev, checked 2026-08-14 |
Evidence: dhanhq-2.2.0-py3-none-any.whl
Tags
Let your AI agent find packages like this
Example. Real query, live index.
You found this page by searching. An agent finds it by wishing: SkillFed indexes 14,416 PyPI packages by what they can do, searchable in plain language.
wish › “automated order execution”
- dhanhqPython client library for the Dhan trading API, enabling automated…
- py-clob-clientPython client library for trading on Polymarket's Central Limit Order…
- pytest-orderingA pytest plugin that lets you control the execution order of your…
Give your agent the search over MCP, or paste the wish link into any chat.
More WWW/HTTP packages
urllib3 is an HTTP client library that provides thread-safe connection pooling, SSL/TLS verification, multipart file uploads, request retries, compression support, and proxy handling for Python applications.
Requests is a Python HTTP library that simplifies sending HTTP/1.1 requests with automatic handling of headers, authentication, cookies, and response parsing.
h11 is a pure-Python HTTP/1.1 protocol implementation that handles parsing and serializing HTTP messages without any built-in I/O, letting you integrate it with any network layer you choose.
HTTPX is a fully featured HTTP client library for Python that provides both sync and async APIs, with support for HTTP/1.1 and HTTP/2, plus an integrated command-line client.
Install it if you are building new projects or modernizing existing ones that rely on HTTP.
A minimal low-level HTTP client library that sends HTTP requests with thread-safe and task-safe connection pooling, supporting HTTP/1.1, HTTP/2, proxies, and both sync and async interfaces.
aiohttp is an async HTTP client and server framework built on asyncio, supporting both WebSockets and middleware-based routing for building concurrent web applications.
Install it if you need async HTTP client or server capabilities in asyncio-based applications.
See also kiteconnect · fyers-apiv3 · growwapi · py-clob-client-v2 · python-binance · tastytrade · databento · shioaji · tardis-client · ShopifyAPI