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

# Obtener un libro de órdenes

> Lee el libro de órdenes anidado de un juego, más los mercados hijos

Devuelve el libro de órdenes **anidado** de un solo juego: spreads y totals son objetos indexados por el número de spread / total en lugar de arrays planos. También devuelve cualquier juego hijo (props, periodos alternativos) y un `orderSummary` de las propias órdenes en espera de la cuenta autenticada en la liga.

Para la forma plana más simple, prefiere [Obtener libro de órdenes](/es/pages/rest/markets/get-orderbook).

<h2 id="request">
  Solicitud
</h2>

`GET /exchange/getSingleOrderbook`

<ParamField query="gameID" type="string" required>
  Id del juego.
</ParamField>

<CodeGroup>
  ```bash curl theme={null}
  curl "https://api.4casters.io/exchange/getSingleOrderbook?gameID=65b67450503180295ade9216" \
    -H "Authorization: Bearer YOUR_TOKEN"
  ```
</CodeGroup>

<h2 id="response">
  Respuesta
</h2>

<ResponseField name="data.game" type="object">
  Objeto de juego con campos de libro de órdenes anidado. Aplican los campos estándar de `Game` (consulta [Obtener juegos](/es/pages/rest/markets/get-games#response)), más:

  <Expandable title="Campos del libro de órdenes por juego">
    <ResponseField name="awayMoneylines" type="array">Órdenes moneyline en espera del lado visitante. Ordenadas con el mejor precio primero.</ResponseField>
    <ResponseField name="homeMoneylines" type="array">Órdenes moneyline en espera del lado local.</ResponseField>
    <ResponseField name="awaySpreads" type="object">Objeto indexado por número de spread (p. ej. `"-3.5"`). Cada valor es un array de órdenes.</ResponseField>
    <ResponseField name="homeSpreads" type="object">Objeto indexado por número de spread.</ResponseField>
    <ResponseField name="over" type="object">Objeto indexado por número de total (p. ej. `"220.5"`). Cada valor es un array de órdenes.</ResponseField>

    <ResponseField name="under" type="object" />

    <ResponseField name="homeMoneylines1x2" type="object">**Solo fútbol.** Objeto con arrays `homeYes` / `homeNo`.</ResponseField>
    <ResponseField name="awayMoneylines1x2" type="object">**Solo fútbol.** Objeto con arrays `awayYes` / `awayNo`.</ResponseField>
    <ResponseField name="draw1x2" type="object">**Solo fútbol.** Objeto con arrays `drawYes` / `drawNo`.</ResponseField>
    <ResponseField name="mainHomeSpread" type="string">El spread local principal que se muestra actualmente (la línea de consenso).</ResponseField>

    <ResponseField name="mainAwaySpread" type="number" />

    <ResponseField name="mainTotal" type="string" />

    <ResponseField name="openInterest" type="number" />

    <ResponseField name="matchedVolume" type="number" />
  </Expandable>
</ResponseField>

<ResponseField name="data.orderSummary" type="array">
  Las propias órdenes en espera de la cuenta autenticada en toda la liga (no solo este juego). Útil para renderizar insignias de "tus ofertas" en una UI.
</ResponseField>

<ResponseField name="data.childGames" type="array">
  Juegos hijos (periodos alternativos, etc.) del juego solicitado. Misma forma que `data.game`.
</ResponseField>

<ResponseField name="data.propGames" type="array">
  Juegos de props ligados al juego solicitado.
</ResponseField>

Cada orden individual tiene la forma estándar de orden:

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

<h2 id="errors">
  Errores
</h2>

| Estado | Significado |
| - | - |
| `400` | Falta `gameID`. |


## OpenAPI

````yaml GET /exchange/getSingleOrderbook
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/getSingleOrderbook:
    get:
      tags:
        - Markets
      summary: Get single orderbook
      description: >-
        Return the nested orderbook for a single game, plus any child games
        (props, alternate periods) and an `orderSummary` of the caller's own
        resting orders for the league.
      parameters:
        - name: gameID
          in: query
          required: true
          schema:
            type: string
          description: Game id.
      responses:
        '200':
          description: Single-game orderbook
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: object
                    properties:
                      game:
                        $ref: '#/components/schemas/GameOrderbookNested'
                      orderSummary:
                        type: array
                        items:
                          type: object
                      childGames:
                        type: array
                        items:
                          $ref: '#/components/schemas/GameOrderbookNested'
                      propGames:
                        type: array
                        items:
                          $ref: '#/components/schemas/GameOrderbookNested'
        '400':
          description: Missing required parameter `gameID`
        '401':
          $ref: '#/components/responses/Unauthorized'
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.

````

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