Messages
Describe the general message format of the stream protocol.
Fields
WebSocket messages are JSON objects with the following fields:
Field | Description | Format |
---|---|---|
t | topic | |
e | event | possible values: - tdx:subscribe - tdx:unsubscribe - tdx:order_create - tdx:order_cancel - tdx:cancel_on_disconnect |
d | data | JSON |
a | authentication | JWT token |
Topics
Interactions are performed on topics
:
Topic | Description | Type | Format |
---|---|---|---|
<pair>@trades | stream to receive trade updates | public | ^[a-zA-Z0-9\-]{1,10}\/[a-zA-Z0-9\-]{1,10}@trades$ |
<pair>@depth | stream to receive order book updates. A level can be specified by appending it to the topic:<pair>@depth10 <pair>@depth50 <pair>@depth100 <pair>@depth500 A refresh speed can be specified by appending it to the topic: <pair>@depth@100ms <pair>@depth@500ms <pair>@depth@1000ms <pair>@depth@5000ms level and speed can be combined: <pair>@depth10@100ms | public | ^[a-zA-Z0-9\-]{1,10}\/[a-zA-Z0-9\-]{1,10}@(depth(10|50|100|500)?(@(100|500|1000|5000)ms)?)$ |
<subAccountId>@subaccount-orders | stream to create orders and receive updates | private | ^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}@subaccount-orders$ |
Subscribing to a topic
First one needs to subscribe to a topic
, by sending a message with an event tdx:subscribe
. For example, to subscribe to the topic
streaming the trades of the BTC/CHF
pair, the following message will be sent:
{
"t": "BTC/CHF@trades",
"e": "tdx:subscribe"
}
{
"t": "BTC/CHF@trades",
"e": "tdx:subscription_received"
}
Unsubscribing from a topic
{
"t": "BTC/CHF@trades",
"e": "tdx:unsubscribe"
}
{
"t": "BTC/CHF@trades",
"e": "tdx:unsubscription_succeeded"
}
Updated 17 days ago