Upstox SDK : Orderdetails API returning empty "data" response

Hi,
I am using the “get_order_details” method to fetch the placed order details with a valid order ID for which I placed the order today. However, I keep on getting empty response.

What am I missing? Please help .

Code

ipdb> configuration = upstox_client.Configuration()
ipdb> configuration.access_token = self.upstox_access_token
ipdb> api_instance = upstox_client.OrderApi(upstox_client.ApiClient(configuration))
ipdb> api_instance
<upstox_client.api.order_api.OrderApi object at 0x000001BCBF6574C0>
ipdb> api_version = '2.0'
ipdb> order_id = "230803025328558"
ipdb> tag = 'tag_example'
ipdb> api_response = api_instance.get_order_details(api_version, order_id=order_id, tag=tag)
ipdb> pprint(api_response)
{'data': [], 'status': 'success'}
ipdb> 

Documentation : https://github.com/upstox/upstox-python/blob/master/docs/OrderApi.md#get_order_details

On Upstox UI:
image

Hi @RahulMittal87,

This issue might occur if there’s a mismatch between the order_id and the tag. Your current request is attempting to fetch the order id 230803025328558 associated with the tag tag_example. If this specific pairing doesn’t exist, the result will be empty. If you’re uncertain about the tag that was used during the order creation, you could omit the tag and try again using only the order_id.

Let us know if this worked.

Thanks!!

1 Like

Thank you. It worked (Y).
In the response I received multiple objects for the same order ID with varying status; why so?

status’: ‘put order req received’,
‘status’: ‘validation pending’,
‘status’: ‘open pending’,
‘status’: ‘open’,
‘status’: ‘complete’,

I should just refer to “Complete” one for the completed orders right?

Also, I can alternatively use get_order_book method with orderID condition to get similar “Complete” order data right?

I’m glad to hear that the solution worked for you!

The purpose of the Order Details API is to retrieve the history of an order, including every status change it has undergone. It’s not advised to use the order book to obtain information on a single order, as it’s an inefficient use of resources to sift through all the orders placed during the day. However, if the total number of daily orders is relatively small, utilizing the order book might be appropriate.

1 Like

Great (Y) . This was really helpful. Thanks for your quick responses. Loving the SDK…

1 Like