npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

google-flights-api

v1.1.5

Published

A simple wrapper for the Google Flights API

Downloads

15

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

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