Messages
Index IN
Index value message JSON is structured like this:
{
"type": "index",
"index_id": "IDX_REFRATE_PRIMKT_BTC_USD",
"sequence": 2323346,
"time_coinapi": "2017-03-18T22:42:21.0000000Z",
"value": 1085.72276,
}
Index value message is sent for each update of certain .
Message variables
Variable | Description |
---|---|
type | Message type, always index |
index_id | Index identifier |
sequence | Sequence number per pair (type , index_id ) which is valid only for the lifespan of the connection |
time_coinapi | CoinAPI time for which value of index was calulated |
value | Value of index |
Reconnect IN
Reconnect message is sent by the server to all connected clients when the server will be restarted or shut down at the defined exact time included in the message content. After the period specified in message passes, the client must expect that the underlying WebSocket connection will be closed from the server-side. A new connection will automatically be established to a different server.
The correct way of handling this event depends on the specific requirements of the integration, but we can define standard ways how to handle it:
- Wait for the connection to be closed and reconnect
- Reconnect immediately after receiving the message
- Upon receiving the message, establish a second connection, and subscribe to the same scope of data. When the first connection is disconnected, do not reconnect it and instead transparently switch the data streams between connections. This method requires more implementation as a transparent switch of the data stream must not break the sequence for streams published using the initial snapshot and update messages. To make sure the sequence is correct, the client must: (a) maintain a state by applying updates to snapshot or (b) buffer the data from the second connection and processing it at the transparent connection switch.
Example JSON reconnect message is structured like this:
{
"type": "reconnect",
"within_seconds": 10,
"before_time": "2020-08-06T19:19:09.7035429Z",
}
Message variables
Variable | Description |
---|---|
type | Message type, always reconnect |
within_seconds | Seconds within which reconnection should be performed. |
before_time | Time before which reconnection should be performed. |
Heartbeat IN
Heartbeat message JSON is structured like this:
{
"type": "heartbeat"
}
Heartbeat message is sent to you every time there is one second of silence in communication between us, if you agreed on this feature in Hello message.
WebSocket working on TCP protocol which doesn’t have the feature indicating that the connection is broken without trying exchange data over it. As you will not be actively sending messages to us, with Heartbeat you can distinguish a situation where there are no market data updates for you (Heartbeat is delivered but no market data updates) or connection between us is broken (Heartbeat and market data updates are not delivered).