Overview
Airport Distance works by analyzing the data provided and returning the distance between the two airports. It uses various sources to determine the data and returns the distance.
Endpoint
One host, one path per API. The block below shows this call in four languages; every one of them is the same HTTP request. Making requests covers the timeouts, retries and parameter rules that apply to all of them. The SDKs wrap the same call in a typed client.
curl "https://api.apiverve.com/v1/airportdistance?iata1=JFK&iata2=LAX" \
-H "x-api-key: your_api_key_here"const res = await fetch('https://api.apiverve.com/v1/airportdistance?iata1=JFK&iata2=LAX', {
headers: { 'x-api-key': 'your_api_key_here' },
});
if (!res.ok) throw new Error(`${res.status} ${await res.text()}`);
const { data } = await res.json();
console.log(data);import requests
res = requests.get(
"https://api.apiverve.com/v1/airportdistance?iata1=JFK&iata2=LAX",
headers={"x-api-key": "your_api_key_here"},
timeout=15,
)
res.raise_for_status()
print(res.json()["data"])package main
import (
"fmt"
"io"
"net/http"
)
func main() {
req, _ := http.NewRequest("GET", "https://api.apiverve.com/v1/airportdistance?iata1=JFK&iata2=LAX", nil)
req.Header.Set("x-api-key", "your_api_key_here")
res, err := http.DefaultClient.Do(req)
if err != nil {
panic(err)
}
defer res.Body.Close()
out, _ := io.ReadAll(res.Body)
fmt.Println(string(out))
}Replace your_api_key_here with the key from your dashboard. When the inputs arrive as a list rather than one at a time, batch requests run up to 200 of them through this same API in a single call.
Authentication
Send your key in the x-api-key header. That is the only auth step — there is no token exchange and no per-endpoint scope to configure. Authentication covers creating, rotating and revoking keys.
A 401 means the key is missing, invalid or expired. A 403 means the key is valid but not permitted here — blocked by a key restriction or an IP allow-list. Running out of credits is a 429.
Parameters
Sent in the query string. Premium parameters are accepted on every plan but only take effect on plans that include them.
| Parameter | Type | Description |
|---|---|---|
iata1Required | string | The IATA code of the first airport (e.g. JFK) |
iata2Required | string | The IATA code of the second airport (e.g. LAX) |
Response
Every API returns the same three top-level keys, so one response handler covers your whole integration: status, error and data. Only data changes shape. Response format covers the envelope, the other output formats and how premium fields are withheld.
{
"status": "ok",
"error": null,
"data": {
"distanceMiles": 2470.23,
"distanceKm": 3974.2,
"distanceNauticalMiles": 2145.12,
"estimatedFlightTime": "5h 24m",
"timezoneDiffHours": -3,
"bearing": 265,
"direction": "West",
"isInternational": false,
"carbonEstimateKg": 543,
"airport1": {
"name": "John F Kennedy International Airport",
"iata": "JFK",
"icao": "KJFK",
"city": "New York",
"state": "New-York",
"country": "US",
"elevation": 13,
"latitude": 40.63980103,
"longitude": -73.77890015,
"timezone": "America/New_York"
},
"airport2": {
"name": "Los Angeles International Airport",
"iata": "LAX",
"icao": "KLAX",
"city": "Los Angeles",
"state": "California",
"country": "US",
"elevation": 125,
"latitude": 33.94250107,
"longitude": -118.4079971,
"timezone": "America/Los_Angeles"
}
}
}Response fields
Paths are relative to data. Premium fields are absent rather than zeroed on plans that do not include them, so check for presence instead of comparing to 0.
| Field | Type | Example | Description |
|---|---|---|---|
distanceMiles | number | 2470.23 | Distance in statute miles |
distanceKm | number | 3974.2 | Great-circle distance between the two airports in kilometres |
distanceNauticalMilesPremium | number | 2145.12 | Distance in nautical miles (aviation standard) |
estimatedFlightTime | string | "5h 24m" | Estimated flight duration (e.g., 5h 24m) |
timezoneDiffHoursPremium | number | -3 | Timezone difference in hours between airports |
bearingPremium | number | 265 | Compass bearing from airport1 to airport2 (0-360 degrees) |
directionPremium | string | "West" | Compass direction (e.g., North, Southwest, East) |
isInternationalPremium | boolean | false | Whether the flight crosses international borders |
carbonEstimateKgPremium | number | 543 | Estimated CO2 emissions in kg per passenger (based on ICAO methodology) |
airport1Premium | object | {...} | Details about the first airport |
namePremium | string | "John F Kennedy International Airport" | Full name of the origin airport |
iataPremium | string | "JFK" | Three-letter IATA code of the origin airport |
icaoPremium | string | "KJFK" | Four-letter ICAO code of the origin airport |
cityPremium | string | "New York" | City the origin airport serves |
statePremium | string | "New-York" | State or region of the origin airport |
countryPremium | string | "US" | Country code of the origin airport |
elevationPremium | number | 13 | Airport elevation in feet |
latitudePremium | number | 40.63980103 | Airport latitude |
longitudePremium | number | -73.77890015 | Airport longitude |
timezonePremium | string | "America/New_York" | Airport timezone (e.g., America/New_York) |
airport2Premium | object | {...} | Details about the second airport |
namePremium | string | "Los Angeles International Airport" | Full name of the destination airport |
iataPremium | string | "LAX" | Three-letter IATA code of the destination airport |
icaoPremium | string | "KLAX" | Four-letter ICAO code of the destination airport |
cityPremium | string | "Los Angeles" | City the destination airport serves |
statePremium | string | "California" | State or region of the destination airport |
countryPremium | string | "US" | Country code of the destination airport |
elevationPremium | number | 125 | Airport elevation in feet |
latitudePremium | number | 33.94250107 | Airport latitude |
longitudePremium | number | -118.4079971 | Airport longitude |
timezonePremium | string | "America/Los_Angeles" | Airport timezone (e.g., America/Los_Angeles) |
Errors
Read the HTTP status first, then error for the specific reason. The body names the parameter that has to change. Error handling covers the full status list and which of them are worth retrying.
| Status | Meaning | What to do |
|---|---|---|
400 | Input was rejected | Read error; it names the parameter. |
401 | Key missing or invalid | Check the header name and the key value. |
403 | Key valid, but not permitted | A key restriction or IP allow-list; see key scoping. |
429 | Rate limited, or out of credits | Read error to tell them apart; see rate limits. |
Other ways to use Airport Distance
Set up Airport Distance on APIVerve, or reach the same source a different way. Your APIVerve account and credits work on all of them — one key, one balance.
Related
More in Transportation: