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

# fetch_orderbook_stats

> Snapshot stats: top-of-book, mid, spread (bps), size-weighted mid, top-10 imbalance, and total depth.

Snapshot stats: top-of-book, mid, spread (bps), size-weighted mid, top-10 imbalance, and total depth.


## OpenAPI

````yaml openpx.openapi.yaml GET /v1/orderbook/fetch_orderbook_stats
openapi: 3.1.0
info:
  title: OpenPX Unified API
  description: >-
    Unified API surface across prediction-market exchanges. One `Exchange`
    trait, one set of models, one shape — implemented in Rust with
    auto-generated Python and TypeScript SDKs.


    This OpenAPI spec is **auto-generated** from
    `engine/core/src/exchange/traits.rs` and `schema/openpx.schema.json`. Edit
    the trait or the schema, then regenerate via `just openapi`. The spec models
    trait methods as REST operations for documentation rendering only — OpenPX
    is an in-process Rust library, not a REST service.
  version: 0.3.1
  license:
    name: MIT
servers:
  - url: https://github.com/openpx-trade/openpx
    description: >-
      Documentation surface only. OpenPX is an in-process Rust library; there is
      no hosted REST endpoint.
security: []
tags:
  - name: Markets
  - name: Orders
  - name: Positions
  - name: Balance
  - name: Orderbook
  - name: Trades
  - name: Fills
  - name: Server
paths:
  /v1/orderbook/fetch_orderbook_stats:
    get:
      tags:
        - Orderbook
      summary: Fetch orderbook stats
      description: >-
        Snapshot stats: top-of-book, mid, spread (bps), size-weighted mid,
        top-10 imbalance, and total depth.
      operationId: fetch_orderbook_stats
      parameters:
        - name: asset_id
          in: query
          required: true
          schema:
            type: string
      responses:
        '200':
          description: Success.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/OrderbookStats'
        default:
          description: Unified error response.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/OpenPxError'
components:
  schemas:
    OrderbookStats:
      description: Top-of-book snapshot stats for one asset.
      properties:
        ask_depth:
          description: Total resting ask size in contracts (e.g. `1000.0`).
          format: double
          type: number
        asset_id:
          description: Orderable asset id (e.g. `"KXBTCD-25APR1517"`).
          type: string
        best_ask:
          description: Best ask as YES probability (e.g. `0.63`).
          format: double
          type:
            - number
            - 'null'
        best_bid:
          description: Best bid as YES probability (e.g. `0.61`).
          format: double
          type:
            - number
            - 'null'
        bid_depth:
          description: Total resting bid size in contracts (e.g. `1000.0`).
          format: double
          type: number
        exchange_ts:
          description: Upstream snapshot time in UTC; `null` when not provided.
          format: date-time
          type:
            - string
            - 'null'
        imbalance:
          description: Top-10 imbalance in `[-1, 1]` (positive = bid-heavy) (e.g. `0.12`).
          format: double
          type:
            - number
            - 'null'
        mid:
          description: Mid price as YES probability (e.g. `0.62`).
          format: double
          type:
            - number
            - 'null'
        openpx_ts:
          description: Wall-clock time OpenPX served the response (UTC).
          format: date-time
          type: string
        spread_bps:
          description: Spread in basis points relative to mid (e.g. `400.0`).
          format: double
          type:
            - number
            - 'null'
        weighted_mid:
          description: Size-weighted mid using the top-10 levels (e.g. `0.62`).
          format: double
          type:
            - number
            - 'null'
      required:
        - ask_depth
        - asset_id
        - bid_depth
        - openpx_ts
      title: OrderbookStats
      type: object
    OpenPxError:
      type: object
      description: >-
        Unified error type returned when an exchange call fails. The `kind`
        field is the canonical category; `message` carries the upstream
        explanation. Per-exchange variants are mapped into this shape before
        they cross the trait boundary.
      required:
        - kind
        - message
      properties:
        kind:
          type: string
          enum:
            - Authentication
            - InsufficientFunds
            - MarketNotFound
            - OrderNotFound
            - RateLimited
            - NetworkError
            - Api
            - Config
            - NotSupported
        message:
          type: string

````