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

# Market depth

> Order book depth for one Decibel market address, perp or spot, with aggregated price levels. Spot BTC and perp BTC are different markets with different addresses and require separate subscriptions. The depth payload does not carry `asset_type`; the subscribed market address identifies the product. Optional aggregationLevel parameter (1, 2, 5, 10, 100, or 1000) can be appended to the topic and defaults to 1. Spot clients derive mid price from `best_bid` and `best_ask` because spot markets do not publish `market_price`.



## AsyncAPI

````yaml api-reference/asyncapi.json marketDepth
id: marketDepth
title: Market depth
description: >-
  Order book depth for one Decibel market address, perp or spot, with aggregated
  price levels. Spot BTC and perp BTC are different markets with different
  addresses and require separate subscriptions. The depth payload does not carry
  `asset_type`; the subscribed market address identifies the product. Optional
  aggregationLevel parameter (1, 2, 5, 10, 100, or 1000) can be appended to the
  topic and defaults to 1. Spot clients derive mid price from `best_bid` and
  `best_ask` because spot markets do not publish `market_price`.
servers:
  - id: testnet
    protocol: wss
    host: api.testnet.aptoslabs.com/decibel/ws
    bindings: []
    variables: []
address: depth:{marketAddr}:{aggregationLevel}
parameters:
  - id: aggregationLevel
    jsonSchema:
      type: string
      description: Price aggregation level for order book depth (1, 2, 5, 10, 100, or 1000)
    description: Price aggregation level for order book depth (1, 2, 5, 10, 100, or 1000)
    type: string
    required: true
    deprecated: false
  - id: marketAddr
    jsonSchema:
      type: string
      description: Market address (Aptos address format, e.g. 0x456...)
    description: Market address (Aptos address format, e.g. 0x456...)
    type: string
    required: true
    deprecated: false
bindings: []
operations:
  - &ref_3
    id: receivemarketDepth
    title: Receivemarket depth
    description: >-
      Receive updates for order book depth for one decibel market address, perp
      or spot, with aggregated price levels. spot btc and perp btc are different
      markets with different addresses and require separate subscriptions. the
      depth payload does not carry `asset_type`; the subscribed market address
      identifies the product. optional aggregationlevel parameter (1, 2, 5, 10,
      100, or 1000) can be appended to the topic and defaults to 1. spot clients
      derive mid price from `best_bid` and `best_ask` because spot markets do
      not publish `market_price`.
    type: receive
    messages:
      - &ref_4
        id: MarketDepthMessage
        payload:
          - name: MarketDepthMessage
            description: >-
              Order book depth for one Decibel market address, perp or spot,
              with aggregated price levels. Spot BTC and perp BTC are different
              markets with different addresses and require separate
              subscriptions. The depth payload does not carry `asset_type`; the
              subscribed market address identifies the product. Optional
              aggregationLevel parameter (1, 2, 5, 10, 100, or 1000) can be
              appended to the topic and defaults to 1. Spot clients derive mid
              price from `best_bid` and `best_ask` because spot markets do not
              publish `market_price`.
            type: object
            properties:
              - name: asks
                type: array
                required: true
                properties:
                  - name: price
                    type: number
                    required: true
                  - name: size
                    type: number
                    required: true
              - name: best_ask
                type: &ref_0
                  - number
                  - 'null'
                description: >-
                  True best ask price (pre-aggregation), useful for accurate
                  spread calculation at higher aggregation levels
                required: false
              - name: best_bid
                type: &ref_1
                  - number
                  - 'null'
                description: >-
                  True best bid price (pre-aggregation), useful for accurate
                  spread calculation at higher aggregation levels
                required: false
              - name: bids
                type: array
                required: true
                properties:
                  - name: price
                    type: number
                    required: true
                  - name: size
                    type: number
                    required: true
              - name: market
                type: string
                required: true
              - name: topic
                type: string
                required: true
              - name: unix_ms
                type: integer
                description: Latest transaction timestamp in milliseconds
                required: true
        headers: []
        jsonPayloadSchema:
          type: object
          required:
            - topic
            - market
            - bids
            - asks
            - unix_ms
          properties:
            asks:
              type: array
              items: &ref_2
                type: object
                required:
                  - price
                  - size
                properties:
                  price:
                    type: number
                    format: double
                    x-parser-schema-id: <anonymous-schema-178>
                  size:
                    type: number
                    format: double
                    x-parser-schema-id: <anonymous-schema-179>
                x-parser-schema-id: NormalizedPriceLevel
              x-parser-schema-id: <anonymous-schema-177>
            best_ask:
              type: *ref_0
              format: double
              description: >-
                True best ask price (pre-aggregation), useful for accurate
                spread calculation at higher aggregation levels
              x-parser-schema-id: <anonymous-schema-180>
            best_bid:
              type: *ref_1
              format: double
              description: >-
                True best bid price (pre-aggregation), useful for accurate
                spread calculation at higher aggregation levels
              x-parser-schema-id: <anonymous-schema-181>
            bids:
              type: array
              items: *ref_2
              x-parser-schema-id: <anonymous-schema-182>
            market:
              type: string
              x-parser-schema-id: <anonymous-schema-183>
            topic:
              type: string
              x-parser-schema-id: <anonymous-schema-184>
            unix_ms:
              type: integer
              format: int64
              description: Latest transaction timestamp in milliseconds
              x-parser-schema-id: <anonymous-schema-185>
          x-parser-schema-id: MarketDepthResponse
        title: Market depth message
        description: >-
          Order book depth for one Decibel market address, perp or spot, with
          aggregated price levels. Spot BTC and perp BTC are different markets
          with different addresses and require separate subscriptions. The depth
          payload does not carry `asset_type`; the subscribed market address
          identifies the product. Optional aggregationLevel parameter (1, 2, 5,
          10, 100, or 1000) can be appended to the topic and defaults to 1. Spot
          clients derive mid price from `best_bid` and `best_ask` because spot
          markets do not publish `market_price`.
        example: |-
          {
            "topic": "depth:0xabcdef1234567890abcdef1234567890abcdef1234567890abcdef1234567890:1",
            "market": "0xabcdef1234567890abcdef1234567890abcdef1234567890abcdef1234567890",
            "bids": [
              {
                "price": 50000,
                "size": 10.5
              },
              {
                "price": 49950,
                "size": 15.2
              },
              {
                "price": 49900,
                "size": 20
              }
            ],
            "asks": [
              {
                "price": 50050,
                "size": 8.3
              },
              {
                "price": 50100,
                "size": 12.7
              },
              {
                "price": 50150,
                "size": 18.5
              }
            ],
            "unix_ms": 1699564800000,
            "best_bid": 50000,
            "best_ask": 50050
          }
        bindings: []
        extensions:
          - id: x-parser-unique-object-id
            value: MarketDepthMessage
          - id: x-parser-message-name
            value: MarketDepthMessage
    bindings: []
    extensions:
      - id: x-parser-unique-object-id
        value: marketDepth
sendOperations:
  - *ref_3
receiveOperations: []
sendMessages:
  - *ref_4
receiveMessages: []
extensions:
  - id: x-parser-unique-object-id
    value: marketDepth
securitySchemes: []

````