Use the websocket API in synchronous mode

What is the best way to get a price snapshot synchronously.

What I would like:

ws.send(request)

result = ws.recv()

The problem is that I can receive different messages (ping for instance..).

Do I have to necessarily implement a logic to filter the answers ?

Best Answer

  • Gurpreet
    Gurpreet admin
    Answer ✓

    @chbailly The websocket is a connection oriented API, and there is minimal housekeeping that has to be performed - like login before making a data request, and responding to ping requests. These have to be done, regardless of request for snapshot or streaming data.

    We don't have a synchronous access helper for it, but might consider providing such "ease of use library" in future. For now, please see the implementation details in the provided code samples.

Answers