WebSocket API documentation


About

WebSocket API is powered by socket.io. All examples below are based on socket.io.

Getting market updates (public)

    
      var socket = io();

      // Subscribe to market updates.
      socket.emit('market', 'btcxrp');

      socket.on('orderbook_updates__btcusd', function(message) {
        /*
          Message has the following content:

          {
            "data": [
              {
                "market": "btcusd",
                "event": "add",
                "from": "bids",
                "data": [
                  {
                    "id": "7l211dtju7d00gadgo",
                    "price": "5766.13",
                    "volume": "0.1113",
                    "timestamp": 1541011693.351
                  }
                ]
              }
            ]
          }
        */
      });

      socket.on('trades_updates__btcusd', function(message) {
        /*
          Message has the following content:

            {
              "data": [
                {
                  "id": "7l1dtju7e005e2p2",
                  "price": "6003.37",
                  "volume": "0.03",
                  "total_value": "180.1011",
                  "timestamp": "2018-10-31T18:48:14.000000Z",
                  "direction": 1
                }
              ]
            }
        */
      });
    
  

Getting ticker updates (public)

    
      var socket = io();

      // All WS clients are automatically subscribed to ticker updates.

      socket.on('tickers', function(message) {
        /*
          Message has the following content:

          {
            "data": [
              {
                "market": "bchcad",
                "ticker": {
                  "open": "575.7",
                  "last": "576.18",
                  "high": "599.7929",
                  "low": "510.2031",
                  "buy": "536.9",
                  "sell": "594.47",
                  "vol": "12238.78065826"
                }
              },
              {
                "market": "ltceur",
                "ticker": {
                  "open": "42.1258",
                  "last": "43.1622",
                  "high": "46.25",
                  "low": "40.04",
                  "buy": "44.64",
                  "sell": "46.2",
                  "vol": "101033.10176358"
                }
              },
              {
                "market": "gntxrp",
                "ticker": {
                  "open": "0.3608",
                  "last": "0.3696",
                  "high": "0.411",
                  "low": "0.34",
                  "buy": "0.35",
                  "sell": "0.3696",
                  "vol": "27603427.6457799"
                }
              }
            ]
          }
        */
      });
    
  

Getting updates for user orders (private channel)

    
      var socket = io();

      // Subscribe to private channel.
      var jwt = 'JSON Web Token goes here';
      socket.emit('subscribe', 'user:orders', jwt);

      socket.on('user:orders', function(message) {
        /*
          Message has the following content:

          [
            {
              "id": "mp211dtjv63009bt9q",
              "market": "ethxrp",
              "type": "bid",
              "strategy": "limit",
              "state": "closed",
              "uid": "IDA111DB7827",
              "income_unit": "eth",
              "income_fee_type": "relative",
              "income_fee_value": "0.0069",
              "outcome_unit": "xrp",
              "outcome_fee_type": "relative",
              "outcome_fee_value": "0.0",
              "initial_income_amount": "20.0",
              "current_income_amount": "0.0",
              "initial_outcome_amount": "9400.0",
              "current_outcome_amount": "243.9525382504",
              "trades_count": 16,
              "created_at": "2018-10-31T19:04:35.000000Z",
              "price": "470.0",
              "previous_income_amount": "3.34",
              "previous_outcome_amount": "1780.3525382504",
              "updated_at": "2018-10-31T19:04:35.000000Z"
            }
          ]
        */
      });
    
  

Getting updates for user trades (private channel)

    
      var socket = io();

      // Subscribe to private channel.
      var jwt = 'JSON Web Token goes here';
      socket.emit('subscribe', 'user:trades', jwt);

      socket.on('user:trades', function(message) {
        /*
          Message has the following content:

          [
            {
              "id": "mp1dtjvai005b16m",
              "market": "ethxrp",
              "price": "461.54",
              "buyer_uid": "IDA111DB7827",
              "buyer_income_unit": "eth",
              "buyer_income_amount": "0.54",
              "buyer_income_fee": "0.003726",
              "buyer_outcome_unit": "xrp",
              "buyer_outcome_amount": "249.2316",
              "buyer_outcome_fee": "0.0",
              "seller_uid": "ID8493025B3A",
              "seller_income_unit": "xrp",
              "seller_income_amount": "249.2316",
              "seller_income_fee": "1.22123484",
              "seller_outcome_unit": "eth",
              "seller_outcome_amount": "0.54",
              "seller_outcome_fee": "0.0",
              "executed_at": "2018-10-31T19:06:58.000000Z"
            }
          ]
        */
      });
    
  

Getting updates for user rewards (private channel)

    
      var socket = io();

      // Subscribe to private channel.
      var jwt = 'JSON Web Token goes here';
      socket.emit('subscribe', 'user:rewards', jwt);

      socket.on('user:rewards', function(message) {
        /*
          Message has the following content:

          [
            {
              "id": 20436476,
              "type": "trading",
              "currency": "xrp",
              "amount": "0.4497877825",
              "created_at": "2018-10-31T19:07:36Z",
              "executed_at": "2018-10-31T19:07:36Z"
            }
          ]
        */
      });
    
  

Getting updates for user deposits (private channel)

    
      var socket = io();

      // Subscribe to private channel.
      var jwt = 'JSON Web Token goes here';
      socket.emit('subscribe', 'user:deposits', jwt);

      socket.on('user:deposits', function(message) {
        /*
          Message has the following content:

          [
            {
              "attributes": {
                "id": 618,
                "uid": "IDA111DB7827",
                "type": "coin",
                "currency": "xrp",
                "amount": "9900.0",
                "fee": "0.0",
                "state": "submitted",
                "created_at": "2018-10-31T19:11:17.000000Z",
                "updated_at": "2018-10-31T19:11:17.000000Z",
                "address": "r3vxXRSLQScpFPdBu2ChyKVfS9gcU736Gp?dt=32",
                "txid": "69ABA894692A7097108FEF70C77BAF5B8F774B1EB8CE155696495F1FAF0A43D7",
                "confirmations": 22
              }
            }
          ]
        */
      });
    
  

Getting updates for user withdrawals (private channel)

    
      var socket = io();

      // Subscribe to private channel.
      var jwt = 'JSON Web Token goes here';
      socket.emit('subscribe', 'user:withdrawals', jwt);

      socket.on('user:withdrawals', function(message) {
        /*
          Message has the following content:

          [
            {
              "attributes": {
                "id": 380,
                "uid": "IDA111DB7827",
                "rid": "mxC3Zv2MANUsNx15iB6XT84Wp4vZWrPuJk",
                "currency": "btc",
                "type": "coin",
                "amount": "0.1",
                "fee": "0.00049",
                "state": "authorizing",
                "created_at": "2018-10-31T19:12:16.000000Z",
                "updated_at": "2018-10-31T19:12:16.000000Z"
              },
              "updates": {
                "state": "enqueued",
                "updated_at": "2018-10-31T19:12:51.000000Z"
              }
            }
          ]
        */
      });