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

# Level 2 order book

> Guarantees delivery of all updates and is the easiest way to keep an order
book snapshot in sync. Subscribe with channel level2; received messages
carry channel l2_data. new_quantity is the updated size at a price level
(not a delta); a value of "0" means the level can be removed.




## AsyncAPI

````yaml api-reference/advanced-trade-api/advanced-trade-asyncapi.json level2
id: level2
title: Level 2 order book
description: |
  Guarantees delivery of all updates and is the easiest way to keep an order
  book snapshot in sync. Subscribe with channel level2; received messages
  carry channel l2_data. new_quantity is the updated size at a price level
  (not a delta); a value of "0" means the level can be removed.
servers:
  - id: production
    protocol: wss
    host: advanced-trade-ws.coinbase.com
    bindings: []
    variables: []
address: level2
parameters: []
bindings: []
operations:
  - &ref_2
    id: level2Subscribe
    title: Subscribe to level2
    description: Client sends a subscribe or unsubscribe request for the level2 channel.
    type: receive
    messages:
      - &ref_4
        id: subscribe_request
        contentType: application/json
        payload:
          - name: Subscription request
            description: Subscribe or unsubscribe to the level2 channel.
            type: object
            properties:
              - name: type
                type: string
                enumValues:
                  - subscribe
                  - unsubscribe
                required: true
              - name: channel
                type: string
                required: true
              - name: product_ids
                type: array
                description: Products to subscribe to, e.g. ["BTC-USD"].
                required: true
                properties:
                  - name: item
                    type: string
                    required: false
              - name: jwt
                type: string
                description: >-
                  CDP JWT. Optional here; recommended for connection
                  reliability.
                required: false
        headers: []
        jsonPayloadSchema:
          type: object
          additionalProperties: false
          required:
            - type
            - channel
            - product_ids
          properties:
            type:
              type: string
              enum:
                - subscribe
                - unsubscribe
              default: subscribe
              x-parser-schema-id: <anonymous-schema-102>
            channel:
              type: string
              default: level2
              x-parser-schema-id: <anonymous-schema-103>
            product_ids:
              type: array
              items:
                type: string
                x-parser-schema-id: <anonymous-schema-105>
              description: Products to subscribe to, e.g. ["BTC-USD"].
              x-parser-schema-id: <anonymous-schema-104>
            jwt:
              type: string
              description: CDP JWT. Optional here; recommended for connection reliability.
              x-parser-schema-id: <anonymous-schema-106>
          x-parser-schema-id: <anonymous-schema-101>
        title: Subscription request
        description: Subscribe or unsubscribe to the level2 channel.
        example: |-
          {
            "type": "subscribe",
            "channel": "level2",
            "product_ids": [
              "BTC-USD"
            ]
          }
        bindings: []
        extensions:
          - id: x-parser-unique-object-id
            value: subscribe_request
    bindings: []
    extensions: &ref_1
      - id: x-parser-unique-object-id
        value: level2
  - &ref_3
    id: level2Stream
    title: Level 2 stream
    description: Server streams order book updates (channel l2_data) to subscribed clients.
    type: send
    messages:
      - &ref_5
        id: l2_data
        contentType: application/json
        payload:
          - allOf: &ref_0
              - type: object
                properties:
                  channel:
                    type: string
                    description: The channel that produced this message.
                    x-parser-schema-id: <anonymous-schema-5>
                  timestamp:
                    type: string
                    format: date-time
                    description: Server time the message was sent (RFC 3339).
                    x-parser-schema-id: <anonymous-schema-6>
                  sequence_num:
                    type: integer
                    description: >-
                      Per-connection message sequence number; use it to detect
                      dropped or out-of-order messages.
                    x-parser-schema-id: <anonymous-schema-7>
                x-parser-schema-id: EnvelopeBase
              - type: object
                properties:
                  channel:
                    const: l2_data
                    x-parser-schema-id: <anonymous-schema-108>
                  events:
                    type: array
                    items:
                      type: object
                      properties:
                        type:
                          type: string
                          enum:
                            - snapshot
                            - update
                          x-parser-schema-id: <anonymous-schema-111>
                        product_id:
                          type: string
                          x-parser-schema-id: <anonymous-schema-112>
                        updates:
                          type: array
                          items:
                            type: object
                            properties:
                              side:
                                type: string
                                enum:
                                  - bid
                                  - offer
                                description: Order book side.
                                x-parser-schema-id: <anonymous-schema-114>
                              event_time:
                                type: string
                                format: date-time
                                description: >-
                                  Time of the event as recorded by the trading
                                  engine.
                                x-parser-schema-id: <anonymous-schema-115>
                              price_level:
                                type: string
                                description: Price level being updated.
                                x-parser-schema-id: <anonymous-schema-116>
                              new_quantity:
                                type: string
                                description: >-
                                  Updated size at this price level (not a
                                  delta). A value of "0" means the level can be
                                  removed.
                                x-parser-schema-id: <anonymous-schema-117>
                            x-parser-schema-id: L2Update
                          x-parser-schema-id: <anonymous-schema-113>
                      x-parser-schema-id: <anonymous-schema-110>
                    x-parser-schema-id: <anonymous-schema-109>
                x-parser-schema-id: <anonymous-schema-107>
            x-parser-schema-id: L2Envelope
            name: Level 2 message
        headers: []
        jsonPayloadSchema:
          allOf: *ref_0
          x-parser-schema-id: L2Envelope
        title: Level 2 message
        example: '{}'
        bindings: []
        extensions:
          - id: x-parser-unique-object-id
            value: l2_data
    bindings: []
    extensions: *ref_1
sendOperations:
  - *ref_2
receiveOperations:
  - *ref_3
sendMessages:
  - *ref_4
receiveMessages:
  - *ref_5
extensions:
  - id: x-parser-unique-object-id
    value: level2
securitySchemes: []

````