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.
| Endpoint | Verwendung |
|---|---|
GET /countries | Lä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
x-api-key bei jeder Anfrage (Direktabonnement). Mehr erfahren →https://data.skylinkapi.com/v3.1/countries| Parameter | Typ | Erforderlich | Standard | Beschreibung |
|---|---|---|---|---|
continent | string | Nein | alle Kontinente | Kontinentcode (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
}| Feld | Typ | Erforderlich | Null? | Beschreibung |
|---|---|---|---|---|
countries | array | Ja | Nie | Passende Länderdatensätze |
total | integer | Ja | Nie | Anzahl der zurückgegebenen Datensätze |
Länderelement (countries[])
| Feld | Typ | Erforderlich | Null? | Beschreibung |
|---|---|---|---|---|
id | integer | Ja | Nie | Numerische Kennung des Datensatzes |
code | string | Ja | Nie | Code nach ISO 3166-1 alpha-2 |
name | string | Ja | Nie | Name des Landes |
continent | string | null | Nein | Ja | Kontinentcode, sofern zugewiesen |
wikipedia_link | string | null | Nein | Ja | Referenz-URL |
keywords | string | null | Nein | Ja | Freitext-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
https://data.skylinkapi.com/v3.1/countries/{code}| Parameter | Typ | Erforderlich | Beschreibung |
|---|---|---|---|
code | string | Ja | Lä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: intIntegration
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"
}Your SkyLink licence key, for keys bought direct from skylinkapi.com.
In: header
Query Parameters
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": {}
}
]
}Your SkyLink licence key, for keys bought direct from skylinkapi.com.
In: header
Path Parameters
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
Fluggesellschaften
Referenzdaten von Fluggesellschaften per ICAO- oder IATA-Code abfragen, inklusive Rufzeichen, Land, Aktivstatus und Logo-URL, sofern verfügbar.
Regionen
Referenzdaten zu Regionen nach ISO 3166-2 (Bundesstaaten/Provinzen) für Flughafenformulare und Validierung, mit Listen- und Code-Abfrage.