Socket
Socket
Sign inDemoInstall

google-flights-api

Package Overview
Dependencies
58
Maintainers
1
Versions
9
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    google-flights-api

A simple wrapper for the Google Flights API


Version published
Weekly downloads
6
increased by20%
Maintainers
1
Created
Weekly downloads
 

Readme

Source

Google Flights Api

Installation

npm install --save google-flights-api

Usage

const API_KEY = '1234';
const options =  { write: __dirname + '/data'};
const qpx = require('google-flights-api')(API_KEY, options);

const q = {
   adultCount: 1, 
   maxPrice: 'EUR5000', 
   solutions: 1, 
   origin: 'DUB',
   destination: 'GDN', 
   date: '2016-12-14'
};
qpx.query(q).then((data) => {
  //data looks like: [ { airline: 'SK', price: 'EUR71.10' } ]
}).catch(console.error);

Documentation

Classes

Api

Typedefs

queryCb : function

Api

Kind: global class

new Api(apikey, [options])

Instantiates the object for interacting with Google QPX API

ParamTypeDefaultDescription
apikeyStringQPX api key
[options]Object{}Optional parameters
[options.backup]StringfalseAbsolute path for location to save full query response and request in JSON Backup filename = MM-DD-YY__origin__destination__current-date.json
[options.simple]BooleantrueIf true, throws on invalid status codes request in JSON

api.query ⇒ Promise | undefined

Perform a Google QPX query

Kind: instance property of Api
Returns: Promise | undefined - - Resolves to response object or undefined if using callback
See

ParamTypeDefaultDescription
qObjectQuery object
q.maxPriceStringThe max price for the trip. Note - Must be prefixed with currency i.e. EUR.
q.originStringThe origin airport code.
q.destinationStringThe destination airport code.
q.dateString | NumberThe date of the flight... moment will attempt to parse the date to YYYY-MM-DD e.g. '2016-12-14' or ms timestamp will work
[q.solutions]Number500The number of possible routes the API should return.
[q.adultCount]Number1The number of adults going on the trip.
[q.childCount]Number0The number of children going on the trip.
[q.infantInLapCount]Number0The number of passengers that are infants travelling in the lap of an adult.
[q.infantInSeatCount]Number0The number of passengers that are infants each assigned a seat.
[q.seniorCount]Number0The number of passengers that are senior citizens.
[q.maxStops]NumberThe maximum number of stops the passenger(s) are willing to accept in this slice.
[q.maxConnectionDuration]NumberThe longest connection between two legs, in minutes.
[q.earliestTime]String00:00The earliest time of day in HH:MM format for departure.
[q.latestTime]String23:59The latest time of day in HH:MM format for departure.
[q.refundable]StringEitherReturn only solutions with refundable fares.
[q.preferredCabin]StringAnyAllowed values are COACH, PREMIUM_COACH, BUSINESS, and FIRST.
[q.permittedCarrier]ArrayAnyA list of 2-letter IATA airline designators to filter your results.
[q.prohibitedCarrier]ArrayNoneA list of 2-letter IATA airline designators. Exclude results that match.
[q.alliance]StringAnySlices with only the carriers in this alliance should be returned; do not use this field with permittedCarrier. Allowed values are ONEWORLD, SKYTEAM, and STAR.
[q.saleCountry]StringIATA country code representing the point of sale. This determines the "equivalent amount paid" currency for the ticket.
[q.ticketingCountry]StringIATA country code representing the point of ticketing.
[cb]queryCbIf you want to use callbacks instead of promises

api.rawQuery ⇒ Promise | undefined

Perform a Google QPX query, no processing will be done on the query or response so it must follow the api format

Kind: instance property of Api
Returns: Promise | undefined - - Resolves to response object or undefined if using callback
See

ParamTypeDescription
qObjectQuery object
[cb]queryCbIf you want to use callbacks instead of promises

queryCb : function

Kind: global typedef

ParamTypeDescription
errorError | undefinedquery error, undefined if success
[response]Object | undefinedquery response object, undefined if error

Contributing

Updating docs

Docs are generated from JSDocs via npm run docs

Credits

Forked from adhorrig's, google-flight-wrapper

Keywords

FAQs

Last updated on 10 Sep 2017

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc