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

# 獲取聯盟佣金

> 你邀請的玩家向你支付的佣金

回傳呼叫方所邀請玩家向其支付的佣金，按玩家使用者名稱分組。不帶參數時回傳終身收益；帶 `fromDate` / `toDate` 時限定範圍。

<Note>
  與大多數端點不同，此端點在**頂層**以 `commissionPaid` 回傳結果（不在 `data` 下）。
</Note>

<h2 id="request">
  請求
</h2>

`GET /affiliate/getAffiliateCommission`

<ParamField query="fromDate" type="string">
  開始日期（`MM-DD-YYYY`）。預設為 `08-02-2021`。
</ParamField>

<ParamField query="toDate" type="string">
  結束日期（`MM-DD-YYYY`）。預設為今天。
</ParamField>

<CodeGroup>
  ```bash curl（日期範圍） theme={null}
  curl "https://api.4casters.io/affiliate/getAffiliateCommission?fromDate=10-03-2022&toDate=10-10-2022" \
    -H "Authorization: Bearer YOUR_TOKEN"
  ```

  ```bash curl（全部時間） theme={null}
  curl https://api.4casters.io/affiliate/getAffiliateCommission \
    -H "Authorization: Bearer YOUR_TOKEN"
  ```
</CodeGroup>

<h2 id="response">
  回應
</h2>

<ResponseField name="commissionPaid" type="array">
  每條記錄是單鍵物件，將玩家使用者名稱對應為該玩家在請求範圍內支付的佣金總額。
</ResponseField>

<h3 id="example">
  示例
</h3>

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

<h2 id="errors">
  錯誤
</h2>

| 狀態 | 含義 |
| - | - |
| `400` | `fromDate` 無法解析。 |


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