Websocket Server Documentation
Subscribing to channels
There are several channels that you can subscribe to. Each channel represents a different type of event that you can listen to.
To subscribe to a channel, you need to send a subscribe message to the websocket server, after you establish a connection to our websocket server. Below is an example of how to subscribe to the prices channel.
{
  "action": "subscribe",
  "channel": "prices-v1",
  "payload": [
    {
      "type": "cr",
      "asset": "BTC",
      "fiat": "EUR"
    },
    {
      "type": "s",
      "asset": "AAPL",
      "fiat": "EUR"
    }
  ]
}Where:
- 
actionis the action that you wants to perform. Supported actions are:subscribeorunsubscribe.
- 
channelis the channel that you want to subscribe to. You can subscribe to multiple channels on the same connection, or you can open multiple connections to subscribe to different channels.
- 
payloadis an array of objects containing the following fields:- 
typeis the type of the asset. It can becrfor crypto,sfor securities,ffor fiat,ifor index,cofor commodity,esfor equity_security.
- 
assetis the asset symbol.
- 
fiatis the fiat symbol
- The value can be missing and in that case it is assumed that you want to subscribe to all asset-fiat pairs.
- You can only subscribe to assets that are associated with your domain.
- 
The payload can also be of the form 
{"fiat": "EUR"}which would indicate subscription to all assets against the indicated fiat.
- 
Take into account that you cannot mix subscription types. On the same subscription action, you can only subscribe to one of:
- an asset list
- all assets against a specific fiat or more than one fiat.
- all assets against all fiats.
 
 
- 
The above rules apply for both channels that are available for subscription.
Examples
Subscribe to a list of assets
{
  "action": "subscribe",
  "channel": "prices-v1",
  "payload": [
    {
      "type": "cr",
      "asset": "BTC",
      "fiat": "EUR"
    },
    {
      "type": "s",
      "asset": "AAPL",
      "fiat": "EUR"
    }
  ]
}Subscribe to all assets against a specific fiat
{
  "action": "subscribe",
  "channel": "prices-v1",
  "payload": [
    {
      "fiat": "EUR"
    }
  ]
}Subscribe to all assets against multiple fiats
{
  "action": "subscribe",
  "channel": "prices-v1",
  "payload": [
    {
      "fiat": "EUR"
    },
    {
      "fiat": "USD"
    }
  ]
}Subscribe to all assets against all fiats
{
  "action": "subscribe",
  "channel": "prices-v1"
}Success messages
For each action taken, if the action was successful, you will receive a success message from the server.
Here is an example of a success message:
{
    "action": "subscribe",
    "channel": "prices-v1",
    "status": "success"
}Error messages
If there is an error in the subscription message, you will receive an error message from the server.
Here are some examples of error messages:
Invalid channel
{
  "action": "subscribe",
  "channel": "non-existent-channel",
  "error": "channel not supported"
}Invalid fiat
{
  "action": "subscribe",
  "channel": "price-changes-v1",
  "error": "fiat not found: XXX"
}Where XXX is the symbol of the fiat that you tried to subscribe to and is not supported.
Asset not found for domain
{
  "action": "subscribe",
  "channel": "price-changes-v1",
  "error": "asset not found for domain: ABC"
}Where ABC is the symbol of the asset that you tried to subscribe to and is not associated with your domain.
Supported Channels
The following channels are available for subscription:
- 
prices-v1: This channel provides real-time price updates for assets. Each asset-fiat pair receives an update roughly every 15 seconds.
- 
price-changes-v1: This channel provides real-time price changes for assets.
Price Updates
Below is an example of a message that you will receive when you subscribe to the prices-v1 channel.
{
  "AP":"65544.85350",
  "BP":"65217.84675",
  "U": 1706521791,
  "T": "cr",
  "A": "BTC",
  "F": "EUR",
  "CH": "prices-v1"
}Where:
- 
APis the ask price
- 
BPis the bid price
- 
Uis the unix timestamp of the update
- 
Tis the type of the asset. It can becrfor crypto,sfor securities,ffor fiat,ifor index,cofor commodity,esfor equity_security.
- 
Ais the asset symbol
- 
Fis the fiat symbol
- 
CHis the channel
Price Changes
Below is an example of a message that you will receive when you subscribe to the price-changes-v1 channel.
{
  "T": "cr",
  "A": "BTC",
  "F": "EUR",
  "CH": "price-changes-v1",
  "D": "-1.5133276010318143",
  "I": "1.273209549071618",
  "W": "-1.8677176148046607",
  "M": "0.297723292469352",
  "6M": "-7.9408455232277769",
  "Y": "-24.3261099365750529",
  "5Y": "-26.7534660050135571",
  "DV": "-0.88",
  "IV": "0.72",
  "WV": "-1.09",
  "MV": "0.17",
  "6MV": "-4.94",
  "YV": "-18.41",
  "5YV": "-20.918",
  "MVOL": "0.1185439986130654"
}Where:
- 
Tis the type of the asset. It can becrfor crypto,sfor securities,ffor fiat,ifor index,cofor commodity,esfor equity_security.
- 
Ais the asset symbol
- 
Fis the fiat symbol
- 
CHis the channel
- 
Dis the daily change in %
- 
Iis the intraday change in %
- 
Wis the weekly change in %
- 
Mis the monthly change in %
- 
6Mis the 6 month change in %
- 
Yis the yearly change in %
- 
5Yis the 5 year change in %
- 
DVis the daily change in value
- 
IVis the intraday change in value
- 
WVis the weekly change in value
- 
MVis the monthly change in value
- 
6MVis the 6 month change in value
- 
YVis the yearly change in value
- 
5YVis the 5 year change in value
- 
MVOLis the monthly volatility
Be advised that price changes are available only for EUR for now. Subscription to other fiats will work, but you will not receive any messages for those fiats.
Unsubscribing from channels
To unsubscribe from a channel, you need to send an unsubscribe message to the websocket server. Below is an example of how to unsubscribe from the prices channel.
{
  "action": "unsubscribe",
  "channel": "prices-v1"
}You cannot unsubscribe selectively from assets. You can only unsubscribe from the entire channel.
Ping/Pong
Our websocket server supports ping/pong messages, in accordance with RFC 6455.
If the connection is idle for one minute or more, the server will close the connection. In order to avoid this, you need to send a ping message to the server at least once per minute. The server will respond with a pong message.
Supported fiats and assets
Fiats: Price changes are available only for EUR for now. Subscription to other fiats will work, but you will not receive any messages for those fiats. Assets: You can only subscribe to assets that are associated with your domain.