Subscribing & Unsubscribing
Once connected to the WebSocket API you can subscribe to various feeds using the subscribe
or unsubscribe
commands.
These commands should be JSON with the following properties:
Property | Type | Description |
---|---|---|
| string | Command you are sending to the WebSocket ( |
| string[] | List of the feeds that should be subscribed/unsubscribed to/from, respectively. |
Subscribing
To begin receiving feed messages, you must send a subscribe
message to the server indicating which feeds to receive. This message is mandatory—you may be disconnected if no subscribe
has been received.
To ensure optimal performance, create a separate WebSocket connection for each feed type you subscribe to. This segregation ensures that time-sensitive updates, such as balances or open-orders messages, are not impacted by high-frequency feeds like order books.
Subscribe Message
Once a subscribe
message is received the server responds with a subscribe
message that lists all feeds you are subscribed to. Subsequent subscribe messages add to the list of subscriptions.
Example Code
Unsubscribing
To unsubscribe from a feed or feeds, send an unsubscribe
message. The structure is equivalent to subscribe
messages.
Unsubscribe Message
Once a unsubscribe
message is received the server responds with an unsubscribe
message that lists all feeds you are unsubscribed from.
Example Code
Last updated