skyscanner-liveflights-api
v0.1.0
Published
[![CircleCI](https://circleci.com/gh/jameshopkins/skyscanner-liveflights-api.svg?style=svg)](https://circleci.com/gh/jameshopkins/skyscanner-liveflights-api) [![Coverage Status](https://coveralls.io/repos/github/jameshopkins/skyscanner-liveflights-api/bad
Downloads
6
Readme
skyscanner-liveflights-api
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
Ensure that you have an
API_KEY
environment variable set, whose value is your API key.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
- Fork the repo and create your branch from
master
yarn
- Add tests
- Do your shizzle
- Create a PR