> ## 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 affiliate commission

> Commission paid to you by your invited players

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

<Note>
  Unlike most endpoints, this one returns the result at the **top level** as `commissionPaid` (not under `data`).
</Note>

## Request

`GET /affiliate/getAffiliateCommission`

<ParamField query="fromDate" type="string">
  Start date (`MM-DD-YYYY`). Defaults to `08-02-2021`.
</ParamField>

<ParamField query="toDate" type="string">
  End date (`MM-DD-YYYY`). Defaults to today.
</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>

## Response

<ResponseField name="commissionPaid" type="array">
  Each entry is a single-key object mapping a player's username to the total commission paid by that player in the requested range.
</ResponseField>

### Example

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

## Errors

| Status | Meaning                      |
| ------ | ---------------------------- |
| `400`  | `fromDate` is not parseable. |


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

````