> ## Documentation Index
> Fetch the complete documentation index at: https://docs.bulk.trade/llms.txt
> Use this file to discover all available pages before exploring further.

# L2 Order Book Deltas

> L2 Order Book Deltas WebSocket subscription and response reference.

Connect to `wss://mainnet-ws1.bulk.trade`, then send the subscription below. All channels share the same socket; the page name is not a separate endpoint path. The playground sends read-only subscription messages.

Real-time incremental order book updates with initial snapshot.

> [!NOTE]
>
> L2 Delta sends an initial snapshot from the current cached delta book when available,
> then publishes every changed price level for an instrument update together in
> one atomic delta message.

```json Subscribe theme={null}
{
  "method": "subscribe",
  "subscription": [{
    "type": "l2Delta",
    "symbol": "BTC-USD"
  }]
}
```

```json Response theme={null}
{
  "type": "subscriptionResponse",
  "topics": ["l2delta.BTC-USD"]
}
```

```json Atomic Delta Batch theme={null}
{
  "type": "l2Delta",
  "data": {
    "book": {
      "updateType": "delta",
      "symbol": "BTC-USD",
      "levels": [
        [
          {"px": 102777.0, "sz": 2.0, "n": 0},
          {"px": 102776.0, "sz": 0.0, "n": 0}
        ],
        [{"px": 102780.0, "sz": 1.5, "n": 0}]
      ],
      "timestamp": 1699564800000000000
    }
  },
  "topic": "l2delta.BTC-USD"
}
```

**Initial Response**: A message with outer `type: "l2Delta"`, topic
`l2delta.BTC-USD`, and `data.book.updateType: "snapshot"`. Its `levels` replace
both sides of your local book. No initial snapshot is sent if no cached book
exists yet; do not treat the subscription confirmation as book readiness.

**Updates**: Real-time, one message per instrument update batch

**Delta Format**:

* Each delta message contains every changed price level in the instrument's update batch
* A message may contain multiple bid and ask changes; either side may be empty
* `levels[0]` = bids (highest to lowest)
* `levels[1]` = asks (lowest to highest)
* Each level: `{px, sz, n}` where `sz` is the new absolute size at that price,
  not an amount to add, and `n` is always `0` for deltas
* `sz: 0` means remove the level
* `timestamp` is Unix time in nanoseconds, not a sequence number

Apply all levels in a delta message atomically before exposing the updated
local book. The subscription snapshot establishes a timestamp cutoff: the
network endpoint suppresses queued deltas at or before that snapshot's timestamp.

> [!WARNING]
>
> The current wire format has no `seq`, `bookVersion`, checksum, or resume
> cursor. Timestamps alone cannot prove that all intermediate deltas arrived.
> A slow or interrupted consumer can miss updates without a gap notification.
> If continuity is uncertain, discard the local book, reconnect and subscribe to
> `l2Delta` again, then wait for its initial snapshot before applying deltas.
> An independently requested `l2Snapshot` is not a sequenced handoff into an
> existing delta stream. Use the periodic snapshot stream when your application
> needs independent complete depth views.

## Connection and Limits

See [connection management](https://docs.bulk.trade/api-reference/ws-connection.md) for reconnect behavior and [public rate limits](https://docs.bulk.trade/api-reference/rate-limits.md) for connection budgets.


## AsyncAPI

````yaml api-reference/asyncapi.yaml l2-deltas
id: l2-deltas
title: L2 deltas
description: >-
  Cached initial data.book.updateType=snapshot when available, then atomic delta
  batches. Apply absolute sizes; zero deletes a level. No sequence, checksum or
  resume cursor. Reconnect and await a fresh snapshot when continuity is
  uncertain. Connect, then send subscribe; unsubscribe uses the acknowledged
  topic. Unsubscribe using the acknowledged topic; see [Connection
  Management](/api-reference/ws-connection#unsubscribe).
servers:
  - id: mainnet
    protocol: wss
    host: mainnet-ws1.bulk.trade
    bindings: []
    variables: []
  - id: testnet
    protocol: wss
    host: exchange-ws1.bulk.trade
    bindings: []
    variables: []
address: /
parameters: []
bindings: []
operations:
  - &ref_1
    id: l2-deltasSubscribe
    title: L2 deltas subscribe
    type: receive
    messages:
      - &ref_3
        id: subscribe
        contentType: application/json
        payload:
          - name: L2 deltas subscribe
            description: >-
              Schema defaults on this request are playground example prefills,
              not omitted-field defaults accepted by the network endpoint.
            type: object
            properties:
              - name: method
                type: string
                enumValues:
                  - subscribe
                required: true
              - name: subscription
                type: array
                description: >-
                  Playground example prefill. Send the subscription array
                  explicitly; this is not a network-side default.
                required: true
                properties:
                  - name: type
                    type: string
                    enumValues:
                      - l2Delta
                    required: true
                  - name: symbol
                    type: string
                    description: Playground example prefill; not a network-side default.
                    required: true
        headers: []
        jsonPayloadSchema:
          type: object
          properties:
            method:
              type: string
              enum:
                - subscribe
              default: subscribe
              x-parser-schema-id: <anonymous-schema-126>
            subscription:
              type: array
              items:
                type: object
                properties:
                  type:
                    type: string
                    enum:
                      - l2Delta
                    default: l2Delta
                    x-parser-schema-id: <anonymous-schema-129>
                  symbol:
                    type: string
                    default: BTC-USD
                    description: Playground example prefill; not a network-side default.
                    x-parser-schema-id: <anonymous-schema-130>
                required:
                  - type
                  - symbol
                x-parser-schema-id: <anonymous-schema-128>
              minItems: 1
              default:
                - type: l2Delta
                  symbol: BTC-USD
              description: >-
                Playground example prefill. Send the subscription array
                explicitly; this is not a network-side default.
              x-parser-schema-id: <anonymous-schema-127>
          required:
            - method
            - subscription
          x-parser-schema-id: <anonymous-schema-125>
        title: L2 deltas subscribe
        description: >-
          Schema defaults on this request are playground example prefills, not
          omitted-field defaults accepted by the network endpoint.
        example: |-
          {
            "method": "subscribe",
            "subscription": [
              {
                "type": "l2Delta",
                "symbol": "BTC-USD"
              }
            ]
          }
        bindings: []
        extensions:
          - id: x-parser-unique-object-id
            value: subscribe
    bindings: []
    extensions: &ref_0
      - id: x-parser-unique-object-id
        value: l2-deltas
  - &ref_2
    id: l2-deltasEvents
    title: L2 deltas events
    type: send
    messages:
      - &ref_4
        id: l2Delta
        contentType: application/json
        payload:
          - name: L2 deltas l2Delta
            description: Network-published l2Delta
            type: object
            properties:
              - name: type
                type: string
                enumValues:
                  - l2Delta
                required: true
              - name: data
                type: object
                required: true
                properties:
                  - name: book
                    type: object
                    required: false
                    properties:
                      - name: updateType
                        type: string
                        required: false
                      - name: symbol
                        type: string
                        required: false
                      - name: levels
                        type: array
                        description: >-
                          [bids, asks]. Delta sizes are absolute; zero deletes a
                          price level.
                        required: false
                        properties:
                          - name: item
                            type: array
                            required: false
                            properties:
                              - name: px
                                type: number
                                required: false
                              - name: sz
                                type: number
                                required: false
                              - name: 'n'
                                type: number
                                required: false
                      - name: timestamp
                        type: number
                        description: Unix timestamp in nanoseconds.
                        required: false
              - name: topic
                type: string
                required: true
        headers: []
        jsonPayloadSchema:
          type: object
          properties:
            type:
              type: string
              enum:
                - l2Delta
              x-parser-schema-id: <anonymous-schema-132>
            data:
              type: object
              properties:
                book:
                  type: object
                  properties:
                    updateType:
                      type: string
                      x-parser-schema-id: <anonymous-schema-135>
                    symbol:
                      type: string
                      x-parser-schema-id: <anonymous-schema-136>
                    levels:
                      type: array
                      items:
                        type: array
                        items:
                          type: object
                          properties:
                            px:
                              type: number
                              x-parser-schema-id: <anonymous-schema-140>
                            sz:
                              type: number
                              x-parser-schema-id: <anonymous-schema-141>
                            'n':
                              type: number
                              x-parser-schema-id: <anonymous-schema-142>
                          x-parser-schema-id: <anonymous-schema-139>
                        x-parser-schema-id: <anonymous-schema-138>
                      minItems: 2
                      maxItems: 2
                      description: >-
                        [bids, asks]. Delta sizes are absolute; zero deletes a
                        price level.
                      x-parser-schema-id: <anonymous-schema-137>
                    timestamp:
                      type: number
                      description: Unix timestamp in nanoseconds.
                      x-parser-schema-id: <anonymous-schema-143>
                  x-parser-schema-id: <anonymous-schema-134>
              x-parser-schema-id: <anonymous-schema-133>
            topic:
              type: string
              x-parser-schema-id: <anonymous-schema-144>
          required:
            - type
            - data
            - topic
          x-parser-schema-id: <anonymous-schema-131>
        title: L2 deltas l2Delta
        description: Network-published l2Delta
        example: |-
          {
            "type": "l2Delta",
            "data": {
              "book": {
                "updateType": "snapshot",
                "symbol": "BTC-USD",
                "levels": [
                  [
                    {
                      "px": 102777,
                      "sz": 2,
                      "n": 0
                    },
                    {
                      "px": 102776,
                      "sz": 0,
                      "n": 0
                    }
                  ],
                  [
                    {
                      "px": 102780,
                      "sz": 1.5,
                      "n": 0
                    }
                  ]
                ],
                "timestamp": 1699564800000000000
              }
            },
            "topic": "l2delta.BTC-USD"
          }
        bindings: []
        extensions:
          - id: x-parser-unique-object-id
            value: l2Delta
      - &ref_5
        id: subscribed
        contentType: application/json
        payload:
          - name: L2 deltas subscribed
            type: object
            properties:
              - name: type
                type: string
                enumValues:
                  - subscriptionResponse
                required: true
              - name: topics
                type: array
                required: false
                properties:
                  - name: item
                    type: string
                    required: false
        headers: []
        jsonPayloadSchema:
          type: object
          properties:
            type:
              type: string
              enum:
                - subscriptionResponse
              x-parser-schema-id: <anonymous-schema-146>
            topics:
              type: array
              items:
                type: string
                x-parser-schema-id: <anonymous-schema-148>
              x-parser-schema-id: <anonymous-schema-147>
          required:
            - type
          x-parser-schema-id: <anonymous-schema-145>
        title: L2 deltas subscribed
        example: |-
          {
            "type": "subscriptionResponse",
            "topics": [
              "l2delta.BTC-USD"
            ]
          }
        bindings: []
        extensions:
          - id: x-parser-unique-object-id
            value: subscribed
      - &ref_6
        id: unsubscribed
        contentType: application/json
        payload:
          - name: L2 deltas unsubscribed
            type: object
            properties:
              - name: type
                type: string
                enumValues:
                  - unsubscribeResponse
                required: true
              - name: topic
                type: string
                required: false
        headers: []
        jsonPayloadSchema:
          type: object
          properties:
            type:
              type: string
              enum:
                - unsubscribeResponse
              x-parser-schema-id: <anonymous-schema-150>
            topic:
              type: string
              x-parser-schema-id: <anonymous-schema-151>
          required:
            - type
          x-parser-schema-id: <anonymous-schema-149>
        title: L2 deltas unsubscribed
        example: |-
          {
            "type": "unsubscribeResponse",
            "topic": "l2delta.BTC-USD"
          }
        bindings: []
        extensions:
          - id: x-parser-unique-object-id
            value: unsubscribed
    bindings: []
    extensions: *ref_0
sendOperations:
  - *ref_1
receiveOperations:
  - *ref_2
sendMessages:
  - *ref_3
receiveMessages:
  - *ref_4
  - *ref_5
  - *ref_6
extensions:
  - id: x-parser-unique-object-id
    value: l2-deltas
securitySchemes: []

````

This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.