google-flights-api
v1.1.5
Published
A simple wrapper for the Google Flights API
Downloads
15
Maintainers
Readme
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
- Api
- new Api(apikey, [options])
- .query ⇒ Promise | undefined
- .rawQuery ⇒ Promise | undefined
new Api(apikey, [options])
Instantiates the object for interacting with Google QPX API
| Param | Type | Default | Description | | --- | --- | --- | --- | | apikey | String | | QPX api key | | [options] | Object | {} | Optional parameters | | [options.backup] | String | false | Absolute path for location to save full query response and request in JSON Backup filename = MM-DD-YY__origin__destination__current-date.json | | [options.simple] | Boolean | true | If 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
- https://developers.google.com/qpx-express/v1/trips/search#request
- https://developers.google.com/qpx-express/v1/trips/search#response
| Param | Type | Default | Description | | --- | --- | --- | --- | | q | Object | | Query object | | q.maxPrice | String | | The max price for the trip. Note - Must be prefixed with currency i.e. EUR. | | q.origin | String | | The origin airport code. | | q.destination | String | | The destination airport code. | | q.date | String | Number | | The 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] | Number | 500 | The number of possible routes the API should return. | | [q.adultCount] | Number | 1 | The number of adults going on the trip. | | [q.childCount] | Number | 0 | The number of children going on the trip. | | [q.infantInLapCount] | Number | 0 | The number of passengers that are infants travelling in the lap of an adult. | | [q.infantInSeatCount] | Number | 0 | The number of passengers that are infants each assigned a seat. | | [q.seniorCount] | Number | 0 | The number of passengers that are senior citizens. | | [q.maxStops] | Number | ∞ | The maximum number of stops the passenger(s) are willing to accept in this slice. | | [q.maxConnectionDuration] | Number | ∞ | The longest connection between two legs, in minutes. | | [q.earliestTime] | String | 00:00 | The earliest time of day in HH:MM format for departure. | | [q.latestTime] | String | 23:59 | The latest time of day in HH:MM format for departure. | | [q.refundable] | String | Either | Return only solutions with refundable fares. | | [q.preferredCabin] | String | Any | Allowed values are COACH, PREMIUM_COACH, BUSINESS, and FIRST. | | [q.permittedCarrier] | Array | Any | A list of 2-letter IATA airline designators to filter your results. | | [q.prohibitedCarrier] | Array | None | A list of 2-letter IATA airline designators. Exclude results that match. | | [q.alliance] | String | Any | Slices 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] | String | | IATA country code representing the point of sale. This determines the "equivalent amount paid" currency for the ticket. | | [q.ticketingCountry] | String | | IATA country code representing the point of ticketing. | | [cb] | queryCb | | If 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
- https://developers.google.com/qpx-express/v1/trips/search#request
- https://developers.google.com/qpx-express/v1/trips/search#response
| Param | Type | Description | | --- | --- | --- | | q | Object | Query object | | [cb] | queryCb | If you want to use callbacks instead of promises |
queryCb : function
Kind: global typedef
| Param | Type | Description | | --- | --- | --- | | error | Error | undefined | query error, undefined if success | | [response] | Object | undefined | query 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