npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

node-skyscanner-live

v4.0.2

Published

Node.js module to poll skyscanner live prices

Downloads

4

Readme

node-skyscanner-live

This Node.js module provides a simplified call to poll Skyscanner Live Prices.

Installation

npm insall node-skyscanner-live --save

Usage

Set the API key. You can get your API key by signing into the Skyscanner Business Portal.

var skyscanner = require('node-skyscanner-live');
skyscanner.setApiKey('xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx');

Use getLocation function to find location IDs by keywords. The Skyscanner API can handle typos too. These IDs are needed when fetching flight ticket prices.

skyscanner.getLocation('herthrow').then(function (data) {
    console.log(data);
});
[ { id: 'LHR-sky', name: 'London Heathrow' } ]

Use search function to poll Skyscanner's API and get a list of air tickets. You have to use location IDs and “yyyy-mm-dd”, “yyyy-mm” or “anytime” for the dates.

Since this is real-time search, the time takes to execute this function may vary. In Skyscanner's original API, you have to continuously poll a URL until the result JSON is fully propulated. It has caused complexities in handling Promise of waits, retries, together with logic to determine if API limit has been breached. This module has encapsulated all those in a simple function.

skyscanner.search('HKG-sky', 'LHR-sky', '2017-06-20', '2017-06-30').then(function (data) {
    console.log(util.inspect(data[0], false, 99999));
});
{ segments: 
   [ { departAirport: { code: 'HKG', name: 'Hong Kong International' },
       arriveAirport: { code: 'PEK', name: 'Beijing Capital' },
       departCity: { code: 'HKG', name: 'Hong Kong' },
       arriveCity: { code: 'BJS', name: 'Beijing' },
       departTime: '2017-06-20T10:30:00',
       arriveTime: '2017-06-20T13:55:00',
       carrier: [ 'Air China' ] },
     { departAirport: { code: 'PEK', name: 'Beijing Capital' },
       arriveAirport: { code: 'LHR', name: 'London Heathrow' },
       departCity: { code: 'BJS', name: 'Beijing' },
       arriveCity: { code: 'LON', name: 'London' },
       departTime: '2017-06-20T17:05:00',
       arriveTime: '2017-06-20T20:40:00',
       carrier: [ 'Air China' ] },
     { departAirport: { code: 'LHR', name: 'London Heathrow' },
       arriveAirport: { code: 'PEK', name: 'Beijing Capital' },
       departCity: { code: 'LON', name: 'London' },
       arriveCity: { code: 'BJS', name: 'Beijing' },
       departTime: '2017-06-30T22:40:00',
       arriveTime: '2017-07-01T15:50:00',
       carrier: [ 'Air China' ] },
     { departAirport: { code: 'PEK', name: 'Beijing Capital' },
       arriveAirport: { code: 'HKG', name: 'Hong Kong International' },
       departCity: { code: 'BJS', name: 'Beijing' },
       arriveCity: { code: 'HKG', name: 'Hong Kong' },
       departTime: '2017-07-02T08:05:00',
       arriveTime: '2017-07-02T11:35:00',
       carrier: [ 'Air China' ] } ],
  price: 4301.11,
  url: 'http://partners.api.skyscanner.net/apiservices/deeplink/v2?_cje=x' }

Improvements Needed

Right now this API is mainly targeting users in Hong Kong. There are works needed to be done to make this more global and generic. Pull requests are welcome.

More Details

Skyscanner API Documentation

Credits

This is a part of the work done in Hong Kong First Bot Hackathon organized by Recime.io. I and my teammates built a chatbot that suggests tourist attractions and finds cheapest flight tickets. We became the 1st runner-up in the event.

Photo 1, Photo 2, Photos by Recime