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

# Get a market orderbook

> Resting bids and asks for the market on each venue, and the same levels merged across venues. Pass `venue` to read one venue only; a venue symbol reads only the listing it names. A venue whose book could not be read is listed in `unavailable`.



## OpenAPI

````yaml api-reference/openapi.json GET /markets/{id}/book
openapi: 3.0.0
info:
  title: Lean API
  version: 0.1.0
  description: >-
    Programmatic access to Lean: canonical sports markets, quotes, orders,
    positions and balances.
servers:
  - url: '{baseUrl}/v1'
    description: Lean API
    variables:
      baseUrl:
        default: https://api.lean.xyz
        description: >-
          The Lean API base URL, without /v1. Same value as LEAN_API_URL in the
          guides.
security:
  - apiKey: []
paths:
  /markets/{id}/book:
    get:
      tags:
        - Markets
      summary: Get a market orderbook
      description: >-
        Resting bids and asks for the market on each venue, and the same levels
        merged across venues. Pass `venue` to read one venue only; a venue
        symbol reads only the listing it names. A venue whose book could not be
        read is listed in `unavailable`.
      operationId: getMarketBook
      parameters:
        - schema:
            type: string
            minLength: 1
            maxLength: 512
            description: >-
              A market id from GET /markets, or a venue symbol that names one
              market: a Polymarket token id, a Hyperliquid book coin (`#…`,
              written `%23…` in a path), or a leg `ticker` (`pm:…`, `hl:…`,
              `pmus:…` or a Kalshi market ticker) that lists only this outcome.
              A symbol that names more than one market, such as a Polymarket
              condition id, is refused with 400; use the token id or the market
              id instead.
            example: >-
              mkt_bmZsOjIwMjYtMTAtMTE6REVOLUxBQwpzcHJlYWQ6Z2FtZTpERU46LTMuNQpERU4
          required: true
          description: >-
            A market id from GET /markets, or a venue symbol that names one
            market: a Polymarket token id, a Hyperliquid book coin (`#…`,
            written `%23…` in a path), or a leg `ticker` (`pm:…`, `hl:…`,
            `pmus:…` or a Kalshi market ticker) that lists only this outcome. A
            symbol that names more than one market, such as a Polymarket
            condition id, is refused with 400; use the token id or the market id
            instead.
          name: id
          in: path
        - schema:
            type: string
            enum:
              - kalshi
              - polymarket
              - polymarket_us
              - hyperliquid
            description: Only this venue. Defaults to every venue listing it.
          required: false
          description: Only this venue. Defaults to every venue listing it.
          name: venue
          in: query
        - schema:
            type: integer
            minimum: 1
            maximum: 100
            default: 20
            description: >-
              Price levels returned per side. Depth totals always cover the
              whole book read.
          required: false
          description: >-
            Price levels returned per side. Depth totals always cover the whole
            book read.
          name: depth
          in: query
      responses:
        '200':
          description: >-
            Executable levels per venue and combined across venues, with depth
            totals
          content:
            application/json:
              schema:
                oneOf:
                  - type: object
                    properties:
                      success:
                        type: boolean
                        enum:
                          - true
                      data:
                        type: object
                        properties:
                          market_id:
                            type: string
                            minLength: 1
                            description: >-
                              The market id from GET /markets, however the
                              request named the market.
                          venues:
                            type: array
                            items:
                              type: object
                              properties:
                                venue:
                                  type: string
                                  enum:
                                    - kalshi
                                    - polymarket
                                    - polymarket_us
                                    - hyperliquid
                                ticker:
                                  type: string
                                  minLength: 1
                                side:
                                  type: string
                                  enum:
                                    - 'yes'
                                    - 'no'
                                bids:
                                  type: array
                                  items:
                                    type: object
                                    properties:
                                      price:
                                        type: string
                                      quantity:
                                        type: string
                                        pattern: ^\d+(?:\.\d+)?$
                                    required:
                                      - price
                                      - quantity
                                asks:
                                  type: array
                                  items:
                                    type: object
                                    properties:
                                      price:
                                        type: string
                                      quantity:
                                        type: string
                                        pattern: ^\d+(?:\.\d+)?$
                                    required:
                                      - price
                                      - quantity
                                bid_quantity:
                                  type: string
                                  pattern: ^\d+(?:\.\d+)?$
                                ask_quantity:
                                  type: string
                                  pattern: ^\d+(?:\.\d+)?$
                                bid_notional_usd:
                                  type: string
                                  pattern: ^\d+(?:\.\d+)?$
                                ask_notional_usd:
                                  type: string
                                  pattern: ^\d+(?:\.\d+)?$
                              required:
                                - venue
                                - ticker
                                - side
                                - bids
                                - asks
                                - bid_quantity
                                - ask_quantity
                                - bid_notional_usd
                                - ask_notional_usd
                          combined:
                            type: object
                            properties:
                              bids:
                                type: array
                                items:
                                  type: object
                                  properties:
                                    price:
                                      type: string
                                    quantity:
                                      type: string
                                      pattern: ^\d+(?:\.\d+)?$
                                    venues:
                                      type: array
                                      items:
                                        type: object
                                        properties:
                                          venue:
                                            type: string
                                            enum:
                                              - kalshi
                                              - polymarket
                                              - polymarket_us
                                              - hyperliquid
                                          quantity:
                                            type: string
                                            pattern: ^\d+(?:\.\d+)?$
                                        required:
                                          - venue
                                          - quantity
                                  required:
                                    - price
                                    - quantity
                                    - venues
                              asks:
                                type: array
                                items:
                                  type: object
                                  properties:
                                    price:
                                      type: string
                                    quantity:
                                      type: string
                                      pattern: ^\d+(?:\.\d+)?$
                                    venues:
                                      type: array
                                      items:
                                        type: object
                                        properties:
                                          venue:
                                            type: string
                                            enum:
                                              - kalshi
                                              - polymarket
                                              - polymarket_us
                                              - hyperliquid
                                          quantity:
                                            type: string
                                            pattern: ^\d+(?:\.\d+)?$
                                        required:
                                          - venue
                                          - quantity
                                  required:
                                    - price
                                    - quantity
                                    - venues
                            required:
                              - bids
                              - asks
                          total_bid_quantity:
                            type: string
                            pattern: ^\d+(?:\.\d+)?$
                          total_ask_quantity:
                            type: string
                            pattern: ^\d+(?:\.\d+)?$
                          total_bid_notional_usd:
                            type: string
                            pattern: ^\d+(?:\.\d+)?$
                          total_ask_notional_usd:
                            type: string
                            pattern: ^\d+(?:\.\d+)?$
                          unavailable:
                            type: array
                            items:
                              type: string
                              enum:
                                - kalshi
                                - polymarket
                                - polymarket_us
                                - hyperliquid
                          as_of:
                            type: string
                            format: date-time
                          livemode:
                            type: boolean
                        required:
                          - market_id
                          - venues
                          - combined
                          - total_bid_quantity
                          - total_ask_quantity
                          - total_bid_notional_usd
                          - total_ask_notional_usd
                          - unavailable
                          - as_of
                          - livemode
                      meta:
                        type: object
                        properties:
                          timestampMs:
                            type: integer
                            minimum: 0
                          requestId:
                            type: string
                            minLength: 1
                          traceId:
                            type: string
                            minLength: 1
                          cachedAtMs:
                            type: integer
                            minimum: 0
                          source:
                            type: string
                            enum:
                              - cache
                              - database
                              - clickhouse
                              - upstream
                              - fallback
                              - internal
                        required:
                          - timestampMs
                          - requestId
                    required:
                      - success
                      - data
                      - meta
                  - $ref: '#/components/schemas/ApiError'
              example:
                success: true
                data:
                  market_id: >-
                    mkt_bmZsOjIwMjYtMTAtMTE6REVOLUxBQwpzcHJlYWQ6Z2FtZTpERU46LTMuNQpERU4
                  venues:
                    - venue: hyperliquid
                      ticker: hl:9999
                      side: 'yes'
                      bids:
                        - price: '0.54'
                          quantity: '100'
                      asks:
                        - price: '0.56'
                          quantity: '80'
                      bid_quantity: '100'
                      ask_quantity: '80'
                      bid_notional_usd: '54'
                      ask_notional_usd: '44.8'
                    - venue: polymarket
                      ticker: >-
                        pm:0x2222222222222222222222222222222222222222222222222222222222222222
                      side: 'yes'
                      bids:
                        - price: '0.54'
                          quantity: '50'
                        - price: '0.53'
                          quantity: '200'
                      asks:
                        - price: '0.55'
                          quantity: '120'
                      bid_quantity: '250'
                      ask_quantity: '120'
                      bid_notional_usd: '133'
                      ask_notional_usd: '66'
                  combined:
                    bids:
                      - price: '0.54'
                        quantity: '150'
                        venues:
                          - venue: hyperliquid
                            quantity: '100'
                          - venue: polymarket
                            quantity: '50'
                      - price: '0.53'
                        quantity: '200'
                        venues:
                          - venue: polymarket
                            quantity: '200'
                    asks:
                      - price: '0.55'
                        quantity: '120'
                        venues:
                          - venue: polymarket
                            quantity: '120'
                      - price: '0.56'
                        quantity: '80'
                        venues:
                          - venue: hyperliquid
                            quantity: '80'
                  total_bid_quantity: '350'
                  total_ask_quantity: '200'
                  total_bid_notional_usd: '187'
                  total_ask_notional_usd: '110.8'
                  unavailable: []
                  as_of: '2026-10-29T18:00:00.000Z'
                  livemode: true
                meta:
                  timestampMs: 1792771200000
                  requestId: 7d2c9f4e-1b3a-4e8d-9c6f-2a5b8e0d4f17
        '400':
          description: API error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ApiError'
              example:
                success: false
                error:
                  code: VALIDATION_ERROR
                  message: Invalid request
                meta:
                  timestampMs: 1792771200000
                  requestId: 7d2c9f4e-1b3a-4e8d-9c6f-2a5b8e0d4f17
        '401':
          description: Missing, invalid, expired or revoked API key
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ApiError'
              example:
                success: false
                error:
                  code: UNAUTHORIZED
                  message: Invalid, expired or revoked API key
                meta:
                  timestampMs: 1792771200000
                  requestId: 7d2c9f4e-1b3a-4e8d-9c6f-2a5b8e0d4f17
        '403':
          description: The key lacks the scope this route needs
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ApiError'
              example:
                success: false
                error:
                  code: FORBIDDEN
                  message: This API key lacks the scope this route needs
                meta:
                  timestampMs: 1792771200000
                  requestId: 7d2c9f4e-1b3a-4e8d-9c6f-2a5b8e0d4f17
        '404':
          description: No market with this id, or none on the requested venue
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ApiError'
              example:
                success: false
                error:
                  code: NOT_FOUND
                  message: No market with this id, or none on the requested venue
                meta:
                  timestampMs: 1792771200000
                  requestId: 7d2c9f4e-1b3a-4e8d-9c6f-2a5b8e0d4f17
        '429':
          description: API error
          headers:
            Retry-After:
              description: Seconds remaining in the upstream read cooldown, when available
              schema:
                type: integer
                minimum: 0
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ApiError'
              example:
                success: false
                error:
                  code: RATE_LIMITED
                  message: Too many requests for this API key
                meta:
                  timestampMs: 1792771200000
                  requestId: 7d2c9f4e-1b3a-4e8d-9c6f-2a5b8e0d4f17
        '500':
          description: API error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ApiError'
              example:
                success: false
                error:
                  code: INTERNAL_ERROR
                  message: An internal error occurred.
                meta:
                  timestampMs: 1792771200000
                  requestId: 7d2c9f4e-1b3a-4e8d-9c6f-2a5b8e0d4f17
components:
  schemas:
    ApiError:
      type: object
      properties:
        success:
          type: boolean
          enum:
            - false
        error:
          type: object
          properties:
            code:
              type: string
              enum:
                - VALIDATION_ERROR
                - NOT_FOUND
                - UNAUTHORIZED
                - FORBIDDEN
                - CONFLICT
                - UPSTREAM_ERROR
                - RATE_LIMITED
                - INTERNAL_ERROR
                - FEATURE_DISABLED
                - CONDITIONAL_SELL_REJECTED
                - CONDITIONAL_SELL_ACTIVE
            message:
              type: string
              minLength: 1
            details:
              nullable: true
          required:
            - code
            - message
        meta:
          type: object
          properties:
            timestampMs:
              type: integer
              minimum: 0
            requestId:
              type: string
              minLength: 1
            traceId:
              type: string
              minLength: 1
            cachedAtMs:
              type: integer
              minimum: 0
            source:
              type: string
              enum:
                - cache
                - database
                - clickhouse
                - upstream
                - fallback
                - internal
          required:
            - timestampMs
            - requestId
      required:
        - success
        - error
        - meta
  securitySchemes:
    apiKey:
      type: http
      scheme: bearer
      description: >-
        A Lean API key, sent as `Authorization: Bearer <key>`. A test key
        (`lean_sk_test_...`) simulates orders and fills with no money; a live
        key (`lean_sk_live_...`) trades for real within the key's limits. Every
        successful response says which mode answered in `data.livemode`.

````

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