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

# Get orderbook (v1, deprecated)

> Legacy nested-orderbook endpoint kept for backwards compatibility

<Warning>
  **Deprecated.** Use [`GET /exchange/v2/getOrderbook`](/pages/rest/markets/get-orderbook) for the simpler, recommended flat format.

  This endpoint is kept for backwards compatibility with older clients.
</Warning>

Returns the orderbook for an entire league in **nested** form, keyed by spread / total number. Same per-game shape as [Get single orderbook](/pages/rest/markets/get-single-orderbook), but for every game in the league.

## Request

`POST /exchange/getOrderbook`

<ParamField body="leagueRequested" type="string" required>
  League code (case-insensitive).
</ParamField>

<CodeGroup>
  ```bash curl theme={null}
  curl -X POST https://api.4casters.io/exchange/getOrderbook \
    -H "Authorization: Bearer YOUR_TOKEN" \
    -H "Content-Type: application/json" \
    -d '{"leagueRequested": "NBA"}'
  ```
</CodeGroup>

## Response

<ResponseField name="data.market" type="string">Always `null` in this endpoint.</ResponseField>

<ResponseField name="data.games" type="array">
  Array of games with nested-orderbook fields. See [Get single orderbook](/pages/rest/markets/get-single-orderbook#response) for the per-game shape — `awayMoneylines` / `homeMoneylines` arrays plus `awaySpreads` / `homeSpreads` / `over` / `under` objects keyed by spread or total number.
</ResponseField>

Each individual order in those buckets has the standard order shape:

<Snippet file="types/orderbook-order.mdx" />


## OpenAPI

````yaml POST /exchange/getOrderbook
openapi: 3.1.0
info:
  title: 4casters REST API
  version: 1.0.0
  description: >-
    Public REST API for the 4casters peer-to-peer betting exchange. Use this API
    to manage your account, query the orderbook and games, and place / edit /
    cancel orders.


    All responses (unless noted otherwise) are JSON envelopes of the form `{
    "data": ... }`.
  contact:
    name: 4casters
    url: https://4casters.io
servers:
  - url: https://api.4casters.io
    description: Production
security:
  - bearerAuth: []
tags:
  - name: Authentication
    description: Login and account session management
  - name: User
    description: Read account info, bets, and orders
  - name: Orders
    description: Place, edit, look up, and cancel orders
  - name: Markets
    description: Browse leagues, games, participants, and orderbooks
  - name: Affiliate
    description: Affiliate / referral commission
paths:
  /exchange/getOrderbook:
    post:
      tags:
        - Markets
      summary: Get orderbook (v1, deprecated)
      description: >-
        **Deprecated.** Use `GET /exchange/v2/getOrderbook` instead.


        Returns the orderbook for an entire league in **nested** form, keyed by
        spread / total number. Kept for backwards compatibility with older
        clients.
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required:
                - leagueRequested
              properties:
                leagueRequested:
                  type: string
                  description: League code (case-insensitive).
            example:
              leagueRequested: NBA
      responses:
        '200':
          description: Nested-orderbook response
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: object
                    properties:
                      market:
                        type:
                          - string
                          - 'null'
                      games:
                        type: array
                        items:
                          $ref: '#/components/schemas/GameOrderbookNested'
        '401':
          $ref: '#/components/responses/Unauthorized'
      deprecated: true
components:
  schemas:
    GameOrderbookNested:
      allOf:
        - $ref: '#/components/schemas/Game'
        - type: object
          description: >-
            v1 orderbook: spreads and totals are objects keyed by spread / total
            number; values are arrays of orders.
          properties:
            homeMoneylines:
              type: array
              items:
                $ref: '#/components/schemas/OrderbookOrder'
            awayMoneylines:
              type: array
              items:
                $ref: '#/components/schemas/OrderbookOrder'
            homeSpreads:
              type: object
              additionalProperties:
                type: array
                items:
                  $ref: '#/components/schemas/OrderbookOrder'
              description: Keyed by spread number, e.g. `"-3.5"`.
            awaySpreads:
              type: object
              additionalProperties:
                type: array
                items:
                  $ref: '#/components/schemas/OrderbookOrder'
            over:
              type: object
              additionalProperties:
                type: array
                items:
                  $ref: '#/components/schemas/OrderbookOrder'
              description: Keyed by total number, e.g. `"220.5"`.
            under:
              type: object
              additionalProperties:
                type: array
                items:
                  $ref: '#/components/schemas/OrderbookOrder'
            homeMoneylines1x2:
              type: object
            awayMoneylines1x2:
              type: object
            draw1x2:
              type: object
            mainHomeSpread:
              type:
                - string
                - number
              nullable: true
            mainAwaySpread:
              type:
                - string
                - number
              nullable: true
            mainTotal:
              type:
                - string
                - number
              nullable: true
            openInterest:
              type: number
            matchedVolume:
              type: number
    Game:
      type: object
      description: Game without orderbook data.
      properties:
        id:
          type: string
        parentGameID:
          type: string
          nullable: true
        cheapDataUID:
          type: string
          description: >-
            Stable cross-system identifier for the game (used for line
            correlation).
        league:
          type: string
        sport:
          type: string
        start:
          type: string
          format: date-time
        ended:
          type: boolean
        live:
          type: boolean
        featured:
          type: boolean
        eventName:
          type: string
          nullable: true
        tournamentName:
          type: string
          nullable: true
        periodName:
          type: string
          description: e.g. `Full Time`, `1H`, `Set 1`.
        isSpecials:
          type: boolean
          description: True for futures and other specials markets.
        participants:
          type: array
          items:
            $ref: '#/components/schemas/Participant'
    OrderbookOrder:
      type: object
      description: A single resting order on the book.
      properties:
        id:
          type: string
        type:
          $ref: '#/components/schemas/MarketType'
        createdBy:
          type: string
          description: Present **only** when the order belongs to the caller.
        sumUntaken:
          type: number
          description: Win amount still available (taker pays risk to claim it).
        odds:
          type: integer
          description: American odds.
        bet:
          type: number
          description: Original `bet` amount.
        gameID:
          type: string
        takenRatio:
          type: number
          nullable: true
          description: Fraction of the order that has been matched.
        expiry:
          type: string
          format: date-time
          nullable: true
        createdAt:
          type: string
          format: date-time
        mockOrder:
          type: boolean
        gameStartExpiry:
          type: boolean
          description: True when the order is set to auto-cancel at game start.
        isPostArb:
          type: boolean
          description: 'Present when the order was placed with `orderType: postArb`.'
        participantID:
          type: string
          description: Present for `moneyline` and `spread`.
        spread:
          type: number
          description: Present for `spread`.
        total:
          type: number
          description: Present for `total`.
        OU:
          type: string
          enum:
            - over
            - under
          description: Present for `total`.
        market:
          type: string
          description: Present for `moneyline1x2`.
        side:
          type: string
          enum:
            - 'yes'
            - 'no'
          description: Present for `moneyline1x2`.
    Participant:
      type: object
      properties:
        id:
          type: string
        longName:
          type: string
        shortName:
          type: string
        homeAway:
          type: string
          enum:
            - home
            - away
        mainPitcher:
          type: string
          nullable: true
        rotationNumber:
          type: string
          nullable: true
        futuresSide:
          type: string
          nullable: true
        score:
          type: number
          description: Final score; only present for ended games.
    MarketType:
      type: string
      enum:
        - moneyline
        - spread
        - total
        - moneyline1x2
      description: >-
        Market type. `moneyline1x2` is **soccer-only** (three-way money line:
        home / away / draw).
  responses:
    Unauthorized:
      description: Missing or invalid auth token
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      description: >-
        Pass your auth token in the `Authorization` header. The `Bearer` prefix
        is optional; the server also accepts a signed `auth` cookie or a `token`
        field in the request body.

````