Error {'806': 'Data APIs not Subscribed'}

Hey @Tradehull_Imran Sir, I am getting the error while trying to use the codebase 3.1. i have installed the latest codebase “pip install Dhan-Tradehull==3.0.6” and also subscribed the Data APIs.

please help to resolve, thanks!!

Below is my code:

import pdb
import time
import datetime
import traceback
from Dhan_Tradehull import Tradehull
import pandas as pd
from pprint import pprint
import talib


client_code = "xxxxx"
token_id    = "XXXX"
tsl         = Tradehull(client_code,token_id)


all_ltp_data   = tsl.get_ltp_data(names = ["ACC", "CIPLA"])
acc_ltp = all_ltp_data['ACC']
pe_ltp  = all_ltp_data['NIFTY 28 AUG 25500 PUT']



stock_name = 'NIFTY'
ltp   = tsl.get_ltp_data(names = [stock_name])[stock_name]




chart = tsl.get_historical_data(tradingsymbol = 'NIFTY',  exchange = 'INDEX',timeframe="DAY")
data  = tsl.get_historical_data(tradingsymbol = 'NIFTY 19 DEC 24000 CALL'     ,exchange = 'NFO'  ,timeframe="15")



order_status  = tsl.get_order_status(orderid=82241218256027)
order_price   = tsl.get_executed_price(orderid=82241218256027)
order_time    = tsl.get_exchange_time(orderid=82241218256027)


positions = tsl.get_positions()
orderbook = tsl.get_orderbook()
tradebook = tsl.get_trade_book()
holdings = tsl.get_holdings()


ce_name, pe_name, strike = tsl.ATM_Strike_Selection(Underlying='NIFTY', Expiry=0)


ce_name, pe_name, ce_strike, pe_strike = tsl.OTM_Strike_Selection(Underlying='NIFTY', Expiry=0, OTM_count=3)

ce_name, pe_name, ce_strike, pe_strike = tsl.ITM_Strike_Selection(Underlying='NIFTY', Expiry=0, ITM_count=5)

# Equity
entry_orderid  = tsl.order_placement(tradingsymbol='ACC' ,exchange='NSE', quantity=1, price=0, trigger_price=0,    order_type='MARKET',     transaction_type='BUY',   trade_type='MIS')
sl_orderid     = tsl.order_placement(tradingsymbol='ACC' ,exchange='NSE', quantity=1, price=0, trigger_price=2200, order_type='STOPMARKET', transaction_type ='SELL', trade_type='MIS')

# Options
entry_orderid  = tsl.order_placement(tradingsymbol='NIFTY 19 DEC 24400 CALL' ,exchange='NFO', quantity=50, price=0, trigger_price=0, order_type='MARKET', transaction_type='BUY', trade_type='MIS')
sl_orderid     = tsl.order_placement(tradingsymbol='NIFTY 19 DEC 24400 CALL' ,exchange='NFO', quantity=25, price=29, trigger_price=30, order_type='STOPLIMIT', transaction_type='SELL', trade_type='MIS')

modified_order = tsl.modify_order(order_id=sl_orderid,order_type="STOPLIMIT",quantity=50,price=price,trigger_price=trigger_price)

order_ids      = tsl.place_slice_order(tradingsymbol="NIFTY 19 DEC 24400 CALL",   exchange="NFO",quantity=5000, transaction_type="BUY",order_type="LIMIT",trade_type="MIS",price=0.05)



margin = tsl.margin_calculator(tradingsymbol='ACC', exchange='NSE', transaction_type='BUY', quantity=2, trade_type='MIS', price=2180, trigger_price=0)

margin = tsl.margin_calculator(tradingsymbol='NIFTY 19 DEC 24400 CALL', exchange='NFO', transaction_type='SELL', quantity=25, trade_type='MARGIN', price=43, trigger_price=0)

margin = tsl.margin_calculator(tradingsymbol='NIFTY 19 DEC 24400 CALL', exchange='NFO', transaction_type='BUY', quantity=25, trade_type='MARGIN', price=43, trigger_price=0)
margin = tsl.margin_calculator(tradingsymbol='NIFTY DEC FUT', exchange='NFO', transaction_type='BUY', quantity=25, trade_type='MARGIN', price=24350, trigger_price=0)


exit_all       = tsl.cancel_all_orders()


My error is:

C:\Users\Admin\Desktop\Dhan Algo\3.1 Codebase Upgrade\3.1 Codebase Upgrade>py "How to use updated codebase.py"
Codebase Version 3
-----Logged into Dhan-----
reading existing file all_instrument 2025-08-28.csv
Got the instrument file
Exception at calling ltp as {'status': 'failure', 'remarks': {'error_code': None, 'error_type': None, 'error_message': None}, 'data': {'data': {'806': 'Data APIs not Subscribed'}, 'status': 'failed'}}
Traceback (most recent call last):
  File "How to use updated codebase.py", line 17, in <module>
    acc_ltp = all_ltp_data['ACC']
KeyError: 'ACC'

C:\Users\Admin\Desktop\Dhan Algo\3.1 Codebase Upgrade\3.1 Codebase Upgrade>

@Tradehull_Imran sir, its resolved. thanks!

How to solve this problem please help us

Hey @priyanshu1 @KLchawla

You need to have an active Data API subscription to be able to use the data. If you have already subscribed and still getting this error, request you to generate a new token and try once.

Thanks for helps sir but another problem is when run dhan websocket error the error is
Websocket connection error: server rejected websocket connection:HTTP 400

Hi @priyanshu1 ,

It seems you are trying to connect to the WebSocket using the older V1 version. We request you to connect using the latest WebSocket V2. For reference, please check here - Live Market Feed - DhanHQ Ver 2.0 / API Document

Where are latest websocket ver2

Hi @priyanshu1 ,

Sir I am update tradehull in tradehull_v2 kya ab websocket run karke algo run karna parega ki tradehull_v2.py run kar ke phir algo run karna parega

Sir if I had subscribed only trading API ont data API then I could find pnl if I take trade