GithubHelp home page GithubHelp logo

garee / skyscannerjs Goto Github PK

View Code? Open in Web Editor NEW
12.0 3.0 2.0 18 KB

:airplane: Promise access to Skyscanner travel APIs.

Home Page: https://www.npmjs.com/package/skyscannerjs

License: MIT License

JavaScript 100.00%
skyscanner nodejs javascript api

skyscannerjs's Introduction

SkyscannerJS

Promise based wrapper for the Skyscanner travel APIs.

npm version npm downloads CI status

Install

$ npm install skyscannerjs

Examples

Create an API object

import {API} from "skyscannerjs";
const apiKey = "s3r3t4PIk3y";
const api = new API(apiKey);

Create a flight live pricing session

api.flights.livePrices.session({
    country: "UK",
    currency: "GBP",
    locale: "en-GB",
    locationSchema: "Iata",
    originplace: "EDI",
    destinationplace: "LHR",
    outbounddate: "2016-06-13",
    adults: 1
})
.then((response) => {
    // URL to poll the session.
    const location = response.headers.location;                                     
});

Documentation

Poll a flight living pricing session

api.flights.livePrices.poll(session).then((response) => {
    const itineraries = response.data.Itineraries;
    const legs = response.data.legs;
    ...
});

Documentation

Create a flight booking details session

api.flights.livePrices.bookingDetails.session(session, {
    outboundlegid: "",
    inboundlegid: ""
})
.then((response) => {
    // URL to poll the session.
    const location = response.headers.location;                                     
});

Documentation

Poll a flight booking details session

api.flights.livePrices.bookingDetails.poll(session, itinerary).then((response) => {
    const options = response.data.BookingOptions;    
    const places = response.data.Places;
    ...
});

Documentation

Browse the quotes service

api.flights.browse.quotes({
    market: "UK",
    currency: "GBP",
    locale: "en-GB",
    originPlace: "EDI",
    destinationPlace: "LHR",
    outboundPartialDate: "2016-06-13",
    ip: "98.139.180.149"
})
.then((response) => {
    const quotes = response.data.Quotes;
    ...
});

Documentation

Browse the routes service

api.flights.browse.routes({
    market: "UK",
    currency: "GBP",
    locale: "en-GB",
    originPlace: "EDI",
    destinationPlace: "LHR",
    outboundPartialDate: "2016-06-13",
    ip: "98.139.180.149"
})
.then((response) => {
    const quotes = response.data.Quotes;
    const dates = response.data.Routes;
    ...
});

Documentation

Browse the dates service

api.flights.browse.dates({
    market: "UK",
    currency: "GBP",
    locale: "en-GB",
    originPlace: "EDI",
    destinationPlace: "LHR",
    outboundPartialDate: "2016-06-13",
    ip: "98.139.180.149"
})
.then((response) => {
    const quotes = response.data.Quotes;
    const dates = response.data.Dates;
    ...
});

Documentation

Browse the grid service

api.flights.browse.grid({
    market: "UK",
    currency: "GBP",
    locale: "en-GB",
    originPlace: "EDI",
    destinationPlace: "LHR",
    outboundPartialDate: "2016-06-13",
    ip: "98.139.180.149"
})
.then((response) => {
    const quotes = response.data.Quotes;
    const dates = response.data.Dates;
    ...
});

Documentation

Create a car hire live pricing session

api.carHire.livePrices.session({
    market: "UK",
    currency: "GBP",
    locale: "en-GB",
    pickupplace: "EDI",
    dropoffplace: "GLA",
    pickupdatetime: "2016-06-13T19:00",
    dropoffdatetime: "2016-06-14T19:00",
    driverage: 40,
    ip: "98.139.180.149"
})
.then((response) => {
    // URL to poll the session.
    const location = response.headers.location;
});

Documentation

Poll a car hire live pricing session

api.carHire.livePrices.poll(session).then((response) => {
    const cars = reponse.data.cars;
    ...
});

Documentation

Create a hotels live pricing session

api.hotels.livePrices.session({
    market: "UK",
    currency: "GBP",
    locale: "en-GB",
    entityId: "41.37,2.14-latlong",
    checkindate: "2016-06-13",
    checkoutdate: "2016-06-14",
    guests: 1,
    rooms: 1
})
.then((response) => {
    // URL to poll the session.
    const location = response.headers.location;
});

Documentation

Poll the hotels live pricing session

api.hotels.livePrices.poll(session).then((response) => {
    const hotels = response.data.hotels;
    const status = response.data.status;
    ...
});

Documentation

Create a hotel details session

api.hotels.livePrices.details.session(session, {
    HotelIds: "1,2,3"
})
.then((response) => {
    // URL to poll the session.
    const location = response.headers.location;
});

Documentation

Poll a hotel details session

api.hotels.livePrices.details.poll(session, {
    HotelIds: "1,2,3"
})
.then((response) => {
    ...                 
});

Documentation

Use the hotel autosuggest service

api.hotels.autosuggest({
    market: "UK",
    currency: "GBP",
    locale: "en-GB",
    query: "pari"
})
.then((reponse) => {
    const results = response.data.results;
    const places = response.data.places;
    ...
});

Documentation

Get all supported currencies

api.reference.currencies().then((response) => {
    const currencies = response.data.Currencies;
    ...
});

Documentation

Get all supported locales

api.reference.locales().then((response) => {
    const locales = response.data.Locales;
    ...
});

Documentation

Get all supported countries

For example localecan be equal to en-US, the best way is to get supported locales for this query.

api.reference.countries(locale).then((response) => {
    const countries = response.data.Countries;
    ...
});

Documentation

Use the location autosuggest service

api.locationAutosuggest({
    market: "UK",
    currency: "GBP",
    locale: "en-GB",
    query: "ed"
})
.then((response) => {
    const places = response.data.Places;
    ...
});

Documentation

skyscannerjs's People

Contributors

arnaud-zg avatar dvoiss avatar garee avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

skyscannerjs's Issues

Error case

It could be nice, if we can catch the error event.

  • Server not responding
  • Wrong api key

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.