Unable to take api_response into pandas dataframe

I want to take api_response in pandas dataframe but not able to do it. I have tyried somany things but not successful. pls help.

I have attached both my code and code’s output screenshot.

My code is this
from future import print_function
import time
import upstox_client
from upstox_client.rest import ApiException
from pprint import pprint
import pandas as pd, xlwings as xw
import json

create an instance of the API class

api_instance = upstox_client.HistoryApi()

instrument_key = ‘NSE_INDEX|Nifty 50’ # str |
api_version = ‘2.0’ # str | API Version Header

excel_name = xw.Book(“Mylevel.xlsx”)
level_sheet = excel_name.sheets[“SR”]
instrument_key = level_sheet.range(“A6”).value
interval = level_sheet.range(“F1”).value
to_date = level_sheet.range(“D1”).value
from_date = level_sheet.range(“B1”).value

try:
# Historical candle data
api_response = api_instance.get_historical_candle_data1(instrument_key, interval, to_date, from_date, api_version)
pprint(api_response)
data = api_response.values

  • df_ohlc = pd.DataFrame(data)*
  • print(df_ohlc)*
    except ApiException as e:
    print(“Exception when calling HistoryApi->get_historical_candle_data: %s\n” % e)

@vgajre

Thank you for reaching out. I’m pleased to hear that you are successfully executing the API and obtaining results.

If you encounter any issues specifically related to our API’s functionality, please don’t hesitate to bring them to our attention, and we’ll do our best to assist you.

However, it’s important to note that once the API returns the response, any application-specific logic, such as porting results to a pandas DataFrame or other post-processing on your side, is outside the scope of our support. We recommend consulting the relevant documentation or community forums specific to the technology you are using for help in those areas.

We appreciate your understanding, and thank you for using our API. Let us know if you have any further questions related to the API itself.

Thanks!!

So you can improve this api function get_historical_candle_data1 to response in json data type that will help us lot. Response and output should be in industry standard otherwise it has no use. In this api header contant data type is not given this is fault in api.

@vgajre

Thank you for your response. Our APIs have been designed to align with industry standards, and the format of the response reflects that. Each API provides a consistent JSON structure, with the ‘data’ object’s datatype tailored to its specific needs. For instance, in the historical candle API, the ‘candles’ object is structured as an array since it returns multiple candle data points.

For all our APIs that generate a payload, the content type is set to ‘application/json’, which adheres to best practices in the industry.

Having said that, we are continually looking for scope to improve and enhance the product.

Thank you for your understanding and patience. We appreciate your collaboration.