Git Product home page Git Product logo

koa-qpx's Introduction

Koa-QPX

Google QPX API consumer written in Koa. It queries the API with flight parameters and returns up to 20 results.

Requirements

A modern NodeJS installation is required for the Koa Library.

Installation

npm install

Configuration

the file service_config.json must be modified to use include a valid Google API Server Key. Replace XYZ1234 with your key for url string: "https://www.googleapis.com/qpxExpress/v1/trips/search?key=XYZ1234"

Running

node app.js

gulp server

or

gulp

*Gulp will require global install

Usage

This library takes in GET query parameters, queries the API and returns a JSON object. This application uses JSONPath as a templating engine to define the request and response readers to consume a service.

The server runs on port 3000

Input

  • start_date
  • return_date
  • adult_passengers
  • origin,
  • destination
  • max_stops
  • max_price
  • max_price_currency

Dates are strictly enforced using format YYYY-MM-DD HH:MM:SS. Formatting and data errors will result in an invalid input error.

Output

{
	"results": [
		{
			"total_price" : "string"
			, "departure_time" : "string"
			, "return_arrival_time" : "string"
			, "trips" : [
				{
					"total_duration" : "int"
					, "departure_time" : "string"
					, "arrival_time" : "string"
					, "total_connection_time" : "int"
					, "flights" : [
						{
							"duration" : "int"
							,"carrier" : "string"
							,"number" : "string"
							,"departure_time" : "string"
							,"arrival_time" : "string"
							, "origin_airport" : "string"
							, "destination_airport" : "string"
						}
					]
				}
			]
		}
	]
}

Configuration of New Services

New services can be supported by adding to the file service_config.json

The service config file can be extended to include other services that are somewhat similarly organized like the Google QPX Express API. It's assumed the segments and flights are appropriately nested. Custom tags are used to help format data appropriately, for instance -DATE: allows to format input dates (strictly enforced YYYY-MM-DD HH:MM:SS), and reformats it to be compatible with Google QPX format (YYYY-MM-DD). The response uses JSONPath to map the response, while the request is a JSON object that mimics the request format that maps to the API input format.

A new object in the array, under services, will allow the application to randomly distribute the api query load between defined services.

For radically different API formats, a different JSON reader can be build similar to json-builder.js

koa-qpx's People

Contributors

rngwlf avatar

Watchers

 avatar

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.