# API

Read-only JSON over HTTPS, free, no key: the 14 National League clubs, their current entries and recent changes. The [reference](/api/reference) lists every endpoint and field; the [OpenAPI 3.1 document](https://api.sidelined.ch/v1/openapi.json) describes the same, for code and agents.

## Quickstart

The clubs and how many players each is missing:

```sh
curl https://api.sidelined.ch/v1/teams
```

One club's current entries:

```sh
curl https://api.sidelined.ch/v1/teams/zug/absences
```

```json
{
  "data": [
    {
      "id": 89,
      "team": "zug",
      "player": { "id": 69, "name": "Lukas Bengtsson", "jersey": 32 },
      "type": "injury",
      "category": "out",
      "confidence": "official",
      "reason_text": "fibula",
      "body_region": "lower_body",
      "since": "2026-10-11",
      "since_kind": "reported",
      "return": { "text": "several months", "kind": "duration", "min": "2026-12-10", "max": "2027-04-09" },
      "detail": null,
      "sources": [
        { "kind": "medical_report", "label": "club medical report", "url": "https://www.evz.ch/en/eissport/men/medical-report/" }
      ],
      "off_club_report": null,
      "expected_back": null,
      "updated_at": "2026-10-21T13:00:40.995Z"
    }
  ],
  "attribution": { "text": "Data: sidelined.ch, from the clubs, the National League and the Swiss Ice Hockey Federation (sources on each entry)", "url": "https://sidelined.ch" }
}
```

What changed in the last 14 days, newest first:

```sh
curl "https://api.sidelined.ch/v1/changes?team=zug&limit=20"
```

## Endpoints

| Endpoint | Returns |
|---|---|
| `GET /v1/teams` | The 14 clubs: name, slug, logo, players out, scratches, loans, last checked |
| `GET /v1/teams/{slug}` | One club with all its current entries |
| `GET /v1/teams/{slug}/absences` | The club's entries (`category=out` by default; also `scratch`, `loan`, `all`) |
| `GET /v1/absences` | All entries, filterable by `team`, `type`, `confidence`, `category` |
| `GET /v1/changes` | Recent changes: newly out, updated (also off or back on the club's report), back, no longer listed; `since`, `team`, `limit`, `cursor` |
| `GET /v1/openapi.json` | The OpenAPI 3.1 document |

## Conventions

- **Base URL:** `https://api.sidelined.ch/v1`. Breaking changes only come with `/v2`; deprecations are announced in the [changelog](/changelog) and with `Deprecation` and `Sunset` headers.
- **JSON:** `snake_case` fields, dates as `YYYY-MM-DD`, timestamps in UTC (ISO 8601), stable IDs.
- **Attribution:** every response has an `attribution`. Show its `text` with a link to its `url` wherever you show the data.
- **Errors:** [problem details](/api/errors) (`application/problem+json`), each with a `type` link explaining what to do.
- **Caching:** responses carry an `ETag`; send it back as `If-None-Match` and you get `304 Not Modified` when nothing changed. They may be cached for a minute; the sources are read every 15 to 30 minutes, so polling more often than every few minutes brings nothing new.
- **Rate limit:** 60 requests a minute per IP address. Above that: `429` with `Retry-After`.
- **CORS:** open, so browsers can call the API directly. Read-only, no cookies.
- **Pagination:** `/v1/changes` returns `next_cursor`; pass it back as `cursor` for the next page. It's `null` on the last page. A page can hold fewer than `limit` changes.

## Next

- [The data model](/api/concepts): what `type`, `confidence`, `since_kind` and `return` mean.
- [Reference](/api/reference): every endpoint, parameter and field.
- [Errors](/api/errors): what each error means and what to do.
