# GET /leagues - List All Leagues
URL: https://sockodds.com/docs/endpoints/getLeagues/

# GET /leagues - List All Leagues [#get-leagues---list-all-leagues]

Get a list of Leagues

`GET https://api.sockodds.com/v2/leagues/`

Retrieve all supported leagues with leagueID values. `enabled` reflects what your plan can see.

## Query parameters [#query-parameters]

| Parameter | Type | Description |
| --- | --- | --- |
| `sportID` | `string` | The sport to get leagues for |
| `leagueID` | `string` | The league to get data for |

## Response [#response]

`{ "success": true, "data": League[], "nextCursor": string | null }`

### League [#league]

Contains information on a specific league

| Field | Type | Description |
| --- | --- | --- |
| `leagueID` | `string` |  |
| `sportID` | `string` |  |
| `name / shortName` | `string` |  |
| `enabled` | `boolean` | Whether your plan can read this league |
| `activeEvents` | `number` | Events currently carried |

### Status codes [#status-codes]

| Status | Body |
| --- | --- |
| `200` | `Success` |
| `400` | `{"success":false,"error":"Invalid params"}` |
| `401` | `{"success":false,"error":"Invalid API key"}` |
| `403` | `{"success":false,"error":"Inactive API key"}` |
| `429` | `{"success":false,"error":"Rate limit exceeded"} (Retry-After header)` |

## Code samples [#code-samples]

**cURL** · **JavaScript** · **Python** · **Go** · **Java** · **C#**

```bash
curl -X GET "https://api.sockodds.com/v2/leagues/?sportID=RUGBY_LEAGUE" \
  -H "x-api-key: YOUR_API_KEY"
```

```javascript
const r = await fetch("https://api.sockodds.com/v2/leagues/?sportID=RUGBY_LEAGUE", { headers: { "x-api-key": "YOUR_API_KEY" } });
const { success, data, nextCursor, notice } = await r.json();
```

```python
import requests
r = requests.get("https://api.sockodds.com/v2/leagues/", params=dict(sportID="RUGBY_LEAGUE"), headers={"x-api-key": "YOUR_API_KEY"})
body = r.json()
```

```go
req, _ := http.NewRequest("GET", "https://api.sockodds.com/v2/leagues/?sportID=RUGBY_LEAGUE", nil)
req.Header.Set("x-api-key", "YOUR_API_KEY")
res, err := http.DefaultClient.Do(req)
```

```java
HttpRequest req = HttpRequest.newBuilder().uri(URI.create("https://api.sockodds.com/v2/leagues/?sportID=RUGBY_LEAGUE"))
    .header("x-api-key", "YOUR_API_KEY").GET().build();
HttpResponse<String> res = HttpClient.newHttpClient().send(req, HttpResponse.BodyHandlers.ofString());
```

```csharp
using var http = new HttpClient();
http.DefaultRequestHeaders.Add("x-api-key", "YOUR_API_KEY");
var body = await http.GetStringAsync("https://api.sockodds.com/v2/leagues/?sportID=RUGBY_LEAGUE");
```

## Try it [#try-it]

> Need help?[FAQ](https://sockodds.com/docs/faq/) · [Email](mailto:api@sockodds.com) · [Contact](https://sockodds.com/contact-us/)
