Google Flights API search
They say that humans are hardwired to be as lazy as possible, and I tend to agree. I’m planning a flight to my hometown and naturally looking for the cheapest deal. Sites like SkyScanner are good for things like this, but our favourite Google ‘Not Evil’ Corporation also has flight search service, which I prefer because of the ‘matrix calendar’ feature they acquired by purchasing famous ‘ita software’ solution.
Opening Google Flights website a few times a week is too much work for me, so I started digging and found a handy QPX Express Airfare search API (obviously delivered by Google) which I decided to use.
This API has a free quota of 50 queries per day and it was not enough for my needs, but out of its great kindness, Google offers a free 60 day trial of their cloud platform with $300 worth of credit. Kindly accepted.
I signed up for a trial and spent a few blissful hours writing a Python script that given a range of dates and a required price, does the search and spits out 3 cheapest results. Handy!
By no means this code is optimal, but it does the job and every morning a get these search results in my inbox.
As always with Python I has to learn something new, this time, it’s the brilliant itertools library that I used to replaced dreaded nested for-loops required to get all possible combination of departure and arrival dates I was after. Basic, but works perfectly well:
itertools.product(listofstartdates, listofenddates)Feel free to use this script for your own needs and have a safe journey!