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

# Live order book stream

> The stream follows the snapshot-plus-deltas model: exactly one `snapshot` frame with the top-`depth` levels of each side, then `update` frames carrying only changed levels. In updates size `"0"` removes a level. Levels are keyed by numeric price value, so a client must not distinguish `"1.5"` from `"1.50"`. An upstream resync or transparent reconnect is absorbed into a regular `update` diff — a client sees exactly one `snapshot` frame per connection. A positive `throttlingDelay` coalesces diffs (latest size per price wins) into at most one `update` frame per delay; 0 or omitted forwards every upstream batch. A terminal upstream error is delivered as an `error` frame and closes the socket; a client that does not read the stream fast enough for its `depth` is dropped with `too_much_data`.

**Cost:** 50 credits per subscription, charged again in every quota window the connection stays open in.



## AsyncAPI

````yaml platform-api/specs/asyncapi.yaml orderbook
id: orderbook
title: Live order book stream
description: >-
  The stream follows the snapshot-plus-deltas model: exactly one `snapshot`
  frame with the top-`depth` levels of each side, then `update` frames carrying
  only changed levels. In updates size `"0"` removes a level. Levels are keyed
  by numeric price value, so a client must not distinguish `"1.5"` from
  `"1.50"`. An upstream resync or transparent reconnect is absorbed into a
  regular `update` diff — a client sees exactly one `snapshot` frame per
  connection. A positive `throttlingDelay` coalesces diffs (latest size per
  price wins) into at most one `update` frame per delay; 0 or omitted forwards
  every upstream batch. A terminal upstream error is delivered as an `error`
  frame and closes the socket; a client that does not read the stream fast
  enough for its `depth` is dropped with `too_much_data`.


  **Cost:** 50 credits per subscription, charged again in every quota window the
  connection stays open in.
servers:
  - id: production
    protocol: wss
    host: public-api.takeprofit.com
    bindings: []
    variables: []
address: /api/v1/marketdata/orderbook/stream
parameters: []
bindings:
  - protocol: ws
    version: 0.1.0
    value:
      method: GET
      query:
        type: object
        additionalProperties: false
        required:
          - exchange
          - symbol
        properties:
          exchange: &ref_0
            type: string
            description: >-
              TakeProfit exchange code as returned by GET
              /api/v1/marketdata/exchanges.
            example: CXBNCE
            x-parser-schema-id: ExchangeCode
          symbol: &ref_1
            type: string
            description: >-
              TakeProfit security symbol as returned by GET
              /api/v1/marketdata/exchanges/{exchange}/securities.
            example: BTC/USDT
            x-parser-schema-id: SecuritySymbol
          depth:
            type: integer
            minimum: 0
            default: 200
            description: Number of best levels per side; 0 streams the full book.
          throttlingDelay:
            type: integer
            minimum: 0
            maximum: 60000
            default: 0
            description: >-
              Throttling delay in milliseconds; a positive delay coalesces
              updates into at most one frame per delay, 0 or omitted applies no
              gateway-side throttling.
            x-parser-schema-id: ThrottlingDelay
    schemaProperties:
      - name: method
        type: string
        description: GET
        required: false
      - name: query
        type: object
        required: false
        properties:
          - name: exchange
            type: string
            description: >-
              TakeProfit exchange code as returned by GET
              /api/v1/marketdata/exchanges.
            required: true
          - name: symbol
            type: string
            description: >-
              TakeProfit security symbol as returned by GET
              /api/v1/marketdata/exchanges/{exchange}/securities.
            required: true
          - name: depth
            type: integer
            description: Number of best levels per side; 0 streams the full book.
            required: false
          - name: throttlingDelay
            type: integer
            description: >-
              Throttling delay in milliseconds; a positive delay coalesces
              updates into at most one frame per delay, 0 or omitted applies no
              gateway-side throttling.
            required: false
operations:
  - &ref_5
    id: streamOrderBook
    title: Stream the order book
    description: Frames the gateway delivers to a connected order book stream client.
    type: send
    messages:
      - &ref_6
        id: snapshot
        contentType: application/json
        payload:
          - name: Order book snapshot frame
            description: >-
              The full initial top-depth view of the book; exactly one per
              connection.
            type: object
            properties:
              - name: const
                type: string
                description: orderbook
                required: false
              - name: meta
                type: object
                description: >-
                  Echo of the normalized subscription parameters; depth is the
                  effective value after the default is applied.
                required: true
                properties:
                  - name: exchange
                    type: string
                    description: >-
                      TakeProfit exchange code as returned by GET
                      /api/v1/marketdata/exchanges.
                    required: true
                  - name: symbol
                    type: string
                    description: >-
                      TakeProfit security symbol as returned by GET
                      /api/v1/marketdata/exchanges/{exchange}/securities.
                    required: true
                  - name: depth
                    type: integer
                    description: Levels per side; 0 means the full book.
                    required: true
              - name: snapshot
                type: object
                description: >-
                  Levels listed best price first: bids descending, asks
                  ascending. The timestamp is the exchange timestamp of the
                  underlying upstream batch.
                required: true
                properties:
                  - name: timestamp
                    type: string
                    required: true
                  - name: bids
                    type: array
                    required: true
                    properties:
                      - name: item
                        type: array
                        description: >-
                          One price level as the positional array [price, size]
                          of decimal strings. In updates size "0" removes the
                          level. Levels are keyed by numeric price value, so
                          "1.5" and "1.50" are the same level.
                        required: false
                        properties:
                          - name: item
                            type: string
                            required: false
                  - name: asks
                    type: array
                    required: true
                    properties:
                      - name: item
                        type: array
                        description: >-
                          One price level as the positional array [price, size]
                          of decimal strings. In updates size "0" removes the
                          level. Levels are keyed by numeric price value, so
                          "1.5" and "1.50" are the same level.
                        required: false
                        properties:
                          - name: item
                            type: string
                            required: false
        headers: []
        jsonPayloadSchema:
          type: object
          additionalProperties: false
          required:
            - type
            - meta
            - snapshot
          properties:
            type:
              const: orderbook
              x-parser-schema-id: <anonymous-schema-35>
            meta: &ref_3
              type: object
              description: >-
                Echo of the normalized subscription parameters; depth is the
                effective value after the default is applied.
              required:
                - exchange
                - symbol
                - depth
              properties:
                exchange: *ref_0
                symbol: *ref_1
                depth:
                  type: integer
                  description: Levels per side; 0 means the full book.
                  x-parser-schema-id: <anonymous-schema-36>
              x-parser-schema-id: OrderBookMeta
            snapshot: &ref_4
              type: object
              description: >-
                Levels listed best price first: bids descending, asks ascending.
                The timestamp is the exchange timestamp of the underlying
                upstream batch.
              required:
                - timestamp
                - bids
                - asks
              properties:
                timestamp:
                  type: string
                  format: date-time
                  x-parser-schema-id: <anonymous-schema-37>
                bids:
                  type: array
                  items: &ref_2
                    type: array
                    description: >-
                      One price level as the positional array [price, size] of
                      decimal strings. In updates size "0" removes the level.
                      Levels are keyed by numeric price value, so "1.5" and
                      "1.50" are the same level.
                    minItems: 2
                    maxItems: 2
                    items:
                      type: string
                      x-parser-schema-id: <anonymous-schema-39>
                    example:
                      - '109250.5'
                      - '0.42'
                    x-parser-schema-id: OrderBookLevel
                  x-parser-schema-id: <anonymous-schema-38>
                asks:
                  type: array
                  items: *ref_2
                  x-parser-schema-id: <anonymous-schema-40>
              x-parser-schema-id: OrderBookFrame
          x-parser-schema-id: <anonymous-schema-34>
        title: Order book snapshot frame
        description: >-
          The full initial top-depth view of the book; exactly one per
          connection.
        example: |-
          {
            "type": "orderbook",
            "meta": {
              "exchange": "CXBNCE",
              "symbol": "BTC/USDT",
              "depth": 3
            },
            "snapshot": {
              "timestamp": "2026-09-22T05:39:24.614Z",
              "bids": [
                [
                  "85320.85",
                  "6.35745"
                ],
                [
                  "85320.84",
                  "0.00012"
                ],
                [
                  "85320.83",
                  "0.00012"
                ]
              ],
              "asks": [
                [
                  "85320.86",
                  "0.20388"
                ],
                [
                  "85320.87",
                  "0.00047"
                ],
                [
                  "85320.88",
                  "0.00012"
                ]
              ]
            }
          }
        bindings: []
        extensions:
          - id: x-parser-unique-object-id
            value: snapshot
      - &ref_7
        id: update
        contentType: application/json
        payload:
          - name: Order book update frame
            description: Changed levels only; size "0" removes a level.
            type: object
            properties:
              - name: const
                type: string
                description: orderbook
                required: false
              - name: meta
                type: object
                description: >-
                  Echo of the normalized subscription parameters; depth is the
                  effective value after the default is applied.
                required: true
                properties:
                  - name: exchange
                    type: string
                    description: >-
                      TakeProfit exchange code as returned by GET
                      /api/v1/marketdata/exchanges.
                    required: true
                  - name: symbol
                    type: string
                    description: >-
                      TakeProfit security symbol as returned by GET
                      /api/v1/marketdata/exchanges/{exchange}/securities.
                    required: true
                  - name: depth
                    type: integer
                    description: Levels per side; 0 means the full book.
                    required: true
              - name: update
                type: object
                description: >-
                  Levels listed best price first: bids descending, asks
                  ascending. The timestamp is the exchange timestamp of the
                  underlying upstream batch.
                required: true
                properties:
                  - name: timestamp
                    type: string
                    required: true
                  - name: bids
                    type: array
                    required: true
                    properties:
                      - name: item
                        type: array
                        description: >-
                          One price level as the positional array [price, size]
                          of decimal strings. In updates size "0" removes the
                          level. Levels are keyed by numeric price value, so
                          "1.5" and "1.50" are the same level.
                        required: false
                        properties:
                          - name: item
                            type: string
                            required: false
                  - name: asks
                    type: array
                    required: true
                    properties:
                      - name: item
                        type: array
                        description: >-
                          One price level as the positional array [price, size]
                          of decimal strings. In updates size "0" removes the
                          level. Levels are keyed by numeric price value, so
                          "1.5" and "1.50" are the same level.
                        required: false
                        properties:
                          - name: item
                            type: string
                            required: false
        headers: []
        jsonPayloadSchema:
          type: object
          additionalProperties: false
          required:
            - type
            - meta
            - update
          properties:
            type:
              const: orderbook
              x-parser-schema-id: <anonymous-schema-42>
            meta: *ref_3
            update: *ref_4
          x-parser-schema-id: <anonymous-schema-41>
        title: Order book update frame
        description: Changed levels only; size "0" removes a level.
        example: |-
          {
            "type": "orderbook",
            "meta": {
              "exchange": "CXBNCE",
              "symbol": "BTC/USDT",
              "depth": 3
            },
            "update": {
              "timestamp": "2026-09-22T05:39:24.914Z",
              "bids": [],
              "asks": [
                [
                  "85320.86",
                  "0.20274"
                ],
                [
                  "85320.87",
                  "0.0004"
                ]
              ]
            }
          }
        bindings: []
        extensions:
          - id: x-parser-unique-object-id
            value: update
      - &ref_8
        id: error
        contentType: application/json
        payload:
          - name: Error frame
            description: >-
              Terminal error converted from an upstream status; closes the
              socket.
            type: object
            properties:
              - name: const
                type: string
                description: error
                required: false
              - name: meta
                type: object
                description: >-
                  Echo of the normalized subscription parameters; depth is the
                  effective value after the default is applied.
                required: true
                properties:
                  - name: exchange
                    type: string
                    description: >-
                      TakeProfit exchange code as returned by GET
                      /api/v1/marketdata/exchanges.
                    required: true
                  - name: symbol
                    type: string
                    description: >-
                      TakeProfit security symbol as returned by GET
                      /api/v1/marketdata/exchanges/{exchange}/securities.
                    required: true
                  - name: depth
                    type: integer
                    description: Levels per side; 0 means the full book.
                    required: true
              - name: error
                type: object
                required: true
                properties:
                  - name: code
                    type: string
                    description: Stable public error code.
                    enumValues:
                      - canceled
                      - invalid_argument
                      - unauthenticated
                      - permission_denied
                      - not_found
                      - conflict
                      - rate_limited
                      - too_much_data
                      - deadline_exceeded
                      - unimplemented
                      - unavailable
                      - upstream_error
                    required: true
                  - name: message
                    type: string
                    description: Human-readable public error message.
                    required: true
        headers: []
        jsonPayloadSchema:
          type: object
          additionalProperties: false
          required:
            - type
            - meta
            - error
          properties:
            type:
              const: error
              x-parser-schema-id: <anonymous-schema-44>
            meta: *ref_3
            error:
              type: object
              required:
                - code
                - message
              properties:
                code:
                  type: string
                  description: Stable public error code.
                  enum:
                    - canceled
                    - invalid_argument
                    - unauthenticated
                    - permission_denied
                    - not_found
                    - conflict
                    - rate_limited
                    - too_much_data
                    - deadline_exceeded
                    - unimplemented
                    - unavailable
                    - upstream_error
                  x-parser-schema-id: <anonymous-schema-12>
                message:
                  type: string
                  description: Human-readable public error message.
                  x-parser-schema-id: <anonymous-schema-13>
              x-parser-schema-id: ErrorBody
          x-parser-schema-id: <anonymous-schema-43>
        title: Error frame
        description: Terminal error converted from an upstream status; closes the socket.
        example: |-
          {
            "type": "error",
            "meta": {
              "exchange": "CXBNCE",
              "symbol": "UNKNOWN",
              "depth": 200
            },
            "error": {
              "code": "not_found",
              "message": "security not found"
            }
          }
        bindings: []
        extensions:
          - id: x-parser-unique-object-id
            value: error
    bindings: []
    extensions:
      - id: x-parser-unique-object-id
        value: orderbook
sendOperations: []
receiveOperations:
  - *ref_5
sendMessages: []
receiveMessages:
  - *ref_6
  - *ref_7
  - *ref_8
extensions:
  - id: x-parser-unique-object-id
    value: orderbook
securitySchemes:
  - id: ApiKeyAuth
    name: x-api-key
    type: httpApiKey
    description: >-
      API key sent on the WebSocket upgrade request. Exactly one header value is
      required; duplicate or comma-combined values are rejected.
    in: header
    extensions: []

````