# skilive.sk API v1

Live data of Slovak ski resorts as JSON: operation status, snow and temperature, lifts and runs, ski pass prices,
opening hours, 7-day weather forecast, avalanche danger and webcams. Read-only (GET), UTF-8, field names in English,
texts localized with `lang`.

- Machine-readable spec (OpenAPI 3.1): https://skilive.sk/api/v1/openapi.json
- Human documentation with a live console (Slovak): https://skilive.sk/dokumentacia-api
- Contact: hej@skilive.sk

## Authentication

Send the key in the `X-API-Key` header (or `Authorization: Bearer <key>`; `?key=` only for quick tests).

- Resort key (`skl_s_…`): every resort on skilive gets one automatically in the skilive administration
  (account menu → "API kľúč pre vlastný web"). It reads only that resort.
- Global key (`skl_g_…`): issued by skilive, reads all published resorts.
- A key can be limited to websites (browser `Origin` check). `localhost`, `127.0.0.1`, `*.localhost`, `*.local` always work.
  Server-side requests are never limited by domain.
- Rate limit per key and minute (resort keys 120). Headers `X-RateLimit-Limit`, `X-RateLimit-Remaining`; 429 with `Retry-After`.
- Responses may be cached for 60 seconds.

## Endpoints

| Method and path | Returns |
|---|---|
| `GET /api/v1` | API info and links (no key) |
| `GET /api/v1/resorts` | Resorts available for the key (name, region, location, status, temperature, snow) |
| `GET /api/v1/resorts/{slug}` | All data of a resort; `?parts=status,lifts` for a subset |
| `GET /api/v1/resorts/{slug}/{part}` | One part: `{"slug", "<part>": ...}`, same shape as that field in the full resort |
| `GET /api/v1/openapi.json` | OpenAPI spec (no key) |

Query `lang`: `sk` (default), `cs`, `en`, `pl`, `hu`, `de`, `uk`; an unsupported value falls back to `sk` (see `lang` in the response).
Unknown names in `?parts=` return 400 `unknown_part`. `slug` is the last part of the resort URL on skilive.sk, e.g. `ski-ilanovo`.

Parts: `status`, `conditions`, `lifts`, `runs`, `prices`, `opening_hours`, `forecast`, `avalanche`, `cameras`, `news`.

## Response

Every response: `{"api", "version", "lang", "generated_at", "attribution": [...], "data": {...}}`.

```json
{
  "data": {
    "slug": "ski-ilanovo", "name": "Ski Iľanovo", "region": "Low Tatras", "partner": true,
    "url": "https://skilive.sk/stredisko/ski-ilanovo", "website": "https://skiilanovo.sk",
    "location": { "lat": 49.04607, "lon": 19.61675, "altitude_min": 642, "altitude_max": 730 },
    "season": "winter", "season_opens": null,
    "status": { "code": "closed", "text": "Closed today", "today_hours": null, "lifts_open": 0, "lifts_total": 3,
                "updated_at": "2026-11-27T19:11:58+01:00" },
    "conditions": { "temperature_c": -9.5, "snow_depth_cm": 4, "new_snow_24h_cm": 0, "surface": "thin cover", "surface_code": "thin_cover",
                    "groomed_at": null, "weather": { "text": "Clear", "icon": "pocasie-jasno", "wind_kmh": 10 } },
    "lifts": [ { "name": "Tatrapoma F-10", "type": "lift", "type_text": "drag lift", "status": "closed", "status_text": "not running", "detail": null } ],
    "runs":  [ { "name": "Hlavná", "type": "run", "type_text": "ski run", "status": "closed", "status_text": "not running", "detail": "red 400 m" } ],
    "prices": { "columns": ["Adult", "Child"], "column_codes": ["adult", "child"],
                "rows": [ { "name": "2 hours", "prices": [ { "amount": 16.0, "currency": "EUR", "text": "16 €" }, { "amount": 14.0, "currency": "EUR", "text": "14 €" } ] } ],
                "other": [ { "name": "Family 4 h (1+2)", "price": { "amount": 45.0, "currency": "EUR", "text": "45 €" }, "note": null } ] },
    "opening_hours": { "week": [ { "weekday": 0, "day": "Monday", "closed": false, "text": "9:00 – 16:00", "today": false } ],
                       "exceptions": [ { "date": "2026-12-24", "text": "closed" } ] },
    "forecast": [ { "date": "2026-11-29", "text": "Clear", "temp_max_c": -2, "temp_min_c": -10, "snow_cm": 0, "sunshine_h": 6.5 } ],
    "avalanche": { "level": 1, "text": "low", "region": "Low Tatras – west", "above_m": 1800, "valid_until": "2026-11-29T23:00:00+00:00" },
    "cameras": [ { "name": "Zjazdovka", "snapshot": "…", "player": "https://skilive.sk/embed/ski-ilanovo?k=ski-ilanovo-zjazdovka&l=en" } ],
    "news": [ { "text": "…", "from": "…", "to": null } ]
  }
}
```

Values:

- `status.code`: `open`, `partial` (partly open), `soon` (opens later today), `closed`, `unknown` (resort does not report operation).
- `status.today_hours` already includes special days (exceptions); use it for "today". `status.lifts_open` counts lifts with status `open` or `partial`.
- `prices.column_codes`: language-independent codes of price columns in the same order: `adult`, `child`, `junior`, `student`, `senior`, `disabled`, `family`, or a slug.
- `conditions.surface_code`: `powder`, `groomed`, `hard`, `wet`, `spring_snow`, `icy`, `tracked`, `windblown`, `thin_cover`, `granular`, `dirty`.
- `forecast` is in the Europe/Bratislava time zone: `forecast[0]` = today, `forecast[1]` = tomorrow.
- `lifts[].status`, `runs[].status`: `open`, `partial`, `closed`.
- `lifts[].type`: `gondola`, `chair`, `lift` (drag lift). `runs[].type`: `run`, `park`, `xc` (cross-country).
- `season`: `winter`, `summer`, `off_season`. Times are ISO 8601 with time zone; prices in EUR (number and formatted text).
- Public-data resorts (`partner: false`) have only `status` (code `unknown`), `conditions` (model), `lifts_summary`, `forecast`, `avalanche`.

## Errors

`{"error": {"status": 401, "code": "invalid_key", "message": "...", "docs": "..."}}`

| HTTP | code | Meaning |
|---|---|---|
| 401 | `missing_key`, `invalid_key` | Send the key; after regeneration use the new one |
| 403 | `origin_not_allowed` | Website not in the key's allowed domains |
| 400 | `unknown_part` | Unknown name in `?parts=` |
| 403 | `key_disabled` | Key disabled |
| 403 | `resort_not_available` | Resort key asking for another resort |
| 404 | `resort_not_available` | Unknown slug (global key) |
| 404 | `unknown_part` | Unknown part in the path `/{part}` |
| 429 | `rate_limited` | Wait `Retry-After` seconds, cache responses |

## Example (browser)

```js
fetch("https://skilive.sk/api/v1/resorts/ski-ilanovo?lang=en&parts=status,conditions,lifts", {
  headers: { "X-API-Key": "YOUR_KEY" }
})
  .then(r => r.json())
  .then(({ data }) => {
    console.log(data.status.text, data.conditions.temperature_c + " °C",
                data.status.lifts_open + "/" + data.status.lifts_total + " lifts");
  });
```

## Terms

- Credit "skilive.sk" with a link to the resort `url`; also credit sources in `attribution`
  (weather: Open-Meteo.com CC BY 4.0, avalanches: Slovak Mountain Rescue Service, map data: © OpenStreetMap contributors).
- Do not present the data misleadingly (status, prices) and do not resell it as a standalone product.
- Embed live webcam video only through `cameras[].player`.
