If you have applied for our Python vikend course this task serves to asess if you have sufficient knowledge to enjoy and learn something on our course.
Your task is to use our flights API to find a flight and book the flight on the booking API. If it sounds too complicated. Don't worry, it's not.
We at Kiwi.com use simple APIs based on HTTP, usually with payload in JSON format. If you've never used an API click here:
Now you have. Our API for searching flights is public, so you can find the documentation in Apiary http://docs.skypickerpublicapi.apiary.io/#reference/flights
Searching for the flight was pretty easy. To book the flight, you'll need to use the booking API (which has been created solely for the purpose of the task and no payment is required). The world is not perfect and not everything is documented so there is no documentation provided for this API.
The booking API endpoint: http://128.199.48.38:8080/booking
You'll just have to figure out how it works and book the flight. Good luck!
-
The solution must be written in Python 3 (or 2 if you must)
-
The following invocations of your program must work
./book_flight.py --date 2018-04-13 --from BCN --to DUB --one-way
./book_flight.py --date 2018-04-13 --from LHR --to DXB --return 5
./book_flight.py --date 2018-04-13 --from NRT --to SYD --cheapest --bags 2
./book_flight.py --date 2018-04-13 --from CPH --to MIA --fastest
where
--one-way
(make this the default option) indicates need of flight only to location and--return 5
should book flight with passenger staying 5 nights in destination,--cheapest
(default) will book the cheapest flight and--fastest
will work similarlyThe program will output a PNR number which serves as confirmation of booking. In case of failure, program will exit with non-zero exit code.
The
--from
and--to
parameters only need to support airport IATA codes
Please send your coded solutions to pythonvikend@kiwi.com , most preferably posted online on places like GitHub or elsewhere, but attachment files are also OK, I guess, if you don't wish to publish it.
During the submission period we want to keep it fair for everybody, so we will not provide you with feedback on your code (apart from clarifying instructions). Do the best you can, keep it is simple ... but neat, focus on practicality.