Save up to 17% with yearly billing

See pricing

Länder

Länder-Referenzdaten nach ISO 3166-1 alpha-2 für Flughafenformulare, Kontinentfilter und die Validierung von iso_country in Flughafendatensätzen. Zwei Operationen: alle Länder auflisten (optional nach Kontinent gefiltert) und ein einzelnes Land per Code abrufen. Liefert die Liste keine Treffer, wird countries: [] mit HTTP 200 zurückgegeben.

EndpointVerwendung
GET /countriesLänderauswahlen befüllen oder Flughafenlisten nach Kontinent filtern
GET /countries/{code}Einen einzelnen ISO-Code in eine kanonische Bezeichnung auflösen

Länder auflisten

Gibt alle Länder zurück, optional gefiltert nach Kontinentcode (AF, AN, AS, EU, NA, OC, SA).

Anfrage

Voraussetzungen

Auth
x-api-key bei jeder Anfrage (Direktabonnement). Mehr erfahren →
GEThttps://data.skylinkapi.com/v3.1/countries
ParameterTypErforderlichStandardBeschreibung
continentstringNeinalle KontinenteKontinentcode (AF, AN, AS, EU, NA, OC, SA)

Antwort

{
  "countries": [
    {
      "id": 302755,
      "code": "US",
      "name": "United States",
      "continent": null,
      "wikipedia_link": "https://en.wikipedia.org/wiki/United_States",
      "keywords": "American airports"
    }
  ],
  "total": 1
}
FeldTypErforderlichNull?Beschreibung
countriesarrayJaNiePassende Länderdatensätze
totalintegerJaNieAnzahl der zurückgegebenen Datensätze

Länderelement (countries[])

FeldTypErforderlichNull?Beschreibung
idintegerJaNieNumerische Kennung des Datensatzes
codestringJaNieCode nach ISO 3166-1 alpha-2
namestringJaNieName des Landes
continentstring | nullNeinJaKontinentcode, sofern zugewiesen
wikipedia_linkstring | nullNeinJaReferenz-URL
keywordsstring | nullNeinJaFreitext-Tags

Land per Code abrufen

Ruft ein einzelnes Land anhand des Codes nach ISO 3166-1 alpha-2 ab (z. B. US, GB). Gibt 404 zurück, wenn der Code nicht gefunden wird.

Anfrage

GEThttps://data.skylinkapi.com/v3.1/countries/{code}
ParameterTypErforderlichBeschreibung
codestringJaLändercode als Pfadparameter (alpha-2)

Antwort

{
  "id": 302755,
  "code": "US",
  "name": "United States",
  "continent": null,
  "wikipedia_link": "https://en.wikipedia.org/wiki/United_States",
  "keywords": "American airports"
}

Gleiche Objektstruktur wie bei den Listenelementen. continent, wikipedia_link und keywords können null sein.

Client-Typen

"""Country reference models for /countries endpoints."""from __future__ import annotationsfrom dataclasses import dataclass@dataclassclass CountriesListRequest:    continent: str | None = None@dataclassclass CountryByCodeRequest:    code: str@dataclassclass CountryRecord:    id: int    code: str    name: str    continent: str | None    wikipedia_link: str | None    keywords: str | None@dataclassclass CountriesResponse:    countries: list[CountryRecord]    total: int

Integration

Erstellen Sie eine validierte Liste von Länderoptionen für Flughafen- oder Routenfilter.

Das folgende Beispiel cacht die Länder-Referenzdaten 24 Stunden lang und verwendet explizite Timeouts, damit das Rendern von Formularen reaktionsschnell bleibt.

import osimport timefrom dataclasses import dataclassimport requestsHEADERS = {    "x-api-key": os.getenv("SKYLINK_API_KEY", "YOUR_API_KEY")}BASE = "https://data.skylinkapi.com/v3.1"CACHE: dict[str, tuple[dict, float]] = {}COUNTRIES_TTL = 86_400  # 24 h@dataclassclass CountryOption:    code: str    label: strdef fetch_countries(*, continent: str | None = None) -> list[dict]:    key = f"countries:{continent or 'all'}"    cached = CACHE.get(key)    if cached and time.time() < cached[1]:        return cached[0]["countries"]    params = {"continent": continent} if continent else None    try:        r = requests.get(f"{BASE}/countries", headers=HEADERS, params=params, timeout=(10, 15))    except requests.Timeout as exc:        raise RuntimeError("SkyLink timeout fetching countries") from exc    r.raise_for_status()    data = r.json()    CACHE[key] = (data, time.time() + COUNTRIES_TTL)    return data.get("countries", [])def get_country_by_code(code: str) -> dict | None:    code = code.upper()    try:        r = requests.get(f"{BASE}/countries/{code}", headers=HEADERS, timeout=(10, 15))    except requests.Timeout as exc:        raise RuntimeError(f"SkyLink timeout fetching country {code}") from exc    if r.status_code == 404:        return None    r.raise_for_status()    return r.json()def country_options(continent: str | None = None) -> list[CountryOption]:    items = fetch_countries(continent=continent)    return [CountryOption(code=item["code"], label=item["name"]) for item in items]if __name__ == "__main__":    import json    us = get_country_by_code("US")    print(json.dumps(us, indent=2, default=str))

Hinweise zur Implementierung

Filterung nach Kontinent. Übergeben Sie continent, um die Datenmenge in regionsspezifischen Produkten zu reduzieren (z. B. nur NA und EU).

Normalisierung von Codes. Wandeln Sie Benutzereingaben vor der Abfrage in Großbuchstaben um (us → US), um fälschliche 404-Fehler zu vermeiden.

Fehlerantworten

Gemeinsame Plattformfehler: Fehlerbehandlung. Endpoint-spezifisch:

404 - Land nicht gefunden

{
  "detail": "Country 'XX' not found"
}

400 - ungültiger Kontinentfilter

{
  "detail": "Invalid continent 'XX'. Valid values: AF, AN, AS, EU, NA, OC, SA"
}
GET
/countries
x-api-key<token>

Your SkyLink licence key, for keys bought direct from skylinkapi.com.

In: header

Query Parameters

continent?|

Filter by continent code: AF (Africa), AN (Antarctica), AS (Asia), EU (Europe), NA (North America), OC (Oceania), SA (South America)

Response Body

application/json

application/json

curl -X GET "https://data.skylinkapi.com/v3.1/countries"
{
  "countries": [
    {
      "id": 0,
      "code": "string",
      "name": "string",
      "continent": "string",
      "wikipedia_link": "string",
      "keywords": "string"
    }
  ],
  "total": 0
}
{
  "detail": [
    {
      "loc": [
        "string"
      ],
      "msg": "string",
      "type": "string",
      "input": null,
      "ctx": {}
    }
  ]
}
GET
/countries/{code}
x-api-key<token>

Your SkyLink licence key, for keys bought direct from skylinkapi.com.

In: header

Path Parameters

code*Code

ISO 3166-1 alpha-2 country code (e.g. US, GB, DE)

Response Body

application/json

application/json

curl -X GET "https://data.skylinkapi.com/v3.1/countries/US"
{
  "id": 0,
  "code": "string",
  "name": "string",
  "continent": "string",
  "wikipedia_link": "string",
  "keywords": "string"
}
{
  "detail": [
    {
      "loc": [
        "string"
      ],
      "msg": "string",
      "type": "string",
      "input": null,
      "ctx": {}
    }
  ]
}

Siehe auch: Regionen · Flughäfen · Flughafensuche