> ## 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 comisión de afiliado

> Comisión que te pagan los jugadores que invitaste

Devuelve la comisión pagada a la cuenta autenticada por los jugadores que ha invitado, agrupada por nombre de usuario del jugador. Sin parámetros, devuelve las ganancias de toda la vida; con `fromDate` / `toDate`, restringe el rango.

<Note>
  A diferencia de la mayoría de los endpoints, este devuelve el resultado en el **nivel superior** como `commissionPaid` (no bajo `data`).
</Note>

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

`GET /affiliate/getAffiliateCommission`

<ParamField query="fromDate" type="string">
  Fecha de inicio (`MM-DD-YYYY`). El valor por defecto es `08-02-2021`.
</ParamField>

<ParamField query="toDate" type="string">
  Fecha de fin (`MM-DD-YYYY`). El valor por defecto es hoy.
</ParamField>

<CodeGroup>
  ```bash curl (date range) theme={null}
  curl "https://api.4casters.io/affiliate/getAffiliateCommission?fromDate=10-03-2022&toDate=10-10-2022" \
    -H "Authorization: Bearer YOUR_TOKEN"
  ```

  ```bash curl (lifetime) theme={null}
  curl https://api.4casters.io/affiliate/getAffiliateCommission \
    -H "Authorization: Bearer YOUR_TOKEN"
  ```
</CodeGroup>

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

<ResponseField name="commissionPaid" type="array">
  Cada entrada es un objeto de una sola clave que mapea el nombre de usuario de un jugador a la comisión total pagada por ese jugador en el rango solicitado.
</ResponseField>

<h3 id="example">
  Ejemplo
</h3>

<CodeGroup>
  ```json JSON theme={null}
  {
    "commissionPaid": [
      { "alice":   124.50 },
      { "bob":      12.00 },
      { "charlie":  87.34 }
    ]
  }
  ```
</CodeGroup>

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

| Estado | Significado |
| - | - |
| `400` | `fromDate` no se puede interpretar. |


## OpenAPI

````yaml GET /affiliate/getAffiliateCommission
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:
  /affiliate/getAffiliateCommission:
    get:
      tags:
        - Affiliate
      summary: Get affiliate commission
      description: >-
        Return commission paid to the caller by the players they have invited,
        grouped by player username. With no parameters, returns lifetime
        earnings; with `fromDate` / `toDate`, restricts the range.
      parameters:
        - name: fromDate
          in: query
          required: false
          schema:
            type: string
            example: 10-03-2022
          description: Start date (`MM-DD-YYYY`). Defaults to `08-02-2021`.
        - name: toDate
          in: query
          required: false
          schema:
            type: string
            example: 10-10-2022
          description: End date (`MM-DD-YYYY`). Defaults to today.
      responses:
        '200':
          description: Commission summary
          content:
            application/json:
              schema:
                type: object
                properties:
                  commissionPaid:
                    type: array
                    description: >-
                      Each entry is a single-key object mapping a player's
                      username to total commission paid.
                    items:
                      type: object
                      additionalProperties:
                        type: number
                    example:
                      - alice: 124.5
                      - bob: 12
        '400':
          description: Invalid `fromDate`
        '401':
          $ref: '#/components/responses/Unauthorized'
components:
  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.