> ## 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_microstructure

> Microstructure signals: depth within 10/50/100 bps, slope, max gap, and per-side level counts.

Microstructure signals: depth within 10/50/100 bps, slope, max gap, and per-side level counts.


## OpenAPI

````yaml openpx.openapi.yaml GET /v1/orderbook/fetch_orderbook_microstructure
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_microstructure:
    get:
      tags:
        - Orderbook
      summary: Fetch orderbook microstructure
      description: >-
        Microstructure signals: depth within 10/50/100 bps, slope, max gap, and
        per-side level counts.
      operationId: fetch_orderbook_microstructure
      parameters:
        - name: asset_id
          in: query
          required: true
          schema:
            type: string
      responses:
        '200':
          description: Success.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/OrderbookMicrostructure'
        default:
          description: Unified error response.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/OpenPxError'
components:
  schemas:
    OrderbookMicrostructure:
      description: Microstructure signals for one orderbook.
      properties:
        ask_slope:
          description: OLS slope of cumulative ask size vs distance-from-mid (e.g. `12.5`).
          format: double
          type:
            - number
            - 'null'
        asset_id:
          description: Orderable asset id (e.g. `"KXBTCD-25APR1517"`).
          type: string
        bid_slope:
          description: OLS slope of cumulative bid size vs distance-from-mid (e.g. `12.5`).
          format: double
          type:
            - number
            - 'null'
        depth_buckets:
          allOf:
            - $ref: '#/components/schemas/DepthBuckets'
          description: Cumulative depth at 10/50/100 bps from mid.
        exchange_ts:
          description: Upstream snapshot time in UTC; `null` when not provided.
          format: date-time
          type:
            - string
            - 'null'
        level_count:
          allOf:
            - $ref: '#/components/schemas/LevelCount'
          description: Number of levels per side.
        max_gap:
          allOf:
            - $ref: '#/components/schemas/MaxGap'
          description: Largest consecutive-level price gap on each side, in basis points.
        openpx_ts:
          description: Wall-clock time OpenPX served the response (UTC).
          format: date-time
          type: string
      required:
        - asset_id
        - depth_buckets
        - level_count
        - max_gap
        - openpx_ts
      title: OrderbookMicrostructure
      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
    DepthBuckets:
      description: Cumulative depth at 10/50/100 bps tiers from mid.
      properties:
        ask_within_100bps:
          description: Cumulative ask size within 100 bps of mid (contracts).
          format: double
          type: number
        ask_within_10bps:
          description: Cumulative ask size within 10 bps of mid (contracts).
          format: double
          type: number
        ask_within_50bps:
          description: Cumulative ask size within 50 bps of mid (contracts).
          format: double
          type: number
        bid_within_100bps:
          description: Cumulative bid size within 100 bps of mid (contracts).
          format: double
          type: number
        bid_within_10bps:
          description: Cumulative bid size within 10 bps of mid (contracts).
          format: double
          type: number
        bid_within_50bps:
          description: Cumulative bid size within 50 bps of mid (contracts).
          format: double
          type: number
      required:
        - ask_within_100bps
        - ask_within_10bps
        - ask_within_50bps
        - bid_within_100bps
        - bid_within_10bps
        - bid_within_50bps
      title: DepthBuckets
      type: object
    LevelCount:
      description: Per-side resting-level counts.
      properties:
        asks:
          description: Number of ask levels (e.g. `12`).
          format: uint32
          minimum: 0
          type: integer
        bids:
          description: Number of bid levels (e.g. `12`).
          format: uint32
          minimum: 0
          type: integer
      required:
        - asks
        - bids
      title: LevelCount
      type: object
    MaxGap:
      description: Largest consecutive-level price gap per side.
      properties:
        ask_gap_bps:
          description: Max ask-side gap in basis points (e.g. `25.0`).
          format: double
          type:
            - number
            - 'null'
        bid_gap_bps:
          description: Max bid-side gap in basis points (e.g. `25.0`).
          format: double
          type:
            - number
            - 'null'
      title: MaxGap
      type: object

````