Messages
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 |
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"
}
Trades stream
- Subscribe
{
"t": "BTC/CHF@trades",
"e": "tdx:unsubscribe"
}
- Receive confirmation and a stream of trade updates:
{
"t": "BTC/CHF@trades",
"e": "tdx:subscription_received"
}
{
"t": "BTC/CHF@trades",
"d": {
"d": 1640760718833000000,
"p": "10000",
"q": "2",
"i": "SWHMAzEePHsGJ9BbqdL3IxpJLgi/5ujG8VezfLnauqg="
},
"e": "trade"
}
{
"t": "BTC/CHF@trades",
"d": {
"d": 1640760847376000000,
"p": "10000",
"q": "1",
"i": "iWoKtJn5Zf8XbB3cG2m/7JcTwRmWnXuxjTPKI+wp/tU="
},
"e": "trade"
}
Trade data
Field | Description |
---|---|
d | Date |
p | Price |
q | Quantity |
i | ID |
Order book stream
- Subscribe
{
"e": "tdx:subscribe",
"t": "ACETO/USD@depth@100ms"
}
- Receive confirmation, the order book and a stream of order book updates:
{
"t": "ACETO/USD@depth@100ms",
"e": "tdx:subscription_received"
}
{
"t": "ACETO/USD@depth@100ms",
"d": {
"u": 124,
"b": [
[
"120",
"2"
],
[
"114",
"14"
],
[
"113",
"13"
],
[
"112",
"12"
],
[
"111",
"11"
],
[
"110",
"10000"
],
[
"103",
"3"
],
[
"100",
"11303"
],
[
"99",
"1"
],
[
"98",
"1"
],
[
"97",
"3"
],
[
"88",
"8"
],
[
"80",
"20"
],
[
"70",
"23"
],
[
"65",
"16"
],
[
"64",
"4"
],
[
"63",
"3"
],
[
"62",
"2"
],
[
"61",
"1"
],
[
"60",
"15"
],
[
"50",
"1"
],
[
"2",
"1"
]
],
"a": [
[
"130",
"9"
]
]
},
"e": "orderbook"
}
Order Book data
Field | Description |
---|---|
u | Update ID |
b | Bids: an array of BookEntry |
a | Asks: an array of BookEntry |
A BookEntry
is an array with 2 values: a price
and a quantity
. For example: ["130","9"]
Updated 11 months ago