Skip to content

jameshopkins/skyscanner-liveflights-api

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

31 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

skyscanner-liveflights-api

CircleCI Coverage Status

A point-free, monadic JS API wrapping the Skyscanner Live Flights API

How To Use

Compose Your Query

You can either refer to the documentation or use the test harness, to obtain valid parameters.

Initiate The API

  1. Ensure that you have an API_KEY environment variable set, whose value is your API key.

  2. Construct the query

import submitQuery from 'skyscanner-liveflights-api';

submitQuery({
  adults: 1,
  cabinclass: 'Economy',
  originplace: 'SFO-iata',
  outbounddate: '2017-03-24',
  inbounddate: '2017-05-30',
  destinationplace: 'BOS-iata'
}).fork(
  console.error,
  console.log
);

Notes

Supported parameters

Currently the only supported parameters are:

  • adults
  • cabinclass
  • originplace
  • outbounddate,
  • inbounddate,
  • destinationplace

Usage Interfaces

If you inspect the source code, you'll notice that all integral functionality is encapsulated in function compositions.

This concept means that, if required, you can build your own custom interface of skyscanner-liveflights-api - itself, a composition of functions.

For example, the main entrypoint, is a composition of two other functions (pollForResults and createSession) that, when used together, make up the standard interface.

You could very easily extend this continutation. E.g

import { compose, lensProp, lensIndex, map, view } from 'ramda';
import submitQuery from 'skyscanner-liveflights-api';

const focusLens = compose(lensProp('Itineraries'), lensProp(0));
const focusOnItineraryItem = map(view(focusLens)))

const getTheFirstItemInTheItinerary = compose(
  focusOnItineraryItem,
  submitQuery
);

getTheFirstItemInTheItinerary({
  adults: 1,
  cabinclass: 'Economy',
  originplace: 'SFO-iata',
  outbounddate: '2017-03-24',
  inbounddate: '2017-05-30',
  destinationplace: 'BOS-iata'
}).fork(
  console.error,
  console.log
);

Debugging

debug is supported, so you can log the individual transactions in the orchestration to stdout, by prepending DEBUG=skyscanner-liveflights-api to the script that starts your consumer application.

Running Tests

make test
# OR
make coverage

Contributing

  1. Fork the repo and create your branch from master
  2. yarn
  3. Add tests
  4. Do your shizzle
  5. Create a PR

About

✈️️ A point-free, monadic JS API wrapping the Skyscanner Live Flights API

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published