File: AmadeusTravelAPI-Flights.ipynb
Name: Corinne Medeiros
Date: 02/29/20
Description: Program pulls flight data from the Amadeus Travel API, stores it in a Pandas dataframe, cleans up headers and columns, and saves the dataframe to a CSV file.

Exploring Flight Options with Amadeus Travel API

Visit https://developers.amadeus.com/get-started/get-started-with-self-service-apis-335 to get your 'API Key' and 'API Secret' credentials before running this code.

Airplane taking off

(photo courtesty of Amadeus Travel API: https://developers.amadeus.com/PAS-EAS/api/v1/cms-gateway//sites/default/files/styles/image_homepage_crop/public/2020-02/Airplane%20takeoff%20at%20Rio%20de%20Janeiro.jpg?h=8dab17aa&itok=nEPMsFAH)

Scenario

I'm interested in visiting Los Angeles this summer on July 9th. I'm pulling data from the Amadeus Travel API (https://developers.amadeus.com/) to see what my flight options are.

Initial Data Pull

Visualizing Data Structure

Since the above data response is very nested and hard to visualize, I pasted the response into a JSON formatter (https://jsonformatter.curiousconcept.com/) to see the structure and grab the specific data I wanted.

Here is an example of one formatted entry to visualize the data structure:

Pulling and Storing Specific Data

Now, with a better understanding of the structure, I can pull specific variables using a key or an index.

Dataframe Clean Up

Our arrival time and departure time columns include a date and a time. It would make more sense to have this info split into two variables in separate columns.

I'll use string methods and Pandas to split them at "T" and then store them in separate columns.

Now that I have them successfully separated, I'll clean up those column names.

The duration column could also use some cleaning. Since none of the flights are longer than a day, I'll strip the data to only include hours and minutes.

With the CSV file successfully created, I feel great!

Female Traveler.

(photo courtesy of Amadeus Travel API: https://developers.amadeus.com/PAS-EAS/api/v1/cms-gateway//sites/default/files/styles/blog_list_image/public/2019-12/Back%20view%20of%20redheaded%20woman%20sitting%20on%20a%20rockt%20looking%20at%20distance_0.jpg?itok=Apc9D7Jb)