Essentials
A few things you definitely need to know when using our WebSocket API.
Operations
Every message you send to the WebSocket server should follow the following format:
{
"id": "{id}", // optional, for your own reference
"action": "{action}",
"body": { /* action-dependent body */ }
}
The action
property is the name of the operation you want the WebSocket server to execute and the body
property is an object that contains data specific to the action. You can find all available actions in the menu on the left.
The response of an operation action is always an object with an action
property and a success
property. The action
property is the name of the action you executed and the success
property is a boolean indicating whether the operation was successful. If the operation was not successful, the response will also contain an error
property with a string containing the related error message.
Authentication
After connecting to the websocket, you have to authenticate yourself by sending an authentication action with your API key as body, before you can do anything else. You can create an API key in the Developer section of the ConfluenceCode website.
Data Structure
There are different data streams to subscribe to and each stream emits objects of different types. Every object is sent as a JSON object. You can find a list of all available streams, with more specific information about the objects they emit, in the Streams pages, for example Streams: Trade. It is useful to know that even though every stream emits objects of different types, all objects share some common properties. These are:
{
"i": "3ee64893-3ff3-5354-8b3c-56362f232b44", // A unique id of the object
"k": "trade", // The event type (kind) of the object
"e": 2, // The exchange id where this trade took place
"m": "BTC-USDT", // The market's unique name on the exchange
"b": "BTC", // The base asset of the market
"c": "USDT", // The quote (counter) asset of the market
"t": 1621360800000, // The timestamp at which the trade took place on the specific exchange (in milliseconds)
"d": false // A boolean indicating if the market is a derivative market
// ... other properties specific to the object type
}
It is also useful to know that the i
property is considered to be unique for each object type. Meaning the combination of i
and k
is unique for any object.