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

> List leagues with active markets

Returns every league with active markets on the exchange. Use league codes from this endpoint to fetch games (`/exchange/v2/getGames`) and orderbooks (`/exchange/v2/getOrderbook`).

If the response contains a league name with `LIVE` in it (other than the per-sport live leagues `NFL-LIVE`, `NBA-LIVE`, `NCAAF-LIVE`, `NCAAB-LIVE`), the value `"LIVE"` is appended as an alias for "all in-play games".

## Request

`GET /exchange/getLeagues`

<ParamField query="sport" type="string">
  Optional sport filter (`basketball`, `baseball`, `hockey`, `football`, `soccer`, `golf`, `tennis`, `mma`, etc.). When `sport=soccer` or `sport=golf`, the value `"all"` is appended to the list.
</ParamField>

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

## Response

<ResponseField name="data.availableLeagues" type="array">
  Array of league codes.
</ResponseField>

### Example

<CodeGroup>
  ```json JSON theme={null}
  {
    "data": {
      "availableLeagues": [
        "CHAMPIONS-LEAGUE",
        "NBA",
        "NHL",
        "BUNDESLIGA",
        "PREMIER-LEAGUE",
        "PGA",
        "LA-LIGA",
        "NON-UFC",
        "SERIE-A",
        "MLS",
        "UFCMMA"
      ]
    }
  }
  ```
</CodeGroup>


## OpenAPI

````yaml GET /exchange/getLeagues
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/getLeagues:
    get:
      tags:
        - Markets
      summary: Get leagues
      description: >-
        Return every league with active markets on the exchange. If the response
        includes a league containing `LIVE` (other than the per-sport live
        leagues `NFL-LIVE`, `NBA-LIVE`, `NCAAF-LIVE`, `NCAAB-LIVE`), the value
        `LIVE` is appended as an alias for fetching all in-play games.
      parameters:
        - name: sport
          in: query
          required: false
          schema:
            type: string
          description: >-
            Optional sport filter (e.g. `basketball`, `soccer`, `golf`). When
            `sport=soccer` or `sport=golf`, `all` is appended to the list.
      responses:
        '200':
          description: Available leagues
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: object
                    properties:
                      availableLeagues:
                        type: array
                        items:
                          type: string
                        example:
                          - NBA
                          - NHL
                          - PREMIER-LEAGUE
                          - PGA
        '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.

````