I’m new to Binance websocket, and I usually get information like pricing and coin information from API endpoints rather than websocket.
Is there any simple way to store data that comes from Websocket that I can use or pass to other functions? I’m using python-binance to call Websocket.
I need help with this.
Based on what you’ve described, it seems that what you want is handling events coming from a WebSocket connection. This is usually done at the message callback level, which you define. How you pass this callback to the WebSocket depends on the library you’re using.
python-binance is not the official library, so I would suggest discussing this topic with their community.
However, if you want to use the official library, you have WebSocket examples available at
Yes, try that library; unfortunately, I got an error like this:
ModuleNotFoundError: No module named ‘binance.websocket’
I already install the package:
pip install binance-connector
@cevinov verify if the python version you’re using to run the file is the one you’ve installed the
I urge you to store your data in dict and update the dict as you receive new data. However it will be gone forever when you terminate the app.
If you still want to keep the data the easiest way to store them in a json file.
I see. Could you give me any example code to give me an idea of how to implement it myself?