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

# Obter aposta por ID

> Consulta uma única aposta por id ou id de transação

Consulta uma única aposta (casada, liquidada ou oferta aberta) que pertence à conta autenticada. Passe **ou** `id` **ou** `txID`, não ambos.

## Requisição

`GET /user/getBetByID`

**id** `string`

`id` da aposta de um endpoint de listagem como `/user/getMatchedBets`.

**txID** `string`

Id de transação, p. ex. o `wagerRequestID` ou `txID` que `/session/v3/place` retorna.

Você deve passar exatamente um de `id` ou `txID`.

```bash curl (por txID) theme={null}
curl "https://api.4casters.io/user/getBetByID?txID=64824b329556daa319747e31" \
  -H "Authorization: Bearer YOUR_TOKEN"
```

```bash curl (por id) theme={null}
curl "https://api.4casters.io/user/getBetByID?id=6494ca85c9346058f35b2b1e" \
  -H "Authorization: Bearer YOUR_TOKEN"
```

## Resposta

A forma de `bet` depende do estado atual da aposta:

* Uma aposta **liquidada** retorna a forma [GradedWager](https://docs.4casters.io/pt-BR/pages/rest/user/get-graded-wagers.md#response), incluindo `risk`, `win`, `fee` e `result`.
* Uma aposta **casada** retorna a forma [MatchedBet](https://docs.4casters.io/pt-BR/pages/rest/user/get-matched-bets.md#response).
* Uma **oferta aberta** retorna a forma [UnmatchedOrder](https://docs.4casters.io/pt-BR/pages/rest/user/get-unmatched-orders.md#response).

Observe que, ao contrário da maioria dos endpoints, este retorna a aposta no **nível superior** (não sob `data`).

### Exemplo

```json JSON (oferta aberta) theme={null}
{
  "bet": {
    "id": "667c1e870c0d22ec36ccb438",
    "txID": "667c1e870c0d22ec36ccb439",
    "type": "moneyline",
    "bet": 222,
    "graded": false,
    "closed": false,
    "createdAt": "2024-06-26T13:58:31.224Z",
    "origin": "offer",
    "wagerRequestID": "667c1e870c...",
    "game": {
      "id": "6679ee8c9f05a804e064b6ed",
      "league": "FED-EX-500",
      "sport": "golf",
      "start": "2024-06-27T10:45:00.000Z",
      "ended": false,
      "participants": [/* ... */]
    }
  }
}
```

## Erros

| Status | Significado |
| - | - |
| `400` | Faltam tanto `id` quanto `txID`, ou nenhuma aposta foi encontrada para o identificador indicado. |


## OpenAPI

````yaml GET /user/getBetByID
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:
  /user/getBetByID:
    get:
      tags:
        - User
      summary: Get bet by ID or txID
      description: >-
        Look up a single bet (matched, graded, or open offer) belonging to the
        caller. Pass **either** `id` (the bet's `id`, e.g. from
        `/user/getMatchedBets`) **or** `txID` (the transaction id, e.g. from a
        `/session/v3/place` response).
      parameters:
        - name: id
          in: query
          required: false
          schema:
            type: string
          description: Bet `id` from a list endpoint.
        - name: txID
          in: query
          required: false
          schema:
            type: string
          description: >-
            Transaction id (e.g. `wagerRequestID` or `txID` returned from
            place). 
      responses:
        '200':
          description: >-
            The bet, in matched, graded, or open form depending on its current
            state.
          content:
            application/json:
              schema:
                type: object
                properties:
                  bet:
                    oneOf:
                      - $ref: '#/components/schemas/MatchedBet'
                      - $ref: '#/components/schemas/GradedWager'
                      - $ref: '#/components/schemas/UnmatchedOrder'
        '400':
          description: Invalid `id` / `txID`
        '401':
          $ref: '#/components/responses/Unauthorized'
components:
  schemas:
    MatchedBet:
      type: object
      description: A bet that has been matched but not yet graded.
      properties:
        id:
          type: string
        txID:
          type: string
        type:
          $ref: '#/components/schemas/MarketType'
        bet:
          type: number
        odds:
          type: integer
        spread:
          type: number
          nullable: true
        total:
          type: number
          nullable: true
        OU:
          type: string
          enum:
            - over
            - under
          description: Present for `total`.
        participantID:
          type: string
          description: Present for `moneyline` / `spread`.
        market:
          type: string
          description: Present for `moneyline1x2`.
        side:
          $ref: '#/components/schemas/MarketSide'
        userReference:
          type: string
        createdAt:
          type: string
          format: date-time
        matchedTime:
          type: string
          format: date-time
        graded:
          type: boolean
        closed:
          type: boolean
        origin:
          type: string
          description: '`offer` or `wager`.'
        adminRefund:
          type: boolean
        risk:
          type: string
          description: >-
            Risk on the matched portion, inclusive of the commission charged on
            a loss.
        win:
          type: string
          description: Win amount net of the commission charged on a win.
        game:
          $ref: '#/components/schemas/GameSummary'
    GradedWager:
      type: object
      description: A settled wager.
      properties:
        id:
          type: string
        txID:
          type: string
        ticketNumber:
          type: string
        type:
          $ref: '#/components/schemas/MarketType'
        outcome:
          type: string
          enum:
            - winner
            - loser
            - push
            - refund
        bet:
          type: number
        odds:
          type: integer
        spread:
          type: number
          nullable: true
        total:
          type: number
          nullable: true
        OU:
          type: string
          enum:
            - over
            - under
        participantID:
          type: string
        market:
          type: string
        side:
          $ref: '#/components/schemas/MarketSide'
        matchedTime:
          type: string
          format: date-time
        settledAt:
          type: string
          format: date-time
        createdAt:
          type: string
          format: date-time
        graded:
          type: boolean
        closed:
          type: boolean
        cancelled:
          type: boolean
        adminRefund:
          type: boolean
        platform:
          type: string
          example: api
        fee:
          type: string
          description: Commission charged on the matched portion.
        risk:
          type: string
        win:
          type: string
        result:
          type: string
          description: Net P&L on this wager (signed).
        pinnacleLine:
          type: object
          description: >-
            Snapshot of the comparable Pinnacle line at fill time, when
            available.
        game:
          $ref: '#/components/schemas/GameSummary'
    UnmatchedOrder:
      type: object
      description: An open order that is currently resting on the exchange.
      properties:
        id:
          type: string
        txID:
          type: string
        type:
          $ref: '#/components/schemas/MarketType'
        bet:
          type: number
        odds:
          type: integer
        spread:
          type: number
          nullable: true
        total:
          type: number
          nullable: true
        participantID:
          type: string
          description: Present for `moneyline` / `spread`.
        otherParticipantID:
          type: string
          description: The opposite participant id (the one whose side is being offered).
        expiry:
          type: string
          format: date-time
          nullable: true
        filled:
          type: number
        offered:
          type: number
        remaining:
          type: number
        takenRatio:
          type: number
        createdAt:
          type: string
          format: date-time
        origin:
          type: string
          description: '`offer` or `wager`.'
        graded:
          type: boolean
        closed:
          type: boolean
        adminRefund:
          type: boolean
        userReference:
          type: string
        wagerRequestID:
          type: string
        game:
          $ref: '#/components/schemas/GameSummary'
    MarketType:
      type: string
      enum:
        - moneyline
        - spread
        - total
        - moneyline1x2
      description: >-
        Market type. `moneyline1x2` is **soccer-only** (three-way money line:
        home / away / draw).
    MarketSide:
      type: string
      description: |-
        Order side. Meaning depends on `type`:

        - `moneyline`, `spread` — the participant id you are backing.
        - `total` — `"over"` or `"under"`.
        - `moneyline1x2` — `"yes"` or `"no"` on the outcome named by `market`.
    GameSummary:
      type: object
      properties:
        id:
          type: string
        league:
          type: string
        sport:
          type: string
        start:
          type: string
          format: date-time
        ended:
          type: boolean
        eventName:
          type: string
          nullable: true
        isFutures:
          type: boolean
        participants:
          type: array
          items:
            $ref: '#/components/schemas/Participant'
    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.
  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.