Please can someone tell me if there is a way to get listenkey using the WebSocket-only method, and not through using Rest API then obtaining the listenkey method.
If it is possible, then any short working code including the correct URL would be appreciated.
If you wish to listen to your own trades as they happen, I’d recommend the new feature of WebSocket API: "userDataStream.subscribe" requests.
Connect to WebSocket API on wss://ws-api.binance.com/ws-api/v3
Authenticate via "session.logon"
Subscribe via "userDataStream.subscribe"
Now you will receive user data stream events over this connection (which you can also use to send orders).
As for listen keys, currently it is not possible to request a listen key via wss://stream.binance.com connection (where you connect to listen to the stream using the listen key).
If you wish to avoid having to do HTTP calls to REST API, you can use WebSocket API to create a listen key (via "userDataStream.start" method). However, that’s still two separate WebSocket connections:
wss://ws-api.binance.com/ws-api/v3 to create a listen key
wss://stream.binance.com to listen to events using the listen key
Thank you for your response and much appreciated, I will most like stick to the REST API method to obtain a listenkey and use the websocket from there on.