This API is deprecated, please migrate to Upstox API v2

Hi,

I’m getting below error while connecting API.
Shown error when tried to connect first time in the day. Then I tried new token each time, cleared browser cache, rebooted PC and followed exact process as in API documentation, still not working.

Error: “This API is deprecated, please migrate to Upstox API v2. For more details refer API Documentation – Fast Secure Free – Upstox | Upstox Developer API”.

Used below code to just try if API is connected, still no success.
from upstox_api.api import Upstox

api_key = “CORRECT KEY”
api_secret = “CORRECT SECRET”
redirect_uri = “https://api.upstox.com/v2/login
access_token = “FIRST / NEW TOKEN”

try:
upstox = Upstox(api_key, access_token)
print(“Authenticated successfully!”)

# Test fetching profile
profile = upstox.get_profile()
print("Profile:", profile)

# Test fetching historical data
instrument = upstox.get_instrument_by_symbol('NSE_INDEX', 'NIFTY')
data = upstox.get_ohlc(instrument, interval='3minute', days=1)
print("Historical Data:", data)

except Exception as e:
print(“Error:”, e)

Hi @Sunitha
The error message indicates that you are using deprecated V1 APIs.

To resolve this issue, please use the latest Python SDK, which is available here: Python SDK. This SDK supports V2 APIs, and updating to it should resolve the issue.

Hi Ketan,
upstox-python-sdk version 2.9.0 is already installed.

You have installed the python-sdk version 2.9.0, which is correct. However, the sample code you shared is from the deprecated library named upstox.

Kindly uninstall the deprecated library and refer to the example codes provided here.

Thanks I could able to fix that now.

Need help on python code to place the GTT order with limit buy order with SL & Targets set. Could not find anything on documentation and community, could you please direct to where I can find it.

Currently, it is not possible to place GTT orders through the API. However, you can achieve a similar functionality by placing multiple orders to simulate a GTT order.

Thank you.

Thanks again.
can you please help with a example code to place multiple order to simulate the GTT.
I want to place SL order or 0.8xbuy price and target order of 1.5xbuy price.
all to be limit orders with ltp+/-1 trigger.