Airports API Examples

  1. Get a airport details with its via ID
  2. Find airports within given radius
  3. Search for airports by name with a partial string

Get the information about a airport via its ID

Example getting information about a airport by querying the ID315961. The ID for the airport can be retrieved by the other endpoints:

// initialisation with your API KEY
$MY_API_KEY_HERE = 'YOUR-API-KEY-HERE';
// base url for the subsequent requests
$base_url = "https://api.searoutes.com/as/airport";
// send the API key in the request
$curl_headers = array(
    'accept: application/json ',
    'x-Api-key: '.$MY_API_KEY_HERE,
);
// initialize curl and pass the Api key in the header
$curl = curl_init();
curl_setopt($curl, CURLOPT_HTTPHEADER, $curl_headers);
// curl has been initialised and ready to be used

// define our search parameter
$requestParameters = array (
    'id' => 315961
);
// create the new url with the specific parameter
$url = $base_url . "?" . http_build_query($requestParameters, '', "&");
curl_setopt($curl, CURLOPT_URL, $url);
$response = curl_exec($curl);
curl_close($curl);
print ($response);
     

// initialisation with your API KEY
final String MY_API_KEY_HERE = "YOUR-API-KEY-HERE";
// base url for the subsequent requests
final String base_url = "https://api.searoutes.com/as/airport";
// provide a search query
final String url = base_url +  "?id=315961";
HttpsURLConnection con = (HttpsURLConnection) new URL(url).openConnection();
// send the API key in the request
con.setRequestProperty("x-api-key", MY_API_KEY_HERE);
con.setRequestProperty("accept", "application/json");
ByteArrayOutputStream baos = new ByteArrayOutputStream();
byte[] buffer = new byte[4096];
InputStream is = con.getInputStream();
for (int nRead = is.read(buffer); nRead != -1; nRead = is.read(buffer)) {
    baos.write(buffer, 0, nRead);
}
is.close();
System.out.println(new String(baos.toByteArray(), "UTF8"));
}
     

# Python 3
import requests

# initialisation with your API KEY
MY_API_KEY_HERE = 'YOUR-API-KEY-HERE'

# base url for the subsequent requests
base_url = "https://api.searoutes.com/as/airport"

# custom headers with our API key
request_headers = {
    'accept': 'application/json',
    'x-api-key': MY_API_KEY_HERE
}

# search term
request_params = {'id': 315961}

# create the new url with the specific parameter
url = base_url
response = requests.get(url, headers=request_headers, params=request_params)
print (response.text)

     

The returned object will be a JSON object that contains the information about the requested airport. For example the request above will return:

{
  "id": 315961,
  "ident": "DE-0299",
  "type": "small_airport",
  "name": "Boberg Airfield",
  "latitude_deg": "53.5147",
  "longitude_deg": "10.1442",
  "elevation_ft": "2",
  "continent": "EU",
  "iso_country": "DE",
  "iso_region": "DE-HH",
  "scheduled_service": "no",
  "home_link": "http://www.hac-boberg.de/",
  "airport_size": "Very Small",
  "osmzoomlevel": "10"
}

Get a list of all the airports within a given circle specifying center and radius

Example getting the first airports nearby the city of Hamburg with 20 Kilometers radius

// initialisation with your API KEY
$MY_API_KEY_HERE = 'YOUR-API-KEY-HERE';
// base url for the subsequent requests
  $base_url = "https://api.searoutes.com/as/airports-in-radius";
// send the API key in the request
$curl_headers = array(
    'accept: application/json ',
    'x-Api-key: '.$MY_API_KEY_HERE,
);
// initialize curl and pass the Api key in the header
$curl = curl_init();
curl_setopt($curl, CURLOPT_HTTPHEADER, $curl_headers);
// curl has been initialised and ready to be used

// define our search parameters
$requestParameters = array(
    'lat' => 53.55,
    'lon' => 9.99,
    'radius' => 20000
);
// create the new url with the specific parameter
$url = $base_url . "?" . http_build_query($requestParameters, '', "&");
curl_setopt($curl, CURLOPT_URL, $url);
$response = curl_exec($curl);
curl_close($curl);
print ($response);
     

// initialisation with your API KEY
final String MY_API_KEY_HERE = "YOUR-API-KEY-HERE";
// base url for the subsequent requests
final String base_url = "https://api.searoutes.com/as/airports-in-radius";
// provide a search query
final String url = base_url +  "?lat=53.55&lon=9.99&radius=20000";
HttpsURLConnection con = (HttpsURLConnection) new URL(url).openConnection();
// send the API key in the request
con.setRequestProperty("x-api-key", MY_API_KEY_HERE);
con.setRequestProperty("accept", "application/json");
ByteArrayOutputStream baos = new ByteArrayOutputStream();
byte[] buffer = new byte[4096];
InputStream is = con.getInputStream();
for (int nRead = is.read(buffer); nRead != -1; nRead = is.read(buffer)) {
    baos.write(buffer, 0, nRead);
}
is.close();
System.out.println(new String(baos.toByteArray(), "UTF8"));
}
     

# Python 3
import requests

# initialisation with your API KEY
MY_API_KEY_HERE = 'YOUR-API-KEY-HERE'

# base url for the subsequent requests
base_url = "https://api.searoutes.com/as/airports-in-radius"

# custom headers with our API key
request_headers = {
    'accept': 'application/json',
    'x-api-key': MY_API_KEY_HERE
}

# search terms
request_params = {
    'lat': 53.55,
    'lon': 9.99,
    'radius': 20000
}

# create the new url with the specific parameter
url = base_url
response = requests.get(url, headers=request_headers, params=request_params)
print (response.text)

     

The returned object will be a JSON array that contains the list with all the airports. For example the request above will return:

[
  {
    "website": "https://www.hamburg-airport.de/en/",
    "icao_code": "EDDH",
    "municipality": "Hamburg",
    "latitude_deg": 53.630401611328,
    "wikipedia": "http://en.wikipedia.org/wiki/Hamburg_Airport",
    "airport_size": "BIG",
    "id": 2214,
    "distance": 8941,
    "name": "Hamburg Airport",
    "longitude_deg": 9.9882297515869,
    "osmzoomlevel": 5,
    "iso_country": "DE",
    "iata_code": "HAM",
    "scheduled_service": "yes",
    "type": "large_airport"
  },
  {
    "website": null,
    "icao_code": "EDHI",
    "municipality": "Hamburg",
    "latitude_deg": 53.5352783203125,
    "wikipedia": "http://en.wikipedia.org/wiki/Hamburg_Finkenwerder_Airport",
    "airport_size": "Small",
    "id": 2234,
    "distance": 10335,
    "name": "Hamburg-Finkenwerder Airport",
    "longitude_deg": 9.835556030273438,
    "osmzoomlevel": 10,
    "iso_country": "DE",
    "iata_code": "XFW",
    "scheduled_service": "no",
    "type": "medium_airport"
  },
  {
    "website": "http://www.hac-boberg.de/",
    "icao_code": "DE-0299",
    "municipality": null,
    "latitude_deg": 53.5147,
    "wikipedia": null,
    "airport_size": "Very Small",
    "id": 315961,
    "distance": 10921,
    "name": "Boberg Airfield",
    "longitude_deg": 10.1442,
    "osmzoomlevel": 10,
    "iso_country": "DE",
    "iata_code": null,
    "scheduled_service": "no",
    "type": "small_airport"
  },
  {
    "website": "http://www.segelflugclub-fischbek.de/",
    "icao_code": "DE-0271",
    "municipality": "Fischbek",
    "latitude_deg": 53.4561,
    "wikipedia": "https://de.wikipedia.org/wiki/Segelfluggel%C3%A4nde_Fischbek",
    "airport_size": "Very Small",
    "id": 315805,
    "distance": 14786,
    "name": "Fischbek Airfield",
    "longitude_deg": 9.8317,
    "osmzoomlevel": 10,
    "iso_country": "DE",
    "iata_code": null,
    "scheduled_service": "no",
    "type": "small_airport"
  }
]

Get a list of airport by partial query on their name

Example getting on how getting the list of airport with the partial search string “hamburg”

// initialisation with your API KEY
$MY_API_KEY_HERE = 'YOUR-API-KEY-HERE';
// base url for the subsequent requests
  $base_url = "https://api.searoutes.com/as/airports-suggest";
// send the API key in the request
$curl_headers = array(
    'accept: application/json ',
    'x-Api-key: '.$MY_API_KEY_HERE,
);
// initialize curl and pass the Api key in the header
$curl = curl_init();
curl_setopt($curl, CURLOPT_HTTPHEADER, $curl_headers);
// curl has been initialised and ready to be used

// define our search parameters
$requestParameters = array(
  'name' => 'hamburg'
);
// create the new url with the specific parameter
$url = $base_url . "?" . http_build_query($requestParameters, '', "&");
curl_setopt($curl, CURLOPT_URL, $url);
$response = curl_exec($curl);
curl_close($curl);
print ($response);
     

// initialisation with your API KEY
final String MY_API_KEY_HERE = "YOUR-API-KEY-HERE";
// base url for the subsequent requests
final String base_url = "https://api.searoutes.com/as/airports-suggest";
// provide a search query
final String url = base_url +  "?name=hamburg";
HttpsURLConnection con = (HttpsURLConnection) new URL(url).openConnection();
// send the API key in the request
con.setRequestProperty("x-api-key", MY_API_KEY_HERE);
con.setRequestProperty("accept", "application/json");
ByteArrayOutputStream baos = new ByteArrayOutputStream();
byte[] buffer = new byte[4096];
InputStream is = con.getInputStream();
for (int nRead = is.read(buffer); nRead != -1; nRead = is.read(buffer)) {
    baos.write(buffer, 0, nRead);
}
is.close();
System.out.println(new String(baos.toByteArray(), "UTF8"));
}
     

# Python 3
import requests

# initialisation with your API KEY
MY_API_KEY_HERE = 'YOUR-API-KEY-HERE'

# base url for the subsequent requests
base_url = "https://api.searoutes.com/as/airports-suggest"

# custom headers with our API key
request_headers = {
    'accept': 'application/json',
    'x-api-key': MY_API_KEY_HERE
}

# search terms
request_params = {
    'name': 'hamburg'
}

# create the new url with the specific parameter
url = base_url
response = requests.get(url, headers=request_headers, params=request_params)
print (response.text)

     

The returned object will be a JSON array that contains the list with the airports. For example the request above will return:

{
  "ports": [
    {
      "id": 965,
      "name": "Hamburg Airport",
      "latitude_deg": "57.3552844682",
      "longitude_deg": "-119.765310287",
      "iso_country": "CA",
      "local_code": "CFM5",
      "osmzoomlevel": "10"
    },
    {
      "id": 2214,
      "name": "Hamburg Airport",
      "latitude_deg": "53.630401611328",
      "longitude_deg": "9.9882297515869",
      "iso_country": "DE",
      "home_link": "https://www.hamburg-airport.de/en/",
      "osmzoomlevel": "5"
    },
    {
      "id": 11422,
      "name": "Hamburg Inc Airport",
      "latitude_deg": "42.70090103149414",
      "longitude_deg": "-78.91480255126953",
      "iso_country": "US",
      "local_code": "4G2",
      "osmzoomlevel": "10"
    },
    {
      "id": 2234,
      "name": "Hamburg-Finkenwerder Airport",
      "latitude_deg": "53.5352783203125",
      "longitude_deg": "9.835556030273438",
      "iso_country": "DE",
      "osmzoomlevel": "10"
    },
    {
      "id": 30195,
      "name": "Novo Hamburgo Airport",
      "latitude_deg": "-29.69610023498535",
      "longitude_deg": "-51.08169937133789",
      "iso_country": "BR",
      "osmzoomlevel": "10"
    },
    {
      "id": 23477,
      "name": "Heussler Hamburg Heliport",
      "latitude_deg": "42.788795471191406",
      "longitude_deg": "-78.84899139404297",
      "iso_country": "US",
      "local_code": "O01",
      "osmzoomlevel": "10"
    },
    {
      "id": 37589,
      "name": "Fazenda Novo Hamburgo Airport",
      "latitude_deg": "-19.233055114746094",
      "longitude_deg": "-57.029720306396484",
      "iso_country": "BR",
      "osmzoomlevel": "10"
    }
  ],
  "size": 7
}

For more information about this API please refer to the Airports API Documentation.