Dependency installation issue with latest Dhan 3.2.0 - Tradehull release on PyPI

I am writing to report and seek clarification on a dependency issue encountered while attempting to install and use the latest version of the Dhan-Tradehull library. I have described the environment, steps performed, and the exact issue in detail below so your engineering team can review it.

Environment Details
Operating System: Windows 10 (64-bit)
Python Version: Python 3.12.9
pip Version: Latest version installed via python -m pip install --upgrade pip
Installation Method: Standard pip installation from PyPI

Initial Objective
I was attempting to install and use the latest version of the Dhan-Tradehull library available on PyPI for building an automated trading workflow using Python.

Step 1: Attempt to install the latest Tradehull package
I attempted to install the latest version using the following command:

pip install Dhan-Tradehull==3.2.0

However, pip failed with a dependency resolution error indicating that a required dependency could not be found.

Observed Error
The pip installer returned the following type of error message:

“Could not find a version that satisfies the requirement dhanhq >= 2.1.0 (from Dhan-Tradehull)”
“No matching distribution found for dhanhq >= 2.1.0”

Step 2: Verification of available dhanhq versions on PyPI
To investigate further, I checked the versions available for the dhanhq package using:

pip index versions dhanhq

The versions available on PyPI appeared to be:

1.x series versions
2.0.0
2.0.1
2.0.2
2.2.0rc1 (release candidate)

There was no stable release version >= 2.1.0 available.

Dependency Mismatch Identified
The latest Dhan-Tradehull version (3.2.0) appears to require:

dhanhq >= 2.1.0

However, since a stable dhanhq version >= 2.1.0 is not available on PyPI, pip cannot resolve this dependency during installation.

Step 3: pip fallback installation
Because of this mismatch, pip automatically installed the latest compatible combination that satisfied available dependencies:

Dhan-Tradehull 3.0.6
dhanhq 2.0.2

This environment worked correctly and the API was functional.

Verification performed using:

pip show Dhan-Tradehull
pip show dhanhq

Resulting environment:

Python 3.12.9
Dhan-Tradehull 3.0.6
dhanhq 2.0.2

API calls such as authentication, LTP retrieval, ATM strike selection, and option LTP queries worked successfully with this configuration.

Step 4: Testing updated codebase provided by the community
In addition to the pip package, I also tested the updated local codebase file provided in the community:

Dhan_Tradehull_V2.py

This codebase reports internally:

“Codebase Version 2.8 : Solved - Strike Selection Issue”

Using this implementation with dhanhq 2.0.2 also worked correctly for the following functions:

get_ltp_data()
ATM_Strike_Selection()
get_live_pnl()
Instrument file loading
Spot and option LTP retrieval

Current Understanding
Based on the above testing, the main issue appears to be a dependency mismatch in the PyPI release.

Specifically:

The latest version of Dhan-Tradehull requires dhanhq >= 2.1.0
However, a stable dhanhq version >= 2.1.0 does not appear to be available on PyPI.

Because of this, installing the latest Tradehull version in a clean Python environment fails.

Questions for the Engineering Team

  1. Has dhanhq >= 2.1.0 been officially released but not published on PyPI?

  2. Is the dependency requirement in Dhan-Tradehull 3.2.x intended to be dhanhq >= 2.0.x instead?

  3. Is there a recommended stable combination of versions that should currently be used for production environments?

  4. Will a corrected dependency version be published for the Tradehull package?

My goal is to ensure that I am using the officially supported and stable library versions for building an automated trading workflow.

If there is updated documentation or a recommended installation method for the latest versions, I would appreciate guidance.

Thank you for your support and for maintaining the API ecosystem.

@Tradehull_Imran

Can you please look into this ?

@Dpwd Try following:

pip install --pre dhanhq
pip install Dhan-Tradehull
2 Likes

Hi @Dpwd ,

We’re currently using the pre-release version of dhanhq so we can access the latest features from the Dhan API. You can install the pre-release version using the following command:

pip install --pre dhanhq
pip install Dhan-Tradehull==3.2.0

Confirm the installation by running the below commands-

pip show dhanhq
pip show Dhan-Tradehull

@DSingh

Thank you
I have used it and issue is solved

@DSingh

I am currently integrating the Dhan API for automated trading and encountered an issue in the authentication workflow related to the TOTP verification and consent generation stage. I would appreciate your assistance in understanding and resolving the problem.

Environment Details

Client Platform: Python 3.12
Automation Framework: Playwright (browser automation)
TOTP Generation: pyotp library
Operating System: Windows 10
API Version: Dhan API v2 authentication flow

The login automation script is designed to perform the following sequence:

  1. Generate consent URL through the API.

  2. Navigate to the Dhan login page.

  3. Enter mobile number and verify using TOTP.

  4. Enter PIN for final authentication.

  5. Capture authorization code and exchange it for an access token.

All environment variables including client_id, mobile number, TOTP secret, and PIN are correctly configured and validated before execution.

Observed Issue

During execution, the script repeatedly fails at the consent generation stage. The logs show the following response:

errorCode: CONSENT_LIMIT_EXCEED
errorMessage: Consent limit Exceeded

Below is the relevant portion of the execution logs:

2026-03-07 00:56:30 | Loaded env | client_id masked mobileno masked
2026-03-07 00:56:32 | LoginAttempt Starting attempt 1/2
2026-03-07 00:56:35 | GenerateConsent HTTP POST attempt 1/3
2026-03-07 00:56:37 | WARNING Consent limit exceeded Waiting 65 seconds before retry
2026-03-07 00:57:42 | GenerateConsent retry
2026-03-07 00:57:43 | WARNING Consent limit exceeded Waiting again
2026-03-07 00:58:48 | ERROR consentAppId missing payload errorCode CONSENT_LIMIT_EXCEED
2026-03-07 00:58:49 | Login failed reason consent_url_generation_failed

Because the consent URL is not generated, the authentication process cannot proceed further, and the access token is never created.

Troubleshooting Already Performed

To ensure the issue was not related to the local implementation, I performed the following checks:

  1. Verified that the client_id and API configuration are correct.

  2. Confirmed that the TOTP secret is valid and generating correct codes.

  3. Tested multiple login attempts with sufficient delay between requests.

  4. Implemented retry logic and exponential backoff for the consent API.

  5. Ensured that the script is not generating parallel authentication requests.

  6. Confirmed that the API payload format matches the documentation.

Despite these checks, the API consistently returns the consent limit exceeded response.

Clarifications Requested

Could you please help clarify the following points:

  1. What is the exact rate limit or quota for the consent generation API endpoint?

  2. Is the consent limit calculated per client_id, per user account, or per IP address?

  3. How long should we wait before retrying once the consent limit is exceeded?

  4. Is there any recommended authentication flow for automated trading systems using the Dhan API?

  5. Are there any recent changes in the authentication or consent generation process that might affect automated login scripts?

Impact

This issue is preventing automated access token generation, which blocks the ability to run API based trading automation workflows.

If there are recommended best practices or alternative authentication mechanisms for automated systems, I would appreciate your guidance.

Please let me know if you require additional logs or debugging information from my side.

Thank you for your support.

TOTP based login has been enabled via API.

1. Sync system time. https://time.is

2. Get “Client ID”. Dhan Web - Made for Fast Online Trading and Investing Platform

3. Set totp = pyotp.TOTP(TOTP_SECRET).now() in DhanHQ-py/examples/auth_example.py at main · dhan-oss/DhanHQ-py · GitHub