Skip to main content

Error Handling

SkyLink API uses standard HTTP status codes and returns structured JSON error responses.

Error Response Format

All errors follow a consistent structure:

{
"error": "Short error title",
"message": "Human-readable description of what went wrong",
"code": "MACHINE_READABLE_ERROR_CODE"
}

HTTP Status Codes

Status CodeMeaningWhen It Occurs
200SuccessRequest completed successfully
400Bad RequestInvalid parameters, missing required fields, or malformed input
401UnauthorizedMissing or invalid API key
404Not FoundResource not found (airport, flight, etc.)
422Validation ErrorRequest parameters fail validation (wrong type, out of range)
429Too Many RequestsRate limit exceeded
500Internal Server ErrorUnexpected server error
502Bad GatewayUpstream data source unavailable
504Gateway TimeoutUpstream data source timed out

Common Error Codes

Authentication Errors

CodeDescription
MISSING_API_KEYNo X-RapidAPI-Key header provided
INVALID_API_KEYAPI key is not valid
INVALID_RAPIDAPI_SECRETRapidAPI proxy secret is not valid

Resource Errors

CodeDescription
AIRPORT_NOT_FOUNDNo airport found for the given ICAO/IATA code
AIRLINE_NOT_FOUNDNo airline found for the given ICAO/IATA code
FLIGHT_NOT_FOUNDNo flight status available for the given flight number
AIRCRAFT_NOT_FOUNDNo aircraft found for the given registration or ICAO24
NO_CHARTS_AVAILABLENo charts found for the given airport

Validation Errors

CodeDescription
INVALID_ICAOICAO code is not valid (must be 3-4 alphanumeric characters)
INVALID_IATAIATA code is not valid (must be 3 alphabetic characters)
INVALID_COORDINATESLatitude or longitude values are out of range
MISSING_PARAMETERA required query parameter is missing

Data Source Errors

CodeDescription
UPSTREAM_ERRORExternal data source returned an error
UPSTREAM_TIMEOUTExternal data source did not respond in time
SERVICE_UNAVAILABLEFeature is temporarily unavailable

Handling Errors

Python Example

import httpx

response = httpx.get(
"YOUR_API_BASE_URL/v3/weather/metar/XXXX",
headers={"X-RapidAPI-Key": "YOUR_API_KEY"},
)

if response.status_code == 200:
data = response.json()
elif response.status_code == 401:
print("Check your API key")
elif response.status_code == 404:
error = response.json()
print(f"Not found: {error['message']}")
else:
print(f"Error {response.status_code}: {response.text}")

JavaScript Example

try {
const response = await fetch(
"YOUR_API_BASE_URL/v3/weather/metar/XXXX",
{ headers: { "X-RapidAPI-Key": "YOUR_API_KEY" } }
);

if (!response.ok) {
const error = await response.json();
console.error(`${error.code}: ${error.message}`);
return;
}

const data = await response.json();
} catch (err) {
console.error("Network error:", err);
}

Retry Strategy

For 429, 500, 502, and 504 errors, implement exponential backoff:

  1. Wait 1 second, retry
  2. Wait 2 seconds, retry
  3. Wait 4 seconds, retry
  4. Give up after 3 retries

For 400, 401, 404, and 422 errors, do not retry — fix the request instead.