WebSocket API

Table of Contents


All request has identical structure:

{
  type: "subscribe",
  stream: "/history/orders",
  requestId: "unique id",
  auth: {
    id: "api key",
    secret: "api secret"
  }),
  payload: {
    // payload data
  }
}
  • type (required) - type of message. Now available only subscribe.
  • stream (required) - stream.
  • requestId (required) - random unique identificator, that will be sent back by the server in response messages so the client can appropriately respond when multiple subscriptions are made.
  • auth - for secure stream need to pass api key and api secret.
  • payload - payload (filter) data. Different for different streams.

Communication schema

  • Send subscribe message.
  • If request is valid, receive subscribed type message, otherwise receive error type message.
  • Receive subscribed data in runtime.

Public Stream

Trades stream

Request:

{
  type: "subscribe",
  stream: "/public/trades",
  requestId: "unique id",
  payload: {
    market: "Market"
  }
}
  • market (required) - market symbol.

Example message:

{
  type: "message",
  stream: "/public/trades",
  requestId: "unique id",
  subscriptionId: "unique subscribtion id",
  payload: {
    id: "123456",
    price: "10.25",
    quantity: "4",
    side: "sell",
    timestamp: "2018-10-10T12:00:00.672Z"
  }
}

Orderbook stream

Request:

{
  type: "subscribe",
  stream: "/public/orderbook",
  requestId: "unique id",
  payload: {
    market: "Market"
  }
}
  • market (required) - market symbol.

Example message:

{
  type: "message",
  stream: "/public/orderbook",
  requestId: "unique id",
  subscriptionId: "unique subscribtion id",
  payload: {
    timestamp: "2018-10-10T12:00:00.672Z",
    ask: [
      {
        price: "5",
        size: "3"
      },
      {
        price: "6",
        size: "8"
      }
    ]
    bid: [
      {
        price: "4",
        size: "2"
      },
      {
        price: "1",
        size: "9"
      }
    ]
  }
}

Candles stream

Request:

{
  type: "subscribe",
  stream: "/public/candles",
  requestId: "unique id",
  payload: {
    market: "Market",
    period: "1D"
  }
}
  • market (required) - market symbol.
  • period (required) - candles period: 1D, 1H.

Example message:

{
  type: "message",
  stream: "/public/candles",
  requestId: "unique id",
  subscriptionId: "unique subscribtion id",
  payload: {
    timestamp: "2018-10-10T12:00:00.672Z",
    open: "100",
    close: "200",
    min: "50",
    max: "500",
    volume: "5",
    volumeQuote: "3"
  }
}

Tickers stream

Request:

{
  type: "subscribe",
  stream: "/public/tickers",
  requestId: "unique id",
  payload: {
    market: "Market",
    period: "1D"
  }
}
  • market (required) - market symbol.
  • period (required) - tickers period: 1D, 1H.

Example message:

{
  type: "message",
  stream: "/public/tickers",
  requestId: "unique id",
  subscriptionId: "unique subscribtion id",
  payload: {
    symbol: "Market",
    period: "1D",
    timestamp: "2018-10-10T12:00:00.672Z",
    bid: "90",
    ask: "120",
    open: "100",
    last: "200",
    low: "50",
    high: "500",
    volume: "5",
    volumeQuote: "3"
  }
}

Secure stream

History Trades stream

Request:

{
  type: "subscribe",
  stream: "/history/trades",
  requestId: "unique id",
  auth: {
    id: "api key",
    secret: "api secret"
  }),
  payload: {
    market: "Market"
  }
}
  • market (required) - market symbol.

Example message:

{
  type: "message",
  stream: "/history/trades",
  requestId: "unique id",
  subscriptionId: "unique subscribtion id",
  payload: {
    id: "123456",
    clientOrderId: "clientOrderId",
    orderId: "23456",
    symbol: "Market",
    side: "buy",
    price: "234",
    quantity: "15",
    fee: "1",
    timestamp: "2018-10-10T12:00:00.672Z"
  }
}

History Orders stream

Request:

{
  type: "subscribe",
  stream: "/history/orders",
  requestId: "unique id",
  auth: {
    id: "api key",
    secret: "api secret"
  }),
  payload: {
    market: "Market"
  }
}
  • market (required) - market symbol.

Example message:

{
  type: "message",
  stream: "/history/orders",
  requestId: "unique id",
  subscriptionId: "unique subscribtion id",
  payload: {
    id: "123456",
    clientOrderId: "clientOrderId",
    symbol: "Market",
    side: "buy",
    price: "234",
    quantity: "15",
    fee: "1",
    timestamp: "2018-10-10T12:00:00.672Z",
    status: "new",
    type: "limit",
    timeInForce: "GTC",
    quantity: "23",
    price: "14.55",
    cumQuantity: "0",
    createdAt: "2018-10-09T12:00:00.672Z",
    updatedAt: 2018-10-10T12:00:00.672Z,
    expireTime: "2018-10-11T12:00:00.672Z"
  }
}

Trading Orders stream

Request:

{
  type: "subscribe",
  stream: "/trading/orders",
  requestId: "unique id",
  auth: {
    id: "api key",
    secret: "api secret"
  }),
  payload: {
    market: "Market"
  }
}
  • market (required) - market symbol.

Example message:

{
  type: "message",
  stream: "/trading/orders",
  requestId: "unique id",
  subscriptionId: "unique subscribtion id",
  payload: {
    id: "123456",
    clientOrderId: "clientOrderId",
    symbol: "Market",
    side: "buy",
    price: "234",
    quantity: "15",
    fee: "1",
    timestamp: "2018-10-10T12:00:00.672Z",
    status: "new",
    type: "limit",
    timeInForce: "GTC",
    quantity: "23",
    price: "14.55",
    cumQuantity: "0",
    createdAt: "2018-10-09T12:00:00.672Z",
    updatedAt: 2018-10-10T12:00:00.672Z,
    expireTime: "2018-10-11T12:00:00.672Z"
  }
}