Guides

Using Flightinfo API

In this guide we are going to explain how to use Flightinfo API and what data can you get from it.
Make sure you have your apikey - instructions on how to get it can be found here.

Here we're going to focus on the getInfo method. Its base URL is:

http://fraas-prod.apigee.net/pub/v1/flightinfo/3/flights?apikey={apikey}

No additional parameters are required to get the data from the endpoint, however there are avaiable few optional filter options:

  • offset (default value = 0)
  • limit (default vaule = 50)
  • departureAirportIataCode 
  • arrivalAirportIataCode
  • departureTimeScheduledFrom (default value = "00:00")
  • departureTimeScheduledTo (default value = "23:59")
  • language (default value "en")

The API returns information about statuses of current day's flights. Each status has following properties:

  • Flight number
  • Departure airport
  • Arrival airport
  • Departure time - scheduled, estimated and actual
  • Arrival time - scheduled, estimated and actual
  • Flight status

Flight status can have following codes:

  • On time
    • ARR - arrived
    • EXP - expected
  • Early
    • ARR_ELY - arrived early
    • EXP_ELY - expected early
  • Delay
    • DLY - delay
    • ARR_DLY - arrived delay
    • EXP_DLY - expected delay
  • Exceptions
    • CNL - cancelled
    • DIV - diverted 

In addition in the response we get few global properties:

  • total - total number of flight statuses for the query
  • lastUpdated - when statuses were updated
  • punctuality - punctuality in % how many flights are punctual for the query
  • size - returned collection's size

So now let's hit the endpoint without any parameters and see what information we get:

{
  "total": 1606,
  "flights": [
    {
      "number": "3556",
      "departureAirport": {
        "iataCode": "STN",
        "name": "London Stansted"
      },
      "arrivalAirport": {
        "iataCode": "RAK",
        "name": "Marrakesh"
      },
      "departureTime": {
        "scheduled": "06:10",
        "estimated": "06:20",
        "actual": "06:20"
      },
      "arrivalTime": {
        "scheduled": "09:50",
        "estimated": "09:32",
        "actual": null
      },
      "status": {
        "code": "EXP_ELY",
        "message": "Estimated Arrival",
        "detailedMessage": null
      },
      "lastUpdated": "2017-01-19T08:58:12Z"
    },
    {
      "number": "6330",
      "departureAirport": {
        "iataCode": "BCN",
        "name": "Barcelona"
      },
      "arrivalAirport": {
        "iataCode": "SOF",
        "name": "Sofia"
      },
      "departureTime": {
        "scheduled": "06:15",
        "estimated": "06:13",
        "actual": "06:13"
      },
      "arrivalTime": {
        "scheduled": "10:05",
        "estimated": "10:05",
        "actual": "10:08"
      },
      "status": {
        "code": "EXP",
        "message": "On Time",
        "detailedMessage": null
      },
      "lastUpdated": "2017-01-19T08:58:12Z"
    },
   ...
  "lastUpdated": "2017-01-19T08:58:12Z",
  "punctuality": 85,
  "size": 50
}

From the response we know that total number of flights in current day is 1606, the data was updated at 8:58, 85% planes are punctual and returned list is size of 50. We cut item's list to 2 because we didn't want the code snippet to be too big. But what if we wanted to display only first two items? We can use two filter options which were prepared to implement pagination:

  • limit - controls the maximum number of items that may be returned in a single request
  • offset - controls the starting point within the collection of resource results

Let's prepare a request with pagination parameters:

curl -X GET "http://fraas-prod.apigee.net/pub/v1/flightinfo/3/flights?apikey={apikey}&limit=2"

Response which we get is limited only to two first items. So now, let's prepare a command for next two - number 3 nad 4. To have that done we need to add an offset parameter.

curl -X GET "http://fraas-prod.apigee.net/pub/v1/flightinfo/3/flights?apikey={apikey}&limit=2&offset=2"

 

Let's consider another use case. On specific airport we want to display the whole list of flights which departure in current daty. To present this example let's make some assumptions:

  • we want to show status for  airport in German city Memmingen - its IATA code is FMM
  • as we want to show the results for German audience we need to set the locale to de
  • let's assume that now it's 12:00 and we don't want to show results earlier than 2 hours before now. We should set parameter departureTimeScheduledFrom to "10:00"

Our request will look like:

curl -X GET 'http://fraas-prod.apigee.net/pub/v1/flightinfo/3/flights/?apikey={apikey}&departureAirportIataCode=FMM&departureTimeScheduledFrom=10:00&language=de'

The results will be as follows: 

{
  "total": 2,
  "flights": [
    {
      "number": "7482",
      "departureAirport": {
        "iataCode": "FMM",
        "name": "Memmingen"
      },
      "arrivalAirport": {
        "iataCode": "FAO",
        "name": "Faro"
      },
      "departureTime": {
        "scheduled": "18:00",
        "estimated": "18:00",
        "actual": "18:00"
      },
      "arrivalTime": {
        "scheduled": "20:05",
        "estimated": "20:05",
        "actual": null
      },
      "status": {
        "code": "EXP",
        "message": "Pünktliche Landung",
        "detailedMessage": null
      },
      "lastUpdated": "2017-01-19T12:18:13Z"
    },
    {
      "number": "4599",
      "departureAirport": {
        "iataCode": "FMM",
        "name": "Memmingen"
      },
      "arrivalAirport": {
        "iataCode": "OPO",
        "name": "Porto"
      },
      "departureTime": {
        "scheduled": "21:05",
        "estimated": "21:05",
        "actual": "21:05"
      },
      "arrivalTime": {
        "scheduled": "23:00",
        "estimated": "23:00",
        "actual": null
      },
      "status": {
        "code": "EXP",
        "message": "Pünktliche Landung",
        "detailedMessage": null
      },
      "lastUpdated": "2017-01-19T12:18:13Z"
    }
  ],
  "lastUpdated": "2017-01-19T12:18:13Z",
  "punctuality": 85,
  "size": 2
}

As you can see from the request there are only two flights scheduled after 10 in Memmingen. Please note German language in messages.

Where to go next?

Check out our cool guide about Reservations API