Guides

Using Timetable API

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

Go to Timetable API page and have a look at list of endpoints:

This API can be useful when you want to build a time table in a form of a calendar. Let's assume you want to generate only months for which flights are scheduled. There are 3 ways you can check how many months should be generated:

1) You want to show a calendar with all possible flights:

Endpoint getScheduleGlobalPeriod should be used. A curl command would look as follows:

curl -X GET "http://fraas-prod.apigee.net/pub/v1/timetable/3/schedules/period?apikey={apikey}"

Where {apikey} is your appliation's apikey.

And the result:

{
  "firstFlightDate": "2017-01-06",
  "lastFlightDate": "2017-10-28",
  "months": 10,
  "monthsFromToday": 10
}

From the response we know that you should build our calendar up to October, 2017.

2) You want to show a calendar with fligths only from specific airport

For an example let's assume that the airport will be Dublin - its IATA code is DUB. We should use endpoint getSchedulePeriodOneWay. Let's build our cURL command:

curl -X GET "http://fraas-prod.apigee.net/pub/v1/timetable/3/schedules/DUB/periods?apikey={apikey}"

Notice parameter value in the URL - DUB - IATA code of Dublin Airport. Now let's see results:

{
  "RIX": {
    "firstFlightDate": "2017-01-06",
    "lastFlightDate": "2017-10-27",
    "months": 10,
    "monthsFromToday": 10
  },
  "SXF": {
    "firstFlightDate": "2017-01-06",
    "lastFlightDate": "2017-10-28",
    "months": 10,
    "monthsFromToday": 10
  },
  "BRS": {
    "firstFlightDate": "2017-01-06",
    "lastFlightDate": "2017-10-28",
    "months": 10,
    "monthsFromToday": 10
  },
...
}

As you can see it gives us a little bit more specific information. It's the list of schedule periods for all airports we can fly from Dublin. We can build the calendar up to October.

3) You want to show a calendar with fligths only for specific route

Again, let's make an assumption that route we are intrested in is Dublin (DUB) - Wrocław (WRO). The endpoint we should use is getSchedulePeriodReturn. The cURL command should be:

curl -X GET "http://fraas-prod.apigee.net/pub/v1/timetable/3/schedules/DUB/WRO/period?apikey={apikey}"

Notice parameters in the request. DUB and WRO are IATA codes for respectively airport in Dublin and Wrocław. Let's have a look at response:

{
  "firstFlightDate": "2017-01-06",
  "lastFlightDate": "2017-10-27",
  "months": 10,
  "monthsFromToday": 10
}

Again, we're building our calendar up to October, 2017.

 

Ok, now when we have our calendar generated with proper number of months we can start filling it with the data. We'll continue with third example - route from Dublin to Wrocław.

Useful and intuitive implementation could be inserting some simple data about the flight in day cells. But first of all we need to know in which day there is a flight. To get this data you should use the getScheduleAvailability endpoint. A cURL command with parameters will look as follows:

curl -X GET "http://fraas-prod.apigee.net/pub/v1/timetable/3/schedules/DUB/WRO/availability?apikey={apikey}"

Let's run this command and see the results. What we get is list of days for which there are scheduled flights:

[
  "2017-01-18",
  "2017-01-19",
  "2017-01-20",
  "2017-01-22",
  "2017-01-23",
  "2017-01-25",
  "2017-01-26",
  "2017-01-27",
  "2017-01-29",
  "2017-01-30",
...
}

With this information in place we can put some data in day cell indicating there is available flight in that particular day. 

Another possible implementation is inserting in the day cells even more data about possible flights. It is possible by using getScheduleMonth edpoint. It returns time table for given month and year and for each flight it includes departure time, arrival time and flight number. For this example let's assume user wants to see flights's details in May, 2017. Let's prepare a cURL command:

curl -X GET "http://fraas-prod.apigee.net/pub/v1/timetable/3/schedules/DUB/WRO/years/2017/months/5?apikey={apikey}"

The parameters after years and months set values respectively for year and month we want to get the data for.
And now let's digest the response:

{
  "month": 5,
  "days": [
    {
      "day": 1,
      "flights": [
        {
          "number": "1926",
          "departureTime": "09:45",
          "arrivalTime": "13:20"
        }
      ]
    },
    {
      "day": 3,
      "flights": [
        {
          "number": "1926",
          "departureTime": "17:50",
          "arrivalTime": "21:25"
        }
      ]
    },
...
}

From the response we see that there are flights form Dublin to Wrocław at:

  • 1st of May, 2017 at 09:45-13:20
  • 3rd of May, 2017 at 17:50-21:25
  • etc.

You can see sample implementation of such calendar here.

Where to go next?

Check our cool guide on how to use Flightinfo API.