Regionen
Regionale Untergliederungen nach ISO 3166-2 (Bundesstaaten, Provinzen, Territorien). Der wichtigste Integrationsweg ist die Auflösung von iso_region aus Flughäfen in eine lesbare Bezeichnung — zum Beispiel US-NY → New York. Zwei Operationen: Regionen auflisten (gefiltert nach Land oder Kontinent) und eine einzelne Region per Code abrufen.
Filtern Sie, wann immer möglich. Eine ungefilterte Liste liefert weltweit ca. 3.900 Zeilen. Übergeben Sie in produktiven UIs country oder continent.
| Endpoint | Einsatzzweck |
|---|---|
GET /regions | Regionsauswahl, gefiltert nach Land oder Kontinent |
GET /regions/{code} | iso_region aus einem Flughafendatensatz auflösen |
Regionen auflisten
Liefert Regionen, optional gefiltert nach Land und/oder Kontinent.
Anfrage
Voraussetzungen
x-api-key bei jeder Anfrage (Direktabonnement). Mehr erfahren →https://data.skylinkapi.com/v3.1/regions| Parameter | Typ | Erforderlich | Standard | Beschreibung |
|---|---|---|---|---|
country | string | Nein | alle Länder | Ländercode nach ISO 3166-1 alpha-2, z. B. US |
continent | string | Nein | alle Kontinente | Kontinentcode (AF, AN, AS, EU, NA, OC, SA) |
Antwort
{
"regions": [
{
"id": 306110,
"code": "US-NY",
"local_code": "NY",
"name": "New York",
"continent": null,
"iso_country": "US",
"wikipedia_link": "https://en.wikipedia.org/wiki/New_York",
"keywords": "Airports in New York"
}
],
"total": 1
}| Feld | Typ | Erforderlich | Null? | Beschreibung |
|---|---|---|---|---|
regions | array | Ja | Nie | Passende Regionsdatensätze |
total | integer | Ja | Nie | Anzahl der zurückgegebenen Regionen |
Regionseintrag (regions[])
| Feld | Typ | Erforderlich | Null? | Beschreibung |
|---|---|---|---|---|
id | integer | Ja | Nie | Numerische Datensatzkennung |
code | string | Ja | Nie | ISO-3166-2-Regionscode, z. B. US-NY |
local_code | string | null | Nein | Ja | Landesinterner Kurzcode (z. B. NY) |
name | string | Ja | Nie | Name der Region |
continent | string | null | Nein | Ja | Kontinentcode, sofern zugeordnet |
iso_country | string | Ja | Nie | Alpha-2-Code des übergeordneten Landes |
wikipedia_link | string | null | Nein | Ja | Referenz-URL |
keywords | string | null | Nein | Ja | Freitext-Tags |
Region per Code abrufen
Rufen Sie eine einzelne Region per ISO 3166-2-Code ab (z. B. US-CA, GB-ENG). Liefert 404, wenn der Code nicht gefunden wird.
Anfrage
https://data.skylinkapi.com/v3.1/regions/{code}| Parameter | Typ | Erforderlich | Beschreibung |
|---|---|---|---|
code | string | Ja | Pfadparameter mit dem ISO-3166-2-Regionscode |
Antwort
{
"id": 306110,
"code": "US-NY",
"local_code": "NY",
"name": "New York",
"continent": null,
"iso_country": "US",
"wikipedia_link": "https://en.wikipedia.org/wiki/New_York",
"keywords": "Airports in New York"
}Gleiche Objektstruktur wie bei den Listeneinträgen. Listenfilter ohne Treffer liefern regions: [] und total: 0 — keinen Fehler.
Client-Typen
"""Region reference models for /regions endpoints."""from __future__ import annotationsfrom dataclasses import dataclass@dataclassclass RegionsListRequest: country: str | None = None continent: str | None = None@dataclassclass RegionByCodeRequest: code: str@dataclassclass RegionRecord: id: int code: str local_code: str | None name: str continent: str | None iso_country: str wikipedia_link: str | None keywords: str | None@dataclassclass RegionsResponse: regions: list[RegionRecord] total: intIntegration
Rufen Sie Regionsreferenzdaten für ein ausgewähltes Land ab und bilden Sie sie auf Formularoptionen ab.
Das folgende Beispiel speichert Regionslisten 24 Stunden lang im Cache und verwendet explizite Timeouts, damit Onboarding-Formulare reaktionsschnell bleiben.
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]] = {}REGIONS_TTL = 86_400 # 24 h@dataclassclass RegionOption: code: str label: strdef fetch_regions(*, country: str) -> list[dict]: country = country.upper() key = f"regions:{country}" cached = CACHE.get(key) if cached and time.time() < cached[1]: return cached[0]["regions"] try: r = requests.get( f"{BASE}/regions", headers=HEADERS, params={"country": country}, timeout=(10, 15), ) except requests.Timeout as exc: raise RuntimeError(f"SkyLink timeout fetching regions for {country}") from exc r.raise_for_status() data = r.json() CACHE[key] = (data, time.time() + REGIONS_TTL) return data.get("regions", [])def get_region_by_code(code: str) -> dict | None: code = code.upper() try: r = requests.get(f"{BASE}/regions/{code}", headers=HEADERS, timeout=(10, 15)) except requests.Timeout as exc: raise RuntimeError(f"SkyLink timeout fetching region {code}") from exc if r.status_code == 404: return None r.raise_for_status() return r.json()def region_options(country: str) -> list[RegionOption]: return [RegionOption(code=item["code"], label=item["name"]) for item in fetch_regions(country=country)]if __name__ == "__main__": import json ny = get_region_by_code("US-NY") print(json.dumps(ny, indent=2, default=str))Hinweise zur Implementierung
Land zuerst (UX). Fragen Sie nach Möglichkeit per country ab — vermeiden Sie es, die vollständige globale Liste an Browser zu senden.
Verknüpfung mit Flughäfen. Verknüpfen Sie airport.iso_region aus Flughäfen direkt mit regions.code.
Codeformat. Erzwingen Sie nach Möglichkeit schon vor der Anfrage das Format XX-YYY, um vermeidbare 404-Fehler zu reduzieren.
Fehlerantworten
Allgemeine Fehler: Fehlerbehandlung. Endpoint-spezifisch:
404 - Region nicht gefunden
{
"detail": "Region 'ZZ-XX' not found"
}Your SkyLink licence key, for keys bought direct from skylinkapi.com.
In: header
Query Parameters
Filter by ISO 3166-1 alpha-2 country code (e.g. US, CA, GB)
Filter by continent code: AF, AN, AS, EU, NA, OC, SA
Response Body
application/json
application/json
curl -X GET "https://data.skylinkapi.com/v3.1/regions"{
"regions": [
{
"id": 0,
"code": "string",
"local_code": "string",
"name": "string",
"continent": "string",
"iso_country": "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-2 region code (e.g. US-CA, GB-ENG, AU-NSW)
Response Body
application/json
application/json
curl -X GET "https://data.skylinkapi.com/v3.1/regions/US"{
"id": 0,
"code": "string",
"local_code": "string",
"name": "string",
"continent": "string",
"iso_country": "string",
"wikipedia_link": "string",
"keywords": "string"
}{
"detail": [
{
"loc": [
"string"
],
"msg": "string",
"type": "string",
"input": null,
"ctx": {}
}
]
}Siehe auch: Länder · Flughäfen · Flughafensuche