Using python how to get data in excel received using websocket?

I am using python for API . I have tried websocket . It gives data but it is not properly readable how can I get this data in excel so it is used. I am getting like this

C:\Users\vgajre\OneDrive\Desktop\UPSTOX>py C:\Users\vgajre\OneDrive\Desktop\UPSTOX\
Connection established
{“feeds”: {“NSE_INDEX|Nifty Bank”: {“ff”: {“indexFF”: {“ltpc”: {“ltp”: 43964.05, “ltt”: “1696415400000”, “cp”: 44399.05}, “marketOHLC”: {“ohlc”: [{“interval”: “1d”, “open”: 44108.15, “high”: 44161.35, “low”: 43857.5, “close”: 43964.05, “ts”: “1696357800000”}, {“interval”: “I1”, “open”: 43975.85, “high”: 44016.1, “low”: 43967.75, “close”: 43993.3, “ts”: “1696413540000”}, {“interval”: “I1”, “open”: 43996.6, “high”: 43996.6, “low”: 43996.6, “close”: 43996.6, “ts”: “1696413600000”}, {“interval”: “I30”, “open”: 43947.3, “high”: 43996.7, “low”: 43906.5, “close”: 43975.5, “ts”: “1696410900000”}, {“interval”: “I30”, “open”: 43974.95, “high”: 44026.95, “low”: 43951.95, “close”: 43996.6, “ts”: “1696412700000”}]}, “yh”: 46369.5, “yl”: 38437.95}}}, “NSE_INDEX|Nifty 50”: {“ff”: {“indexFF”: {“ltpc”: {“ltp”: 19436.1, “ltt”: “1696415400000”, “cp”: 19528.75}, “marketOHLC”: {“ohlc”: [{“interval”: “1d”, “open”: 19446.3, “high”: 19457.8, “low”: 19333.6, “close”: 19436.1, “ts”: “1696357800000”}, {“interval”: “I1”, “open”: 19440.05, “high”: 19452.15, “low”: 19437.4, “close”: 19446.15, “ts”: “1696413540000”}, {“interval”: “I1”, “open”: 19449.1, “high”: 19449.1, “low”: 19449.1, “close”: 19449.1, “ts”: “1696413600000”}, {“interval”: “I30”, “open”: 19418.1, “high”: 19446.7, “low”: 19394.15, “close”: 19444.55, “ts”: “1696410900000”}, {“interval”: “I30”, “open”: 19444.35, “high”: 19452.15, “low”: 19435.0, “close”: 19449.1, “ts”: “1696412700000”}]}, “yh”: 20222.45, “yl”: 16828.35}}}}}

You can enhance the readability of JSON using the Python json module. You can find more information on this topic through the following links:

  1. DigitalOcean tutorial: Python Pretty Print JSON
  2. W3Schools guide: Python JSON Formatting

Here’s a sample code that demonstrates how to print JSON in a more readable format using the json module:

import json

json_data = '{"status":"success","data":{"NSE_EQ:IDEA":{"last_price":11.3,"instrument_token":"NSE_EQ|INE669E01016"}}}'
json_object = json.loads(json_data)
json_formatted_str = json.dumps(json_object, indent=2)

We do not support importing data into an Excel sheet. I recommend using the json module for improved data readability.

Hello @vgajre ,

I hope you you may need only ltp only. Instead of passing full pass ltp you can get data in very simplified format and use it to save into excel.

Thanks for reply. I gone throw it. It is good. But I want to make trading tool through excel.

It’s essential to grasp that while we are eager to offer assistance with the API, the exact applications and use cases can vary and should be determined by you, tailored to your specific requirements. At this point in time, we do not have predefined steps available for integrating APIs with Excel.