Registry / http-networking / dhanhq

dhanhq

JSON →
library2.2.0pypypi✓ verified 85d ago

The official Python client for communicating with the DhanHQ API, version 2.2.0. Provides access to trading, order management, market data, and portfolio endpoints for the Dhan stock trading platform. Release cadence is irregular.

pip install dhanhq
INSTALL
IMPORT
SIG · DHANHQ
D
dhanhq
http-networkingpythonv2.2.0
Install
9.2s avg
Import
—
Disk
186MB
Pass rate
10/ 10
Env Coverage10 / 10
glibc
3.9–3.13
musl
3.9–3.13
Install & Compatibility
Where this runs
tested against v2.2.0 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
py 3.10–3.95 runs
installs and imports cleanly · install 0.0s · import 0.000s · 186.4MB
glibc
py 3.10–3.95 runs
installs and imports cleanly · install 9.2s · import 0.000s · 179MB
186MB installed
● package 186MB
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

DhanContext
✓ from dhanhq import DhanContext
✗ from dhanhq import Dhanhq
DhanHTTP
✓ from dhanhq import DhanHTTP
Order
✓ from dhanhq import Order

Initialize the client with your credentials and fetch fund limits.

from dhanhq import Dhanhq client_id = os.environ.get('DHAN_CLIENT_ID', '') access_token = os.environ.get('DHAN_ACCESS_TOKEN', '') client = Dhanhq(client_id, access_token) # Get account balance funds = client.get_fund_limits() print(funds)
Debug
Known issues
gotchaThe access token must be generated via DhanHQ's API flow (not a password). The token is short-lived (typically 1 day) and must be refreshed. Hardcoding tokens will cause auth failures.
fix
Implement token refresh logic using the refresh_token endpoint or generate a new token before each trading session.
affects: all
deprecatedThe old import `from dhanhq.dhanhq import Dhanhq` is deprecated. Use `from dhanhq import Dhanhq` instead.
fix
Change import to `from dhanhq import Dhanhq`.
affects: >=2.0.0
breakingIn version 2.0.0, the `Order` class was removed. All order functions are now methods on the `Dhanhq` client instance.
fix
Use `client.place_order(...)` instead of `Order.place_order(...)`.
affects: >=2.0.0
Upgrade
Version history
2.2.0latest on PyPI · released Apr 24, 2026
Audit
Dependencies

No dependency data recorded yet.

Agent activity
24 hits · last 30 days
node
22
OpenAI (training)
1
Resources