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

# Orderbook (Depth)

## Plan Access

| Plan | Available |
| - | :-: |
| Free | ❌ |
| Starter | ✅ |
| Professional | ✅ |
| Full-Market Plans (A-Shares, HK Stocks, US Stocks) | ✅ |
| Enterprise | ✅ |

## Supported Markets

Supported markets: US Stocks, HK Stocks, A-Shares, China Futures, Crypto

## Subscribe

```json theme={null}
{
  "cmd": "subscribe",
  "data": {
    "channel": "depth",
    "symbols": ["AAPL.US", "BTCUSDT"]
  }
}
```

> `type` applies to every symbol in that subscription. Omit it when subscribing to mixed product types. If a symbol is ambiguous, split the request by product type and pass the corresponding value.

## Unsubscribe

```json theme={null}
{
  "cmd": "unsubscribe",
  "data": {
    "channel": "depth",
    "symbols": ["AAPL.US"]
  }
}
```

## Server Response

```json theme={null}
{
  "cmd": "depth",
  "data": {
    "symbol": "BTCUSDT",
    "bids": [
      ["43250.50", "0.125"],
      ["43250.00", "0.250"]
    ],
    "asks": [
      ["43251.00", "0.180"],
      ["43251.50", "0.320"]
    ],
    "timestamp": 1703123456789
  }
}
```

### Fields

| Field | Type | Description |
| - | - | - |
| symbol | string | Trading symbol |
| bids | array | Bid levels: `[price, quantity]` |
| asks | array | Ask levels: `[price, quantity]` |
| timestamp | int | Server timestamp in ms |

**Ordering**

* `bids`: price descending
* `asks`: price ascending


## AsyncAPI

````yaml asyncapi.en.json depth
id: depth
title: Depth
description: ''
servers:
  - id: production
    protocol: wss
    host: api.tickdb.ai
    bindings: []
    variables: []
address: /v1/realtime
parameters: []
bindings: []
operations:
  - &ref_3
    id: subscribeToDepth
    title: Subscribe to depth
    type: send
    messages:
      - &ref_5
        id: depthData
        contentType: application/json
        payload:
          - name: Orderbook Data
            description: Real-time order book depth data pushed from server
            type: object
            properties:
              - name: cmd
                type: string
                description: Message type
                required: true
              - name: data
                type: object
                required: true
                properties:
                  - name: symbol
                    type: string
                    description: Trading symbol
                    required: true
                  - name: type
                    type: string
                    description: Symbol type
                    enumValues:
                      - stock
                      - indices
                      - crypto
                      - forex
                      - futures
                    required: false
                  - name: bids
                    type: array
                    description: Bid orders [price, quantity]
                    required: true
                    properties:
                      - name: item
                        type: array
                        required: false
                        properties:
                          - name: item
                            type: string
                            required: false
                  - name: asks
                    type: array
                    description: Ask orders [price, quantity]
                    required: true
                    properties:
                      - name: item
                        type: array
                        required: false
                        properties:
                          - name: item
                            type: string
                            required: false
                  - name: timestamp
                    type: integer
                    description: Unix timestamp in milliseconds
                    required: true
        headers: []
        jsonPayloadSchema:
          type: object
          additionalProperties: false
          properties:
            cmd:
              type: string
              const: depth
              description: Message type
              x-parser-schema-id: <anonymous-schema-76>
            data:
              type: object
              additionalProperties: false
              properties:
                symbol:
                  type: string
                  example: BTCUSDT
                  description: Trading symbol
                  x-parser-schema-id: <anonymous-schema-78>
                type:
                  type: string
                  enum:
                    - stock
                    - indices
                    - crypto
                    - forex
                    - futures
                  description: Symbol type
                  x-parser-schema-id: <anonymous-schema-79>
                bids:
                  type: array
                  items:
                    type: array
                    items:
                      type: string
                      x-parser-schema-id: <anonymous-schema-82>
                    minItems: 2
                    maxItems: 2
                    x-parser-schema-id: <anonymous-schema-81>
                  example:
                    - - '43250.50'
                      - '0.125'
                    - - '43250.00'
                      - '0.250'
                  description: Bid orders [price, quantity]
                  x-parser-schema-id: <anonymous-schema-80>
                asks:
                  type: array
                  items:
                    type: array
                    items:
                      type: string
                      x-parser-schema-id: <anonymous-schema-85>
                    minItems: 2
                    maxItems: 2
                    x-parser-schema-id: <anonymous-schema-84>
                  example:
                    - - '43251.00'
                      - '0.180'
                    - - '43251.50'
                      - '0.320'
                  description: Ask orders [price, quantity]
                  x-parser-schema-id: <anonymous-schema-83>
                timestamp:
                  type: integer
                  example: 1703123456789
                  description: Unix timestamp in milliseconds
                  x-parser-schema-id: <anonymous-schema-86>
              required:
                - symbol
                - bids
                - asks
                - timestamp
              x-parser-schema-id: <anonymous-schema-77>
          required:
            - cmd
            - data
          x-parser-schema-id: <anonymous-schema-75>
        title: Orderbook Data
        description: Real-time order book depth data pushed from server
        example: No examples found
        bindings: []
        extensions:
          - id: x-parser-unique-object-id
            value: depthData
    bindings: []
    extensions: &ref_1
      - id: x-parser-unique-object-id
        value: depth
  - &ref_2
    id: receiveDepthData
    title: Receive depth data
    type: receive
    messages:
      - &ref_4
        id: subscribeRequest
        contentType: application/json
        payload:
          - name: Subscribe/Unsubscribe to Orderbook
            description: Subscribe or unsubscribe to real-time order book depth updates
            type: object
            properties:
              - name: cmd
                type: string
                description: Command type (subscribe or unsubscribe)
                enumValues:
                  - subscribe
                  - unsubscribe
                required: true
              - name: data
                type: object
                required: true
                properties:
                  - name: channel
                    type: string
                    description: Channel name
                    enumValues:
                      - ticker
                      - depth
                      - trade
                    required: true
                  - name: symbols
                    type: array
                    description: List of trading symbols to subscribe/unsubscribe
                    examples: &ref_0
                      - AAPL.US
                      - 700.HK
                      - EURUSD
                      - XAUUSD
                      - BTCUSDT
                      - IC2606
                    required: true
                    properties:
                      - name: item
                        type: string
                        required: false
                  - name: type
                    type: string
                    description: >-
                      Symbol type, optional. Not required when the symbol is
                      unambiguous; if the server returns an AMBIGUOUS_SYMBOL
                      error, pass the value as indicated
                    enumValues:
                      - stock
                      - indices
                      - crypto
                      - forex
                      - futures
                    required: false
        headers: []
        jsonPayloadSchema:
          type: object
          additionalProperties: false
          properties:
            cmd:
              type: string
              enum:
                - subscribe
                - unsubscribe
              description: Command type (subscribe or unsubscribe)
              x-parser-schema-id: <anonymous-schema-69>
            data:
              type: object
              additionalProperties: false
              properties:
                channel:
                  type: string
                  enum:
                    - ticker
                    - depth
                    - trade
                  default: depth
                  description: Channel name
                  x-parser-schema-id: <anonymous-schema-71>
                symbols:
                  type: array
                  items:
                    type: string
                    x-parser-schema-id: <anonymous-schema-73>
                  examples: *ref_0
                  description: List of trading symbols to subscribe/unsubscribe
                  x-parser-schema-id: <anonymous-schema-72>
                type:
                  type: string
                  enum:
                    - stock
                    - indices
                    - crypto
                    - forex
                    - futures
                  description: >-
                    Symbol type, optional. Not required when the symbol is
                    unambiguous; if the server returns an AMBIGUOUS_SYMBOL
                    error, pass the value as indicated
                  x-parser-schema-id: <anonymous-schema-74>
              required:
                - channel
                - symbols
              x-parser-schema-id: <anonymous-schema-70>
          required:
            - cmd
            - data
          x-parser-schema-id: <anonymous-schema-68>
        title: Subscribe/Unsubscribe to Orderbook
        description: Subscribe or unsubscribe to real-time order book depth updates
        example: No examples found
        bindings: []
        extensions:
          - id: x-parser-unique-object-id
            value: subscribeRequest
    bindings: []
    extensions: *ref_1
sendOperations:
  - *ref_2
receiveOperations:
  - *ref_3
sendMessages:
  - *ref_4
receiveMessages:
  - *ref_5
extensions:
  - id: x-parser-unique-object-id
    value: depth
securitySchemes:
  - id: apiKey
    name: api_key
    type: httpApiKey
    in: query
    extensions: []

````

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