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

# Retrieve an order

> One API order by id, refreshed from its venues, with its market’s `title` and `outcome` and each leg’s status and the quantity filled so far. A canceled ioc order and its canceled legs carry `status_reason.code` `IOC_REMAINDER_CANCELED`: the venue canceled what did not fill at once, and `filled_quantity` is what filled.



## OpenAPI

````yaml api-reference/openapi.json GET /orders/{id}
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:
  /orders/{id}:
    get:
      tags:
        - Orders
      summary: Get an order
      description: >-
        One API order by id, refreshed from its venues, with its market’s
        `title` and `outcome` and each leg’s status and the quantity filled so
        far. A canceled ioc order and its canceled legs carry
        `status_reason.code` `IOC_REMAINDER_CANCELED`: the venue canceled what
        did not fill at once, and `filled_quantity` is what filled.
      operationId: getOrder
      parameters:
        - schema:
            type: string
            format: uuid
            example: 8a1e5c07-4b3f-4d62-9f18-2c7e0a95d4b1
          required: true
          name: id
          in: path
      responses:
        '200':
          description: Order refreshed from the venue
          content:
            application/json:
              schema:
                oneOf:
                  - type: object
                    properties:
                      success:
                        type: boolean
                        enum:
                          - true
                      data:
                        type: object
                        properties:
                          id:
                            type: string
                            format: uuid
                          client_order_id:
                            type: string
                            minLength: 1
                          market_id:
                            type: string
                            minLength: 1
                            description: >-
                              The market id from GET /markets, however the
                              request named the market.
                          title:
                            type: string
                            nullable: true
                            minLength: 1
                          outcome:
                            type: string
                            nullable: true
                            minLength: 1
                          venue:
                            type: string
                            nullable: true
                            enum:
                              - kalshi
                              - polymarket
                              - polymarket_us
                              - hyperliquid
                          ticker:
                            type: string
                            nullable: true
                            minLength: 1
                          side:
                            type: string
                            nullable: true
                            enum:
                              - 'yes'
                              - 'no'
                          action:
                            type: string
                            enum:
                              - buy
                              - sell
                          type:
                            type: string
                            enum:
                              - limit
                              - market
                          time_in_force:
                            type: string
                            enum:
                              - gtc
                              - ioc
                              - fok
                              - gtd
                          expires_at:
                            type: string
                            nullable: true
                            format: date-time
                          quantity:
                            type: string
                            pattern: ^\d+(?:\.\d+)?$
                          filled_quantity:
                            type: string
                            pattern: ^\d+(?:\.\d+)?$
                          remaining_quantity:
                            type: string
                            pattern: ^\d+(?:\.\d+)?$
                            description: >-
                              Shares still working on the venues: the unfilled
                              size of each live venue order. Zero once the order
                              is final, since a canceled, expired or rejected
                              remainder no longer works.
                          limit_price:
                            type: string
                          avg_fill_price:
                            type: string
                            nullable: true
                            description: >-
                              Average price per share filled, size-weighted
                              across the venue orders that filled, excluding
                              fees. Null until every filled venue order has a
                              price.
                          notional_usd:
                            type: string
                            pattern: ^\d+(?:\.\d+)?$
                          filled_notional_usd:
                            type: string
                            nullable: true
                            pattern: ^\d+(?:\.\d+)?$
                          status:
                            type: string
                            enum:
                              - pending
                              - open
                              - partially_filled
                              - filled
                              - canceled
                              - rejected
                              - expired
                              - unconfirmed
                              - needs_attention
                              - cancel_requested
                          venue_status:
                            type: string
                            nullable: true
                          venue_order_id:
                            type: string
                            nullable: true
                          status_reason:
                            type: object
                            nullable: true
                            properties:
                              code:
                                type: string
                                minLength: 1
                              message:
                                type: string
                                minLength: 1
                            required:
                              - code
                              - message
                          legs:
                            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'
                                quantity:
                                  type: string
                                  pattern: ^\d+(?:\.\d+)?$
                                filled_quantity:
                                  type: string
                                  pattern: ^\d+(?:\.\d+)?$
                                limit_price:
                                  type: string
                                avg_fill_price:
                                  type: string
                                  nullable: true
                                status:
                                  type: string
                                  enum:
                                    - pending
                                    - open
                                    - partially_filled
                                    - filled
                                    - canceled
                                    - rejected
                                    - expired
                                    - unconfirmed
                                    - needs_attention
                                    - cancel_requested
                                venue_status:
                                  type: string
                                  nullable: true
                                venue_order_id:
                                  type: string
                                  nullable: true
                                cancel_requested_at:
                                  type: string
                                  nullable: true
                                  format: date-time
                                status_reason:
                                  type: object
                                  nullable: true
                                  properties:
                                    code:
                                      type: string
                                      minLength: 1
                                    message:
                                      type: string
                                      minLength: 1
                                  required:
                                    - code
                                    - message
                              required:
                                - venue
                                - ticker
                                - side
                                - quantity
                                - filled_quantity
                                - limit_price
                                - avg_fill_price
                                - status
                                - venue_status
                                - venue_order_id
                                - cancel_requested_at
                                - status_reason
                          post_only:
                            type: boolean
                          replaces_order_id:
                            type: string
                            nullable: true
                            format: uuid
                          replaced_by_order_id:
                            type: string
                            nullable: true
                            format: uuid
                          created_at:
                            type: string
                            format: date-time
                          updated_at:
                            type: string
                            format: date-time
                          livemode:
                            type: boolean
                        required:
                          - id
                          - client_order_id
                          - market_id
                          - title
                          - outcome
                          - venue
                          - ticker
                          - side
                          - action
                          - type
                          - time_in_force
                          - expires_at
                          - quantity
                          - filled_quantity
                          - remaining_quantity
                          - limit_price
                          - avg_fill_price
                          - notional_usd
                          - filled_notional_usd
                          - status
                          - venue_status
                          - venue_order_id
                          - status_reason
                          - legs
                          - post_only
                          - replaces_order_id
                          - replaced_by_order_id
                          - created_at
                          - updated_at
                          - 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'
              examples:
                Filled:
                  summary: Refreshed from the venue
                  value:
                    success: true
                    data:
                      id: 3f6c2a8e-91d4-4b7a-8c25-0e4d7b19a6f3
                      client_order_id: bot-2026-10-29-0001
                      market_id: >-
                        mkt_bmZsOjIwMjYtMTAtMTE6REVOLUxBQwpzcHJlYWQ6Z2FtZTpERU46LTMuNQpERU4
                      venue: hyperliquid
                      ticker: <venue ticker>
                      side: 'yes'
                      action: buy
                      type: limit
                      time_in_force: ioc
                      expires_at: null
                      quantity: '5'
                      filled_quantity: '5'
                      remaining_quantity: '0'
                      limit_price: '0.50'
                      avg_fill_price: '0.47'
                      notional_usd: '2.5'
                      filled_notional_usd: '2.35'
                      status: filled
                      venue_status: filled
                      venue_order_id: '91234567012'
                      status_reason: null
                      post_only: false
                      replaces_order_id: null
                      replaced_by_order_id: null
                      legs:
                        - venue: hyperliquid
                          ticker: <venue ticker>
                          side: 'yes'
                          quantity: '5'
                          filled_quantity: '5'
                          limit_price: '0.50'
                          avg_fill_price: '0.47'
                          status: filled
                          venue_status: filled
                          venue_order_id: '91234567012'
                          cancel_requested_at: null
                          status_reason: null
                        - venue: hyperliquid
                          ticker: <venue ticker>
                          side: 'yes'
                          quantity: '5'
                          filled_quantity: '5'
                          limit_price: '0.50'
                          avg_fill_price: '0.47'
                          status: filled
                          venue_status: filled
                          venue_order_id: '91234567012'
                          cancel_requested_at: null
                          status_reason: null
                      created_at: '2026-10-11T18:00:02.114Z'
                      updated_at: '2026-10-11T18:00:02.587Z'
                      livemode: true
                    meta:
                      timestampMs: 1791741600000
                      requestId: e1b8d4a6-7c3f-4a90-b215-6d0e9f3c7a82
        '400':
          description: API error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ApiError'
              examples:
                Bad id:
                  summary: id is not a UUID
                  value:
                    success: false
                    error:
                      code: VALIDATION_ERROR
                      message: Invalid request
                      details:
                        - path: id
                          message: Invalid uuid
                        - path: id
                          message: Invalid uuid
                    meta:
                      timestampMs: 1791741600000
                      requestId: e1b8d4a6-7c3f-4a90-b215-6d0e9f3c7a82
        '401':
          description: Missing, invalid, expired or revoked API key
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ApiError'
              examples:
                Unknown key:
                  summary: Unknown, expired or revoked key
                  value:
                    success: false
                    error:
                      code: UNAUTHORIZED
                      message: Invalid, expired or revoked API key
                    meta:
                      timestampMs: 1791741600000
                      requestId: e1b8d4a6-7c3f-4a90-b215-6d0e9f3c7a82
                Missing key:
                  summary: No Authorization header
                  value:
                    success: false
                    error:
                      code: UNAUTHORIZED
                      message: Missing API key
                    meta:
                      timestampMs: 1791741600000
                      requestId: e1b8d4a6-7c3f-4a90-b215-6d0e9f3c7a82
        '403':
          description: The key lacks the scope this route needs
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ApiError'
              examples:
                Missing scope:
                  summary: The key lacks the read scope
                  value:
                    success: false
                    error:
                      code: FORBIDDEN
                      message: This API key lacks the read scope
                    meta:
                      timestampMs: 1791741600000
                      requestId: e1b8d4a6-7c3f-4a90-b215-6d0e9f3c7a82
        '404':
          description: API error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ApiError'
              examples:
                Not found:
                  summary: Order not found
                  value:
                    success: false
                    error:
                      code: NOT_FOUND
                      message: Order not found
                    meta:
                      timestampMs: 1791741600000
                      requestId: e1b8d4a6-7c3f-4a90-b215-6d0e9f3c7a82
        '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'
              examples:
                Rate limited:
                  summary: Over 5 requests a second; wait for Retry-After
                  value:
                    success: false
                    error:
                      code: RATE_LIMITED
                      message: Too many requests for this API key
                    meta:
                      timestampMs: 1791741600000
                      requestId: e1b8d4a6-7c3f-4a90-b215-6d0e9f3c7a82
        '500':
          description: API error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ApiError'
              examples:
                Internal error:
                  summary: Unexpected server error
                  value:
                    success: false
                    error:
                      code: INTERNAL_ERROR
                      message: An internal error occurred.
                    meta:
                      timestampMs: 1791741600000
                      requestId: e1b8d4a6-7c3f-4a90-b215-6d0e9f3c7a82
        '503':
          description: >-
            A venue could not be read or reached. The stored order is unchanged;
            read it again
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ApiError'
              examples:
                Venue unavailable:
                  summary: Read the order again; the stored order is unchanged
                  value:
                    success: false
                    error:
                      code: UPSTREAM_ERROR
                      message: Hyperliquid upstream request failed
                    meta:
                      timestampMs: 1791741600000
                      requestId: e1b8d4a6-7c3f-4a90-b215-6d0e9f3c7a82
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.