Fantastic Flight API with aviationstack

By (Sponsor)  on  

I didn't fly until I was 25 years of age -- I was hopeless in knowing I had to be there early, the process of security, and the whole gate structure. Now that I've flown dozens of times for Mozilla, I feel much more comfortable with the process of flying, but feel less comfortable about expectations of delays and knowing information about the airlines and flights.

I've often thought about creating my own flight info site, as oftentimes I want to track my own flights and remember paths I've taken in the past. Enter aviationstack, and API which provides detailed current and historical flight information.

Quick Hits

  • Free to sign up and get an API key
  • Provides expansive information about flights, airports, airplanes, airlines, and their locations
  • Reliable, performant, easy to use API
  • Provides JSONP support
  • Brought to you by apilayer, creators of currencylayer, mailboxlayer, userstack, etc.

Using aviationstack

Once you have your free API key, you can start hitting the API to gather information you'd like.

You could start by getting airline information via the API:

# Get all airlines
https://api.aviationstack.com/v1/airlines?access_key=MY_KEY

# Search for a specific airline
https://api.aviationstack.com/v1/airlines
  ?access_key=MY_KEY
  &search=southwest

/*
{
  "pagination": {
    "offset": 0,
    "limit": 100,
    "count": 11,
    "total": 11
  },
  "data": [
    {
      "fleet_average_age": "12.3",
      "callsign": "SOUTHWEST",
      "hub_code": "DAL",
      "iata_code": "WN",
      "icao_code": "SWA",
      "country_iso2": "UM",
      "date_founded": "1967",
      "iata_prefix_accounting": "526",
      "airline_name": "Southwest Airlines Co.",
      "country_name": "United States Minor Outlying Islands",
      "fleet_size": "712",
      "status": "active",
      "type": "scheduled"
    },
    ...
*/

You can use the cities endpoint to retrieve airlines out of your city of choice:

# Get all airlines that operate out of Madison
https://api.aviationstack.com/v1/airlines
  ?access_key=MY_KEY
  &search=MSN

Probably the most useful to users is the flights endpoint which provides real-time flight information:

# Get info about flight 5914 from SFO to MSN on January 5, 2020
https://api.aviationstack.com/v1/flights
  ?access_key=MY_KEY
  &flight_number=5914
  &flight_date=2020-01-05
  &dep_iata=SFO

/*
{
   "pagination":{
      "limit":100,
      "offset":0,
      "count":1,
      "total":1
   },
   "data":[
      {
         "flight_date":"2020-01-05",
         "flight_status":"active",
         "departure":{
            "airport":"San Francisco International",
            "timezone":"America\/Los_Angeles",
            "iata":"SFO",
            "icao":"KSFO",
            "terminal":"3",
            "gate":"F3A",
            "delay":31,
            "scheduled":"2020-01-05T08:42:00+00:00",
            "estimated":"2020-01-05T08:42:00+00:00",
            "actual":"2020-01-05T09:12:00+00:00",
            "estimated_runway":"2020-01-05T09:12:00+00:00",
            "actual_runway":"2020-01-05T09:12:00+00:00"
         },
         "arrival":{
            "airport":"Dane County Regional",
            "timezone":"America\/Chicago",
            "iata":"MSN",
            "icao":"KMSN",
            "terminal":"1",
            "gate":null,
            "baggage":null,
            "delay":null,
            "scheduled":"2020-01-05T14:57:00+00:00",
            "estimated":"2020-01-05T14:57:00+00:00",
            "actual":null,
            "estimated_runway":null,
            "actual_runway":null
         },
         "airline":{
            "name":"United Airlines",
            "iata":"UA",
            "icao":"UAL"
         },
         "flight":{
            "number":"5914",
            "iata":"UA5914",
            "icao":"UAL5914",
            "codeshared":null
         },
         "aircraft":{
            "registration":"N122SY",
            "iata":"E75L",
            "icao":"E75L",
            "icao24":"A05CC7"
         },
         "live":{
            "updated":"2020-01-05T18:20:10+00:00",
            "latitude":39.23,
            "longitude":-113.76,
            "altitude":10668,
            "direction":78.99,
            "speed_horizontal":1028.27,
            "speed_vertical":0,
            "is_ground":false
         }
      }
   ]
}
*/

The amount of detail you get is awesome -- delays, aircraft information, speed, position, and more. Also note that you can provide a date in the past to get historical flight information.

Other endpoints include: countries, cities, airline routes, aircraft types, aircraft taxes (!) and more!

There are so many uses for an API like this. A few ideas which would be fun for me:

  • Keeping track of my team's flight status, so I know when everyone has arrived
  • Creating a graphical, interactive chart of all the flights I've taken and places I've traveled to so I can share it with family and look back at awesome memories
  • Coding up a personal rating system per flight so I can remember which airlines were on time, served good food, and had the best entertainment

aviationstack is an awesome API to jump into. I expected to see a lots of information but there was even more than I had hoped for! I also appreciate how easy it was to use, and how it made me think about the different uses cases that I could enjoy!

Discussion

  1. Ramachandran

    Is it possible to get the historic data of flights more than 1 year old?

    Thank you for the response.

Wrap your code in <pre class="{language}"></pre> tags, link to a GitHub gist, JSFiddle fiddle, or CodePen pen to embed!