Explore the technical features and details of our APIs: Documentation

Quickstarts

On this page you can find quickstarts for some of the most popular programming languages.

Java

The Quistart below invokes the Public Flight API and prints all flights out to the console. It requires two additional dependencies. When using Maven as dependency management framework add the following depenencies to the pom.xml file:

In order to run to run this code it needs to be packaged in a self-containing 'Uber' Jar file, in order to do this add the following Maven plugin to the pom.xml file:

This code example requires Java8 to run.

package nl.schiphol.api.publicflightapi.helloworld;

import org.apache.http.HttpResponse;
import org.apache.http.HttpStatus;
import org.apache.http.client.HttpClient;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.impl.client.HttpClients;
import org.apache.http.util.EntityUtils;
import org.json.simple.JSONArray;
import org.json.simple.JSONObject;
import org.json.simple.parser.JSONParser;
import org.json.simple.parser.ParseException;

import java.io.IOException;

public class Main {

  public static void main(String[] args) {

    try {
      String APP_ID = args[0];
      String APP_KEY = args[1];

      HttpClient httpClient = HttpClients.createDefault();
      HttpGet request = new HttpGet("domain/flights");
      request.addHeader("ResourceVersion", "v4");
      request.addHeader("app_id", APP_ID);
      request.addHeader("app_key", APP_KEY);

      HttpResponse response = httpClient.execute(request);

      if (response.getStatusLine().getStatusCode() == HttpStatus.SC_OK) {
        String responseBody = EntityUtils.toString(response.getEntity(), "UTF-8");

        JSONParser parser = new JSONParser();
        JSONObject jsonObject = (JSONObject) parser.parse(responseBody);

        JSONArray flights = (JSONArray) jsonObject.get("flights");
        System.out.println("found " + flights.size() + " flights");
        flights.forEach(System.out::println);

      } else {
        System.out.println(
            "Oops something went wrong\nHttp response code: " + response.getStatusLine().getStatusCode() + "\nHttp response body: "
                + EntityUtils.toString(response.getEntity()));
      }
    } catch (ArrayIndexOutOfBoundsException e) {
      System.out.println("Oops something went wrong\nPlease insert your APP_ID and APP_KEY as arguments");
    } catch (IOException e) {
      e.printStackTrace();
    } catch (ParseException e) {
      e.printStackTrace();
    }
  }
}

PHP

The example below invokes the Public Flight API and shows the result in a small table. To run the example save the file in the correct location (for example, in the httpdoc of you apache server) and go to the corresponding url in your browser.

<html>
   <head>
      <title>Public flight</title>
   </head>
   <body>
      
      <?php
echo '<h1>Public flight API</h1>';
$app_id  = '[app_id]';
$app_key = '[app_key]';

$ch = curl_init();

curl_setopt($ch, CURLOPT_URL, 'https://api.schiphol.nl/public-flights/flights?includedelays=false&page=0&sort=%2BscheduleTime');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'GET');

$headers = array();
$headers[] = 'Accept: application/json';
$headers[] = 'App_id:'. $app_id;
$headers[] = 'App_key:'. $app_key;
$headers[] = 'Resourceversion: v4';
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);

$result = curl_exec($ch);

if (curl_errno($ch)) {
    echo 'Error:' . curl_error($ch);
}
echo $result;
curl_close($ch);
?>
  </body>
</html>

NodeJS

The quickstart below calls the Public Flight API and logs the result. It can be run with nodejs. Save the file and run it with the command "node filename.js"

var http = require("https");

var options = {
  "method": "GET",
  "hostname": "domain",
  "port": null,
  "path": "/flights",
  "headers": {
    "resourceversion": "v4",
	"app_id": "[app_id]",
	"app_key": "[app_key]"
  }
};

var req = http.request(options, function (res) {
  var chunks = [];

  res.on("data", function (chunk) {
    chunks.push(chunk);
  });

  res.on("end", function () {
    var body = Buffer.concat(chunks);
    console.log(body.toString());
  });
});

req.end();

Angular2

The quickstart can be used as a Injectable in your angular2 project. It calls the Public Flight Api and returns it as a Promise<String> object.

import {
  Injectable
} from '@angular/core';
import {
  Http,
  Response,
  Headers,
  RequestOptions,
  URLSearchParams
} from '@angular/http';

import 'rxjs/add/operator/map';
import 'rxjs/add/operator/catch';
import 'rxjs/add/operator/toPromise';

@Injectable()
export class FlightService {

  constructor(private http: Http) {}

  private publicApiUrl = 'domain/flights';

  getFlights(): Promise < String > {

    let headers = new Headers();
    headers.append('ResourceVersion', 'v4')
    headers.append('app_id', '[app_id]')
    headers.append('app_key', '[app_key]')

    let options = new RequestOptions({
      headers: headers,
    });


    return this.http.get(this.publicApiUrl, options)
      .toPromise()
      .then(response => response.json())
      .catch(this.handleError);
  }

  private handleError(error: any): Promise < any > {
    console.error('An error occurred', error); // for demo purposes only
    return Promise.reject(error.message || error);
  }
}

Python3

This script requires the installtion of the "requests" module. You can do this by running the following command: "pip install requests". After this you can run the script with the following command: "python filename.py" -i [app_id] -k [app_key].

#!/usr/bin/python
# -*- coding: utf-8 -*-
import requests
import sys
import optparse

def callPublicFlightAPI(options):
    url = 'domain/flights'

    headers = {
      'accept': 'application/json',
	  'resourceversion': 'v4',
      'app_id': 'options.app_id',
	  'app_key': 'options.app_key'
	}

    try:
        response = requests.request('GET', url, headers=headers)
    except requests.exceptions.ConnectionError as error:
        print(error)
        sys.exit()

    if response.status_code == 200:
        flightList = response.json()
        print('found {} flights.'.format(len(flightList['flights'])))
        for flight in flightList['flights']:
            print('Found flight with name: {} scheduled on: {} at {}'.format(
                flight['flightName'],
                flight['scheduleDate'],
                flight['scheduleTime']))
    else:
        print('''Oops something went wrong
Http response code: {}
{}'''.format(response.status_code,
             response.text))

if __name__ == '__main__':
    parser = optparse.OptionParser()
    parser.add_option('-i', '--app_id', dest='app_id',
                      help='App id used to call the API')
    parser.add_option('-k', '--app_key', dest='app_key',
                      help='App key used to call the API')

    (options, args) = parser.parse_args()
    if options.app_id is None:
        parser.error('Please provide an app id (-i, --app_id)')

    if options.app_key is None:
        parser.error('Please provide an app key (-key, --app_key)')

    callPublicFlightAPI(options)

CMD

The following quickstarts can be run directly from the *nix command line.

curl -X GET -H "ResourceVersion: v4" \
  -H "app_id: [app_id]" -H "app_key: [app_key]" \
  "domain/flights"
  

wget --quiet \
  --method GET \
  --header 'resourceversion: v4' \
  --header 'app_id: [app_id]' \
  --header 'app_key: [app_key]' \
  --output-document \
  - 'domain/flights'

Do you need assistance?

More about using our API's and advantages of using our airport data? We're happy to assist anytime. Please get in touch.