Jordan Uses aviationstack

aarmora

Jordan Hansen

Posted on January 15, 2020

Jordan Uses aviationstack

Demo code here

This is a sponsored blog post by positionstack. All reviews and opinions expressed here are, however, based on my personal experience.

This is my fourth post about APIs created by apilayer. The other three were for scrapestack (for proxying any and all web requests), serpstack (for getting search engine results in a quick and easy JSON format), and positionstack (geocode location). I’m still really impressed with their APIs, with full featured documentation on their positionstack product here.

We fly!

gandalf fly you fools gif

Aviationstack starts out with a lot of information. My first query to the base /flights route took a while just to handle all of the responses. There are a lot of flights happening in the world! This is what I started with:

    // See how many total we get
    const axiosResponse = await axios.get(`${baseUrl}/flights?access_key=${process.env.apiKey}`);

    console.log('response', axiosResponse.data.pagination.total);
Enter fullscreen mode Exit fullscreen mode

Getting the total at this point in time turned out to return 413,374 flights. I just ran it again 30 seconds later and now it’s at 413,380. So it’s updating in real time as additional flights are scheduled.

Fear not! As with all of apilayer’s APIs, aviationstack is fully featured with a lot of refinement options, including limit and offset. Check a screenshot of some of the results:

aviationstack results with limit and offset

While it is cool to see all of this cool information, including the gate, scheduled time, deparature, and arrival airport, it’s still a LOT of information. I wanted to try aviationstack in some ways that were useful to me.

Personal uses

christian bale personal gif
This is what returned for personal. And I like Christian Bale.

I live in Boise, Idaho. It’s not a very big place (though it keeps growing!) and the airport doesn’t fly a ton of places. Sometimes when I’m scheduling flights it’s kind of ridiculous what I have to do to go somewhere other than Salt Lake City and Seattle. It can make flying a pain.

So, I decided to see for real what airports Boise is flying to over the next few days. My code looked something like this:

    // Get airports Boise flies to
    const axiosResponse = await axios.get(`${baseUrl}/flights?access_key=${process.env.apiKey}&dep_iata=boi`);

    const airportsBoiseFliesTo: any[] = [];

    for (let flight of axiosResponse.data.data) {
        if (airportsBoiseFliesTo.indexOf(flight.arrival.airport) < 0) {
            airportsBoiseFliesTo.push(flight.arrival.airport);
        }
    }

    console.log('airports boise flies to', airportsBoiseFliesTo);
Enter fullscreen mode Exit fullscreen mode

Aviationstack allows you to pass in a dep_iata query parameter which is a departure airport code. They also provide API endpoints for both airports and cities which would help us get our airport code if we needed it. In order to take advantage of the search query parameter, however, you have to be on at least the basic plan.

Here’s the response of that query:

aviationstack results for airports that boise flies to

Okay, so I’m pretty close on my assessment of Boise’s airport choices. Due to its size, Boise has to fly to a regional hub before flying out to anywhere else. Louisville and the airports in Texas were a bit of a surprise to me. Pretty neat.

Upgraded plan endpoints

Aviationstack offers a lot of additional power at their higher plans. These include things like:

Historical data. You give it a date in the past and it’ll return all the flight information for that date.

Airline routes. This is updated every 24 hours and and offers the full route information. Like this:

aviationstack airline route information

The API is extremely robust. A lot of information and it’s very easy to use. The price is very reasonable, as with all of apilayer’s APIs.

aviationstack pricing

Check it out!

The post Jordan Uses aviationstack appeared first on JavaScript Web Scraping Guy.

💖 💪 🙅 🚩
aarmora
Jordan Hansen

Posted on January 15, 2020

Join Our Newsletter. No Spam, Only the good stuff.

Sign up to receive the latest update from our blog.

Related

Jordan Uses aviationstack
apilayer Jordan Uses aviationstack

January 15, 2020