Searching for Flights

The next step is to search for the flight prices from London (LON) to all the destinations in the Google Sheet. In this project, we're looking only for direct flights, that leave anytime between tomorrow and in 6 months (6x30days) time. We're also looking for round trips that return between 7 and 28 days in length. The currency of the price we get back should be in GBP.

Objective

Take a look at the Flight Search API to see which parameters you can pass to the API:

https://tequila.kiwi.com/portal/docs/tequila_api/search_api

Aim to print the City and Price for all the cities, e.g:


HINT 1: Try to use the FlightData class to represent the flight data. e.g. You can create attributes for price, departure_airport_code, departure_city etc.


HINT 2: You can use timedelta() from the datatime module to define a 6 month period (6 x 30 days). e.g.

https://stackoverflow.com/questions/4541629/how-to-create-a-datetime-equal-to-15-minutes-ago/4541668


HINT 3: You can use strftime() to format the date to the required format by the Flight Search API.

https://www.w3schools.com/python/python_datetime.asp


HINT 4: You can use the split() function to get the first part of the date from the API response.

https://www.w3schools.com/python/ref_string_split.asp


Debugging Note

You can of course change your starting city, time frame and the destination cities as you see fit. Keep this in mind when you run into problems. For example, due to international travel disruptions, there may actually be no flights to certain destinations in the timeframe that you're searching in. Thus your code may not work even if otherwise, it is perfectly valid. If you're not sure why you're not getting any results back, you can double-check flight availability on websites such as Skyscanner or Kayak.com. As such, you could change the origin city to Denver (DEN), change the currency to dollars (i.e., "curr"="USD"), and change the Google Sheet cities to very large domestic airports like Atlanta, Los Angeles, Chicago and Dallas.


SOLUTION

STEP 4 SOLUTION IN REPL.IT