View Live Order and Market Data Updates

Subscribe to real-time order book and trade order updates through WebSocket. See the Guide.

  1. Subscribe to a live feed of all outstanding buy and sell orders on the market for specific coins and tokens. Connect to the WebSocket endpoint and send a subscribe message with the level2 channel and the product ID for the trading pair you want to monitor. The response includes a snapshot of current bids and asks.

    Prerequisites:

    API Reference

  2. Subscribe to live status updates for your trade orders, including individual fills. Connect to the WebSocket endpoint and send a subscribe message with the orders channel and your account ID. You receive messages when order statuses update, including: order created, fill updated, order completed, order canceled, and order error.

    API Reference

// 1. Subscribe to Order Books
// Connect to the WebSocket endpoint and send
// the following JSON message:
//
// GET /api/prime/trading/v1/ws
//
// {
//   "type": "subscribe",
//   "accountId": "f230fdebfa084ffebc7e00515f54603f",
//   "channel": "level2",
//   "productId": "TBTC-TUSD*"
// }
// 2. Subscribe to Trade Orders
// Connect to the WebSocket endpoint and send
// the following JSON message:
//
// GET /api/prime/trading/v1/ws
//
// {
//   "type": "subscribe",
//   "channel": "orders",
//   "accountId": "f230fdebfa084ffebc7e00515f54603f"
// }
Response
// 1. Subscribe to Order Books Response
{
  "channel": "level2",
  "type": "snapshot",
  "product": "TBTC-TUSD*",
  "time": "2020-01-01T09:35:26.465Z",
  "bids": [["7001.10", "1.5084"]],
  "asks": [["7002.55", "2.7524"]]
}

// 2. Subscribe to Trade Orders Response (Created)
{
  "channel": "order",
  "time": "2019-04-25T01:02:03.045678Z",
  "accountId": "f230fdebfa084ffebc7e00515f54603f",
  "orderId": "14db12f5-4d3d-4fd8-8ced-062aa81bb4bc",
  "clientOrderId": "my-order-1",
  "product": "TBTC-TUSD*",
  "status": "opened",
  "type": "market",
  "side": "buy",
  "quantity": "1.01"
}

// 2. Subscribe to Trade Orders Response (Fill Updated)
{
  "channel": "order",
  "time": "2019-04-25T01:02:04.045678Z",
  "accountId": "f230fdebfa084ffebc7e00515f54603f",
  "orderId": "14db12f5-4d3d-4fd8-8ced-062aa81bb4bc",
  "clientOrderId": "my-order-1",
  "product": "TBTC-TUSD*",
  "status": "opened",
  "type": "market",
  "side": "buy",
  "quantity": "1.01",
  "cumulativeQuantity": "0.50",
  "averagePrice": "7090.1",
  "tradeId": "a6a9ab1b-2947-41b7-b44d-4ce61fca8b92",
  "fillQuantity": "0.50",
  "fillPrice": "7090.1"
}

// 2. Subscribe to Trade Orders Response (Completed)
{
  "channel": "order",
  "time": "2019-04-25T01:02:03.045678Z",
  "accountId": "f230fdebfa084ffebc7e00515f54603f",
  "orderId": "14db12f5-4d3d-4fd8-8ced-062aa81bb4bc",
  "clientOrderId": "my-order-1",
  "product": "TBTC-TUSD*",
  "status": "completed",
  "type": "market",
  "side": "buy",
  "quantity": "1.01",
  "cumulativeQuantity": "1.01",
  "averagePrice": "7090.1"
}