Login error using API

Hi Team,

I am trying to login using the api, but I am receiving the following error:

Traceback (most recent call last):
File “D:/Learning_Development/Python/connect_upstox.py”, line 26, in
profile = client.get_profile()
AttributeError: ‘ApiClient’ object has no attribute ‘get_profile’

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File “D:/Learning_Development/Python/connect_upstox.py”, line 28, in
except upstox_client.UpstoxException as e:
AttributeError: module ‘upstox_client’ has no attribute ‘UpstoxException’

Here is the code I am using the access:

import upstox_client

your api key and secret

configuration = upstox_client.Configuration()
configuration.api_key = “my_api_key”
configuration.api_secret = “my_api_secret”
client = upstox_client.ApiClient(configuration)

#api_key = “my_api_key”
#api_secret = “my_api_secret”

Initialize the upstox client

client = upstox_client.ApiClient(configuration)

Step 2: Generate login URL and visit it manually to get the authorization code

#login_url = client.get_login_url()
#print(“Login URL:”, login_url)

After logging in via the URL, you will get an authorization code (manually copy it)

authorization_code = input("Enter the authorization code: ")

Step 3: Get the access token using the authorization code

client.get_access_token(authorization_code)

Get user profile

try:
profile = client.get_profile()
print(profile)
except upstox_client.UpstoxException as e:
print(f"Error: {e}")

Let me know if you need any additional details

Hi @Mahesh_Kavalla,
Please make sure you are installing the correct package for the Upstox API client. This is the correct package: upstox-python-sdk · PyPI
Also, please refer to the documentation and example code to understand how to use this package: Example Code | Upstox Developer API

If you still face any issues, feel free to comment here.

Thanks!

I hope I have installed the correct version… please check the attached screenshot

Please let me know if there is anything wrong

Hi Ketan,

Thank you for the support, I am able to connect successfully. I need some more help in placing the orders. I am trying add few conditions before placing the order i.e., moving average, rsi and vwap, do we have any example codes to incorporate in my order? Please suggest.