1.1.5 • Published 7 years ago

google-flights-api v1.1.5

Weekly downloads
1
License
MIT
Repository
github
Last release
7 years ago

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

Typedefs

Api

Kind: global class

new Api(apikey, options)

Instantiates the object for interacting with Google QPX API

ParamTypeDefaultDescription
apikeyStringQPX api key
optionsObject{}Optional parameters
options.backupStringfalseAbsolute path for location to save full query response and request in JSON Backup filename = MM-DD-YYorigindestination__current-date.json
options.simpleBooleantrueIf 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.solutionsNumber500The number of possible routes the API should return.
q.adultCountNumber1The number of adults going on the trip.
q.childCountNumber0The number of children going on the trip.
q.infantInLapCountNumber0The number of passengers that are infants travelling in the lap of an adult.
q.infantInSeatCountNumber0The number of passengers that are infants each assigned a seat.
q.seniorCountNumber0The number of passengers that are senior citizens.
q.maxStopsNumberThe maximum number of stops the passenger(s) are willing to accept in this slice.
q.maxConnectionDurationNumberThe longest connection between two legs, in minutes.
q.earliestTimeString00:00The earliest time of day in HH:MM format for departure.
q.latestTimeString23:59The latest time of day in HH:MM format for departure.
q.refundableStringEitherReturn only solutions with refundable fares.
q.preferredCabinStringAnyAllowed values are COACH, PREMIUM_COACH, BUSINESS, and FIRST.
q.permittedCarrierArrayAnyA list of 2-letter IATA airline designators to filter your results.
q.prohibitedCarrierArrayNoneA list of 2-letter IATA airline designators. Exclude results that match.
q.allianceStringAnySlices 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.saleCountryStringIATA country code representing the point of sale. This determines the "equivalent amount paid" currency for the ticket.
q.ticketingCountryStringIATA country code representing the point of ticketing.
cbqueryCbIf 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
cbqueryCbIf you want to use callbacks instead of promises

queryCb : function

Kind: global typedef

ParamTypeDescription
errorError | undefinedquery error, undefined if success
responseObject | 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

1.1.5

7 years ago

1.1.4

7 years ago

1.1.3

7 years ago

1.1.1

7 years ago

1.1.0

7 years ago

1.0.3

7 years ago

1.0.2

7 years ago

1.0.1

7 years ago

1.0.0

7 years ago