LogoLogo
  • Getting Started
  • How to Connect
  • REST API
    • Order
    • PublicMarketData
    • Wallet
    • Trade
    • Models
  • Smart Contract ABI
    • OrderBook
    • Order Data (explanation)
  • Websocket API
    • Orderbook
    • Ticker
  • SDK Documentation
    • Getting Started
    • REST API Interaction
    • Smart Contract Interaction
      • Order Placement
      • Order Cancelation
Powered by GitBook

Privacy

  • Privacy Policy

All rights reserved. 21X AG

On this page
  • Orderbook data
  • Overview
  • Channel
  • Subscription
  • Market Data Model
Export as PDF
  1. Websocket API

Orderbook

Orderbook data

This guide explains how to use the WebSocket API to subscribe to market data updates via the /orderbook channel.


Overview

The WebSocket API allows clients to receive real-time market data updates. Subscribing to the /orderbook channel provides updates for market ticker data, including prices, bids, asks, and quantities.


Channel

/orderbook/*

  • Subscribe to get ticker data from all active markets.

/orderbook/bytradingpair/{market symbol}

  • Subscribe to get ticker data from specific markets

  • Client may be subscribed to many markets at the same time.


Subscription

{
    "id": "94c68f6e-44ba-46ec-b9fb-4eb7addfe5ea",
    "type": "subscribe",
    "channel": "orderbook/*",
    "authorization": {
        "host": "vfqqino6svadzoqkann4355in4.appsync-api.eu-central-1.amazonaws.com",
        "x-amz-date": "20250117T133706Z",
        "x-api-key": "da2-vjlcb7rsira4bggsctnmzcjvwe"
    }
}
{"id":"94c68f6e-44ba-46ec-b9fb-4eb7addfe5ea","type":"subscribe_success"}

Market Data Model

When subscribed to the /orderbook channel, the server sends market data updates in the following format:

Level 2 Market Data Example

Example message

{
  "channel": "orderbook",
  "data": [
    {
      "symbol": "ABCEUROe",
      "buy": [
        {
          "limit": 120.05,
          "totalQuantity": 36,
          "orderCount": 2
        },
        {
          "limit": 120.0,
          "totalQuantity": 65,
          "orderCount": 1
        }
      ],
      "sell": [
        {
          "limit": 120.2,
          "totalQuantity": 150.5,
          "orderCount": 3
        },
        {
          "limit": 120.5,
          "totalQuantity": 77,
          "orderCount": 1
        }
      ],
      "time": "2024-12-16T12:28:22.462Z"
    }
  ]
}

Field Descriptions

Field
Type
Description

channel

String

The type of data channel, e.g., "orderbook".

data

Array

Array containing market data for the specified symbol.

symbol

String

The trading pair, e.g., "ABCEUROe".

buy

Array of Objects

List of buy orders with price levels and quantities.

sell

Array of Objects

List of sell orders with price levels and quantities.

limit

Number

Price limit for the order.

totalQuantity

Number

Total quantity of orders at the price level.

orderCount

Number

Number of orders at the price level.

time

String (ISO 8601)

Timestamp of the market data.

PreviousWebsocket APINextTicker

Last updated 1 month ago