@mankintong/node-skyscanner-live
Node.js module to poll skyscanner live prices
Last updated 3 years ago by mankintong .
ISC · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install @mankintong/node-skyscanner-live 
SYNC missed versions from official npm registry.

node-skyscanner-live

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

Installation

npm insall @mankintong/node-skyscanner-live --save

Usage

Require this library and set the API key. You can get your API key by signing into the Skyscanner Business Portal.

var skyscanner = require('skyscanner');
skyscanner.setApiKey('xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx');

Use getLocation function to retrieve a well-formatted location ID. This ID will be used for fetching flight ticket prices.

skyscanner.getLocation('hong').then(function (data) {
    console.log(data);
});

Results is shown below:

[ { id: 'HKG-sky', name: 'Hong Kong International' },
  { id: 'SHA-sky', name: 'Shanghai Hongqiao' },
  { id: 'HGN-sky', name: 'Mae Hong Son' },
  { id: 'PYY-sky', name: 'Pai (Mae Hong Son)' },
  { id: 'HPG-sky', name: 'Hongping' },
  { id: 'AHJ-sky', name: 'Aba/Hongyuan' },
  { id: 'PVG-sky', name: 'Shanghai Pu Dong' },
  { id: 'HGH-sky', name: 'Hangzhou' },
  { id: 'CKG-sky', name: 'Chongqing' },
  { id: 'HU-sky', name: 'Hungary' } ]

Use search function to poll Skyscanner's API and get a list of air tickets. Since this is on-demand real-time search, the time takes to execute this function varies. In Skyscanner's original API, you have to continuously polling a URL until the result JSON is fully proulated. This 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 this in a simple function.

skyscanner.search('HKG-sky', 'LHR-sky', '2017-03-08', '2017-03-31').then(function (data) {
    console.log(data[0]);
});

Results is shown below:

{ outbound: 
   { departTime: '2017-03-08T11:55:00',
     arriveTime: '2017-03-08T21:05:00',
     stops: 2,
     carriers: [ 'Aeroflot' ] },
  inbound: 
   { departTime: '2017-03-31T10:40:00',
     arriveTime: '2017-04-01T09:45:00',
     stops: 2,
     carriers: [ 'Aeroflot' ] },
  price: 6446,
  url: 'http://partners.api.skyscanner.net/apiservices/deeplink/v2?_cje=xxx' }

More Details

Skyscanner API Documentation

Credits

This is a part of the work done in Hong Kong #1 Bot Hackathon organized by Recime.io. I and my teammates built a chatbot to suggest tourist attractions and find cheapest flight tickets. We have become of the winning teams.

Photo 1, Photo 2

Current Tags

  • 1.0.0                                ...           latest (3 years ago)

1 Versions

  • 1.0.0                                ...           3 years ago
Maintainers (1)
Downloads
Today 0
This Week 0
This Month 0
Last Day 0
Last Week 0
Last Month 0
Dependencies (4)
Dev Dependencies (0)
None
Dependents (0)
None

Copyright 2014 - 2016 © taobao.org |