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.
import pandas as pd
import requests
import json
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.
from amadeus import Client, ResponseError
# Initializing Amadeus library using your credentials
amadeus = Client(
client_id='API KEY',
client_secret='API SECRET'
)

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.
try:
'''
What are the flight options for flying to Los Angeles from San Francisco on July 9th, 2020?
'''
response = amadeus.shopping.flight_offers.get(origin='SFO', destination='LAX', departureDate='2020-07-09')
print(response.data)
except ResponseError as error:
print(error)
[{'type': 'flight-offer', 'id': '1583015327667-1547356594', 'offerItems': [{'services': [{'segments': [{'flightSegment': {'departure': {'iataCode': 'SFO', 'terminal': '2', 'at': '2020-07-09T10:40:00-07:00'}, 'arrival': {'iataCode': 'LAX', 'terminal': '6', 'at': '2020-07-09T12:18:00-07:00'}, 'carrierCode': 'AS', 'number': '3432', 'aircraft': {'code': 'E75'}, 'operating': {'number': '3432'}, 'duration': '0DT1H38M'}, 'pricingDetailPerAdult': {'travelClass': 'ECONOMY', 'fareClass': 'X', 'availability': 7, 'fareBasis': 'TH2OAVBN'}}]}], 'price': {'total': '63.85', 'totalTaxes': '16.85'}, 'pricePerAdult': {'total': '63.85', 'totalTaxes': '16.85'}}]}, {'type': 'flight-offer', 'id': '1583015327667--702364065', 'offerItems': [{'services': [{'segments': [{'flightSegment': {'departure': {'iataCode': 'SFO', 'terminal': '2', 'at': '2020-07-09T16:00:00-07:00'}, 'arrival': {'iataCode': 'LAS', 'terminal': '3', 'at': '2020-07-09T17:37:00-07:00'}, 'carrierCode': 'AS', 'number': '3386', 'aircraft': {'code': 'E75'}, 'operating': {'number': '3386'}, 'duration': '0DT1H37M'}, 'pricingDetailPerAdult': {'travelClass': 'ECONOMY', 'fareClass': 'V', 'availability': 7, 'fareBasis': 'VH2OASMN'}}, {'flightSegment': {'departure': {'iataCode': 'LAS', 'terminal': '3', 'at': '2020-07-09T19:55:00-07:00'}, 'arrival': {'iataCode': 'LAX', 'terminal': '6', 'at': '2020-07-09T21:11:00-07:00'}, 'carrierCode': 'AS', 'number': '3363', 'aircraft': {'code': 'E75'}, 'operating': {'number': '3363'}, 'duration': '0DT1H16M'}, 'pricingDetailPerAdult': {'travelClass': 'ECONOMY', 'fareClass': 'T', 'availability': 7, 'fareBasis': 'TH3TAVMN'}}]}], 'price': {'total': '198.85', 'totalTaxes': '33.85'}, 'pricePerAdult': {'total': '198.85', 'totalTaxes': '33.85'}}]}, {'type': 'flight-offer', 'id': '1583015327667-136522242', 'offerItems': [{'services': [{'segments': [{'flightSegment': {'departure': {'iataCode': 'SFO', 'terminal': '3', 'at': '2020-07-09T08:35:00-07:00'}, 'arrival': {'iataCode': 'SMF', 'terminal': 'A', 'at': '2020-07-09T09:29:00-07:00'}, 'carrierCode': 'UA', 'number': '5445', 'aircraft': {'code': 'CRJ'}, 'operating': {'number': '5445'}, 'duration': '0DT0H54M'}, 'pricingDetailPerAdult': {'travelClass': 'ECONOMY', 'fareClass': 'S', 'availability': 9, 'fareBasis': 'SAA4AFDN'}}, {'flightSegment': {'departure': {'iataCode': 'SMF', 'terminal': 'A', 'at': '2020-07-09T10:13:00-07:00'}, 'arrival': {'iataCode': 'LAX', 'terminal': '7', 'at': '2020-07-09T11:50:00-07:00'}, 'carrierCode': 'UA', 'number': '5513', 'aircraft': {'code': 'CRJ'}, 'operating': {'number': '5513'}, 'duration': '0DT1H37M'}, 'pricingDetailPerAdult': {'travelClass': 'ECONOMY', 'fareClass': 'W', 'availability': 9, 'fareBasis': 'WAA3AKEN'}}]}], 'price': {'total': '342.93', 'totalTaxes': '43.93'}, 'pricePerAdult': {'total': '342.93', 'totalTaxes': '43.93'}}]}, {'type': 'flight-offer', 'id': '1583015327667-795525582', 'offerItems': [{'services': [{'segments': [{'flightSegment': {'departure': {'iataCode': 'SFO', 'terminal': '2', 'at': '2020-07-09T14:00:00-07:00'}, 'arrival': {'iataCode': 'LAX', 'terminal': '6', 'at': '2020-07-09T15:36:00-07:00'}, 'carrierCode': 'AS', 'number': '2428', 'aircraft': {'code': 'E75'}, 'operating': {'number': '2428'}, 'duration': '0DT1H36M'}, 'pricingDetailPerAdult': {'travelClass': 'ECONOMY', 'fareClass': 'X', 'availability': 7, 'fareBasis': 'TH2OAVBN'}}]}], 'price': {'total': '63.85', 'totalTaxes': '16.85'}, 'pricePerAdult': {'total': '63.85', 'totalTaxes': '16.85'}}]}, {'type': 'flight-offer', 'id': '1583015327667-1686947287', 'offerItems': [{'services': [{'segments': [{'flightSegment': {'departure': {'iataCode': 'SFO', 'terminal': '1', 'at': '2020-07-09T20:09:00-07:00'}, 'arrival': {'iataCode': 'LAX', 'terminal': '2', 'at': '2020-07-09T21:45:00-07:00'}, 'carrierCode': 'DL', 'number': '1898', 'aircraft': {'code': '319'}, 'operating': {'carrierCode': 'DL', 'number': '1898'}, 'duration': '0DT1H36M'}, 'pricingDetailPerAdult': {'travelClass': 'ECONOMY', 'fareClass': 'E', 'availability': 9, 'fareBasis': 'TAUVA0BQ'}}]}], 'price': {'total': '77.81', 'totalTaxes': '17.81'}, 'pricePerAdult': {'total': '77.81', 'totalTaxes': '17.81'}}]}, {'type': 'flight-offer', 'id': '1583015327667-844438014', 'offerItems': [{'services': [{'segments': [{'flightSegment': {'departure': {'iataCode': 'SFO', 'terminal': 'I', 'at': '2020-07-09T00:49:00-07:00'}, 'arrival': {'iataCode': 'DEN', 'at': '2020-07-09T04:22:00-06:00'}, 'carrierCode': 'F9', 'number': '662', 'aircraft': {'code': '320'}, 'operating': {'carrierCode': 'F9', 'number': '662'}, 'duration': '0DT2H33M'}, 'pricingDetailPerAdult': {'travelClass': 'ECONOMY', 'fareClass': 'B', 'availability': 4, 'fareBasis': 'B00PXP5'}}, {'flightSegment': {'departure': {'iataCode': 'DEN', 'at': '2020-07-09T06:00:00-06:00'}, 'arrival': {'iataCode': 'LAX', 'terminal': '5', 'at': '2020-07-09T07:36:00-07:00'}, 'carrierCode': 'F9', 'number': '403', 'aircraft': {'code': '320'}, 'operating': {'carrierCode': 'F9', 'number': '403'}, 'duration': '0DT2H36M'}, 'pricingDetailPerAdult': {'travelClass': 'ECONOMY', 'fareClass': 'B', 'availability': 4, 'fareBasis': 'B00PXP5'}}]}], 'price': {'total': '174.11', 'totalTaxes': '32.11'}, 'pricePerAdult': {'total': '174.11', 'totalTaxes': '32.11'}}]}, {'type': 'flight-offer', 'id': '1583015327667-2041443946', 'offerItems': [{'services': [{'segments': [{'flightSegment': {'departure': {'iataCode': 'SFO', 'terminal': '3', 'at': '2020-07-09T09:51:00-07:00'}, 'arrival': {'iataCode': 'ONT', 'terminal': '2', 'at': '2020-07-09T11:18:00-07:00'}, 'carrierCode': 'UA', 'number': '5371', 'aircraft': {'code': 'CRJ'}, 'operating': {'number': '5371'}, 'duration': '0DT1H27M'}, 'pricingDetailPerAdult': {'travelClass': 'ECONOMY', 'fareClass': 'G', 'availability': 1, 'fareBasis': 'GAA2AKDN'}}]}], 'price': {'total': '100.42', 'totalTaxes': '19.42'}, 'pricePerAdult': {'total': '100.42', 'totalTaxes': '19.42'}}]}, {'type': 'flight-offer', 'id': '1583015327667-325495069', 'offerItems': [{'services': [{'segments': [{'flightSegment': {'departure': {'iataCode': 'SFO', 'terminal': '3', 'at': '2020-07-09T14:11:00-07:00'}, 'arrival': {'iataCode': 'ONT', 'terminal': '2', 'at': '2020-07-09T15:38:00-07:00'}, 'carrierCode': 'UA', 'number': '5422', 'aircraft': {'code': 'CRJ'}, 'operating': {'number': '5422'}, 'duration': '0DT1H27M'}, 'pricingDetailPerAdult': {'travelClass': 'ECONOMY', 'fareClass': 'L', 'availability': 6, 'fareBasis': 'LAA1AKDN'}}]}], 'price': {'total': '146.60', 'totalTaxes': '22.60'}, 'pricePerAdult': {'total': '146.60', 'totalTaxes': '22.60'}}]}, {'type': 'flight-offer', 'id': '1583015327667-1186805071', 'offerItems': [{'services': [{'segments': [{'flightSegment': {'departure': {'iataCode': 'SFO', 'terminal': '3', 'at': '2020-07-09T11:00:00-07:00'}, 'arrival': {'iataCode': 'LAX', 'terminal': '7', 'at': '2020-07-09T12:43:00-07:00'}, 'carrierCode': 'UA', 'number': '256', 'aircraft': {'code': '738'}, 'operating': {'carrierCode': 'UA', 'number': '256'}, 'duration': '0DT1H43M'}, 'pricingDetailPerAdult': {'travelClass': 'ECONOMY', 'fareClass': 'G', 'availability': 6, 'fareBasis': 'GAA2AQDN'}}]}], 'price': {'total': '96.10', 'totalTaxes': '19.10'}, 'pricePerAdult': {'total': '96.10', 'totalTaxes': '19.10'}}]}, {'type': 'flight-offer', 'id': '1583015327667-1871803817', 'offerItems': [{'services': [{'segments': [{'flightSegment': {'departure': {'iataCode': 'SFO', 'terminal': '3', 'at': '2020-07-09T06:30:00-07:00'}, 'arrival': {'iataCode': 'LAX', 'terminal': '7', 'at': '2020-07-09T08:21:00-07:00'}, 'carrierCode': 'UA', 'number': '504', 'aircraft': {'code': '739'}, 'operating': {'carrierCode': 'UA', 'number': '504'}, 'duration': '0DT1H51M'}, 'pricingDetailPerAdult': {'travelClass': 'ECONOMY', 'fareClass': 'K', 'availability': 9, 'fareBasis': 'KAA4AQDN'}}]}], 'price': {'total': '119.72', 'totalTaxes': '20.72'}, 'pricePerAdult': {'total': '119.72', 'totalTaxes': '20.72'}}]}, {'type': 'flight-offer', 'id': '1583015327667-124681231', 'offerItems': [{'services': [{'segments': [{'flightSegment': {'departure': {'iataCode': 'SFO', 'terminal': '2', 'at': '2020-07-09T07:55:00-07:00'}, 'arrival': {'iataCode': 'LAS', 'terminal': '3', 'at': '2020-07-09T09:34:00-07:00'}, 'carrierCode': 'AS', 'number': '3302', 'aircraft': {'code': 'E75'}, 'operating': {'number': '3302'}, 'duration': '0DT1H39M'}, 'pricingDetailPerAdult': {'travelClass': 'ECONOMY', 'fareClass': 'V', 'availability': 7, 'fareBasis': 'VH2OASMN'}}, {'flightSegment': {'departure': {'iataCode': 'LAS', 'terminal': '3', 'at': '2020-07-09T11:15:00-07:00'}, 'arrival': {'iataCode': 'LAX', 'terminal': '6', 'at': '2020-07-09T12:30:00-07:00'}, 'carrierCode': 'AS', 'number': '2173', 'aircraft': {'code': 'E75'}, 'operating': {'number': '2173'}, 'duration': '0DT1H15M'}, 'pricingDetailPerAdult': {'travelClass': 'ECONOMY', 'fareClass': 'T', 'availability': 1, 'fareBasis': 'TH3TAVMN'}}]}], 'price': {'total': '198.85', 'totalTaxes': '33.85'}, 'pricePerAdult': {'total': '198.85', 'totalTaxes': '33.85'}}]}, {'type': 'flight-offer', 'id': '1583015327667-1499058599', 'offerItems': [{'services': [{'segments': [{'flightSegment': {'departure': {'iataCode': 'SFO', 'terminal': '3', 'at': '2020-07-09T14:00:00-07:00'}, 'arrival': {'iataCode': 'LAX', 'terminal': '7', 'at': '2020-07-09T15:38:00-07:00'}, 'carrierCode': 'UA', 'number': '2114', 'aircraft': {'code': '738'}, 'operating': {'carrierCode': 'UA', 'number': '2114'}, 'duration': '0DT1H38M'}, 'pricingDetailPerAdult': {'travelClass': 'ECONOMY', 'fareClass': 'G', 'availability': 9, 'fareBasis': 'GAA2AQDN'}}]}], 'price': {'total': '96.10', 'totalTaxes': '19.10'}, 'pricePerAdult': {'total': '96.10', 'totalTaxes': '19.10'}}]}, {'type': 'flight-offer', 'id': '1583015327667-581136118', 'offerItems': [{'services': [{'segments': [{'flightSegment': {'departure': {'iataCode': 'SFO', 'terminal': '2', 'at': '2020-07-09T19:00:00-07:00'}, 'arrival': {'iataCode': 'LAX', 'terminal': '6', 'at': '2020-07-09T20:33:00-07:00'}, 'carrierCode': 'AS', 'number': '1238', 'aircraft': {'code': '32S'}, 'operating': {'carrierCode': 'AS', 'number': '1238'}, 'duration': '0DT1H33M'}, 'pricingDetailPerAdult': {'travelClass': 'ECONOMY', 'fareClass': 'X', 'availability': 7, 'fareBasis': 'TH2OAVBN'}}]}], 'price': {'total': '63.85', 'totalTaxes': '16.85'}, 'pricePerAdult': {'total': '63.85', 'totalTaxes': '16.85'}}]}, {'type': 'flight-offer', 'id': '1583015327667-1766326436', 'offerItems': [{'services': [{'segments': [{'flightSegment': {'departure': {'iataCode': 'SFO', 'terminal': '1', 'at': '2020-07-09T10:38:00-07:00'}, 'arrival': {'iataCode': 'LAX', 'terminal': '2', 'at': '2020-07-09T12:10:00-07:00'}, 'carrierCode': 'DL', 'number': '708', 'aircraft': {'code': '319'}, 'operating': {'carrierCode': 'DL', 'number': '708'}, 'duration': '0DT1H32M'}, 'pricingDetailPerAdult': {'travelClass': 'ECONOMY', 'fareClass': 'E', 'availability': 9, 'fareBasis': 'TAUVA0BQ'}}]}], 'price': {'total': '77.81', 'totalTaxes': '17.81'}, 'pricePerAdult': {'total': '77.81', 'totalTaxes': '17.81'}}]}, {'type': 'flight-offer', 'id': '1583015327667--501107881', 'offerItems': [{'services': [{'segments': [{'flightSegment': {'departure': {'iataCode': 'SFO', 'terminal': '2', 'at': '2020-07-09T09:00:00-07:00'}, 'arrival': {'iataCode': 'LAX', 'terminal': '6', 'at': '2020-07-09T10:40:00-07:00'}, 'carrierCode': 'AS', 'number': '3446', 'aircraft': {'code': 'E75'}, 'operating': {'number': '3446'}, 'duration': '0DT1H40M'}, 'pricingDetailPerAdult': {'travelClass': 'ECONOMY', 'fareClass': 'X', 'availability': 7, 'fareBasis': 'KH2OASBN'}}]}], 'price': {'total': '80.00', 'totalTaxes': '18.00'}, 'pricePerAdult': {'total': '80.00', 'totalTaxes': '18.00'}}]}, {'type': 'flight-offer', 'id': '1583015327667-1106064779', 'offerItems': [{'services': [{'segments': [{'flightSegment': {'departure': {'iataCode': 'SFO', 'terminal': '2', 'at': '2020-07-09T06:00:00-07:00'}, 'arrival': {'iataCode': 'LAX', 'terminal': '6', 'at': '2020-07-09T07:39:00-07:00'}, 'carrierCode': 'AS', 'number': '3318', 'aircraft': {'code': 'E75'}, 'operating': {'number': '3318'}, 'duration': '0DT1H39M'}, 'pricingDetailPerAdult': {'travelClass': 'ECONOMY', 'fareClass': 'X', 'availability': 7, 'fareBasis': 'TH2OAVBN'}}]}], 'price': {'total': '63.85', 'totalTaxes': '16.85'}, 'pricePerAdult': {'total': '63.85', 'totalTaxes': '16.85'}}]}, {'type': 'flight-offer', 'id': '1583015327667--550361565', 'offerItems': [{'services': [{'segments': [{'flightSegment': {'departure': {'iataCode': 'SFO', 'terminal': '1', 'at': '2020-07-09T12:58:00-07:00'}, 'arrival': {'iataCode': 'LAX', 'terminal': '2', 'at': '2020-07-09T14:25:00-07:00'}, 'carrierCode': 'DL', 'number': '2600', 'aircraft': {'code': '319'}, 'operating': {'carrierCode': 'DL', 'number': '2600'}, 'duration': '0DT1H27M'}, 'pricingDetailPerAdult': {'travelClass': 'ECONOMY', 'fareClass': 'E', 'availability': 9, 'fareBasis': 'TAUVA0BQ'}}]}], 'price': {'total': '77.81', 'totalTaxes': '17.81'}, 'pricePerAdult': {'total': '77.81', 'totalTaxes': '17.81'}}]}, {'type': 'flight-offer', 'id': '1583015327667-389555624', 'offerItems': [{'services': [{'segments': [{'flightSegment': {'departure': {'iataCode': 'SFO', 'terminal': '1', 'at': '2020-07-09T18:39:00-07:00'}, 'arrival': {'iataCode': 'LAX', 'terminal': '2', 'at': '2020-07-09T20:20:00-07:00'}, 'carrierCode': 'DL', 'number': '1897', 'aircraft': {'code': '739'}, 'operating': {'carrierCode': 'DL', 'number': '1897'}, 'duration': '0DT1H41M'}, 'pricingDetailPerAdult': {'travelClass': 'ECONOMY', 'fareClass': 'E', 'availability': 9, 'fareBasis': 'TAUVA0BQ'}}]}], 'price': {'total': '77.81', 'totalTaxes': '17.81'}, 'pricePerAdult': {'total': '77.81', 'totalTaxes': '17.81'}}]}, {'type': 'flight-offer', 'id': '1583015327667-2070373450', 'offerItems': [{'services': [{'segments': [{'flightSegment': {'departure': {'iataCode': 'SFO', 'terminal': '3', 'at': '2020-07-09T07:45:00-07:00'}, 'arrival': {'iataCode': 'ONT', 'terminal': '2', 'at': '2020-07-09T09:15:00-07:00'}, 'carrierCode': 'UA', 'number': '5792', 'aircraft': {'code': 'CRJ'}, 'operating': {'number': '5792'}, 'duration': '0DT1H30M'}, 'pricingDetailPerAdult': {'travelClass': 'ECONOMY', 'fareClass': 'G', 'availability': 9, 'fareBasis': 'GAA2AKDN'}}]}], 'price': {'total': '100.42', 'totalTaxes': '19.42'}, 'pricePerAdult': {'total': '100.42', 'totalTaxes': '19.42'}}]}, {'type': 'flight-offer', 'id': '1583015327667-2014550491', 'offerItems': [{'services': [{'segments': [{'flightSegment': {'departure': {'iataCode': 'SFO', 'terminal': '2', 'at': '2020-07-09T08:00:00-07:00'}, 'arrival': {'iataCode': 'LAX', 'terminal': '6', 'at': '2020-07-09T09:38:00-07:00'}, 'carrierCode': 'AS', 'number': '1446', 'aircraft': {'code': '32S'}, 'operating': {'carrierCode': 'AS', 'number': '1446'}, 'duration': '0DT1H38M'}, 'pricingDetailPerAdult': {'travelClass': 'ECONOMY', 'fareClass': 'X', 'availability': 7, 'fareBasis': 'TH2OAVBN'}}]}], 'price': {'total': '63.85', 'totalTaxes': '16.85'}, 'pricePerAdult': {'total': '63.85', 'totalTaxes': '16.85'}}]}, {'type': 'flight-offer', 'id': '1583015327667-108207099', 'offerItems': [{'services': [{'segments': [{'flightSegment': {'departure': {'iataCode': 'SFO', 'terminal': '3', 'at': '2020-07-09T17:00:00-07:00'}, 'arrival': {'iataCode': 'LAX', 'terminal': '7', 'at': '2020-07-09T18:44:00-07:00'}, 'carrierCode': 'UA', 'number': '2176', 'aircraft': {'code': '739'}, 'operating': {'carrierCode': 'UA', 'number': '2176'}, 'duration': '0DT1H44M'}, 'pricingDetailPerAdult': {'travelClass': 'ECONOMY', 'fareClass': 'W', 'availability': 4, 'fareBasis': 'WAA3AFEN'}}]}], 'price': {'total': '174.60', 'totalTaxes': '24.60'}, 'pricePerAdult': {'total': '174.60', 'totalTaxes': '24.60'}}]}, {'type': 'flight-offer', 'id': '1583015327667--1859054511', 'offerItems': [{'services': [{'segments': [{'flightSegment': {'departure': {'iataCode': 'SFO', 'terminal': '1', 'at': '2020-07-09T17:02:00-07:00'}, 'arrival': {'iataCode': 'LAX', 'terminal': '2', 'at': '2020-07-09T18:40:00-07:00'}, 'carrierCode': 'DL', 'number': '2757', 'aircraft': {'code': '319'}, 'operating': {'carrierCode': 'DL', 'number': '2757'}, 'duration': '0DT1H38M'}, 'pricingDetailPerAdult': {'travelClass': 'ECONOMY', 'fareClass': 'E', 'availability': 9, 'fareBasis': 'UA3NA0BQ'}}]}], 'price': {'total': '103.60', 'totalTaxes': '19.60'}, 'pricePerAdult': {'total': '103.60', 'totalTaxes': '19.60'}}]}, {'type': 'flight-offer', 'id': '1583015327667-1283747356', 'offerItems': [{'services': [{'segments': [{'flightSegment': {'departure': {'iataCode': 'SFO', 'terminal': '3', 'at': '2020-07-09T22:30:00-07:00'}, 'arrival': {'iataCode': 'ONT', 'terminal': '2', 'at': '2020-07-09T23:48:00-07:00'}, 'carrierCode': 'UA', 'number': '5611', 'aircraft': {'code': 'CRJ'}, 'operating': {'number': '5611'}, 'duration': '0DT1H18M'}, 'pricingDetailPerAdult': {'travelClass': 'ECONOMY', 'fareClass': 'W', 'availability': 4, 'fareBasis': 'WAA0AKDN'}}]}], 'price': {'total': '207.92', 'totalTaxes': '26.92'}, 'pricePerAdult': {'total': '207.92', 'totalTaxes': '26.92'}}]}, {'type': 'flight-offer', 'id': '1583015327667-2020987402', 'offerItems': [{'services': [{'segments': [{'flightSegment': {'departure': {'iataCode': 'SFO', 'terminal': '2', 'at': '2020-07-09T15:00:00-07:00'}, 'arrival': {'iataCode': 'LAX', 'terminal': '6', 'at': '2020-07-09T16:33:00-07:00'}, 'carrierCode': 'AS', 'number': '418', 'aircraft': {'code': '73H'}, 'operating': {'carrierCode': 'AS', 'number': '418'}, 'duration': '0DT1H33M'}, 'pricingDetailPerAdult': {'travelClass': 'ECONOMY', 'fareClass': 'X', 'availability': 7, 'fareBasis': 'TH2OAVBN'}}]}], 'price': {'total': '63.85', 'totalTaxes': '16.85'}, 'pricePerAdult': {'total': '63.85', 'totalTaxes': '16.85'}}]}, {'type': 'flight-offer', 'id': '1583015327667--2013142932', 'offerItems': [{'services': [{'segments': [{'flightSegment': {'departure': {'iataCode': 'SFO', 'terminal': '2', 'at': '2020-07-09T20:00:00-07:00'}, 'arrival': {'iataCode': 'LAX', 'terminal': '6', 'at': '2020-07-09T21:35:00-07:00'}, 'carrierCode': 'AS', 'number': '3440', 'aircraft': {'code': 'E75'}, 'operating': {'number': '3440'}, 'duration': '0DT1H35M'}, 'pricingDetailPerAdult': {'travelClass': 'ECONOMY', 'fareClass': 'V', 'availability': 4, 'fareBasis': 'VH4OASMN'}}]}], 'price': {'total': '100.42', 'totalTaxes': '19.42'}, 'pricePerAdult': {'total': '100.42', 'totalTaxes': '19.42'}}]}, {'type': 'flight-offer', 'id': '1583015327667-1021995922', 'offerItems': [{'services': [{'segments': [{'flightSegment': {'departure': {'iataCode': 'SFO', 'terminal': '3', 'at': '2020-07-09T22:45:00-07:00'}, 'arrival': {'iataCode': 'LAX', 'terminal': '7', 'at': '2020-07-10T00:24:00-07:00'}, 'carrierCode': 'UA', 'number': '257', 'aircraft': {'code': '319'}, 'operating': {'carrierCode': 'UA', 'number': '257'}, 'duration': '0DT1H39M'}, 'pricingDetailPerAdult': {'travelClass': 'ECONOMY', 'fareClass': 'Q', 'availability': 3, 'fareBasis': 'QAA0AQEY'}}]}], 'price': {'total': '217.56', 'totalTaxes': '27.56'}, 'pricePerAdult': {'total': '217.56', 'totalTaxes': '27.56'}}]}, {'type': 'flight-offer', 'id': '1583015327667-2094684728', 'offerItems': [{'services': [{'segments': [{'flightSegment': {'departure': {'iataCode': 'SFO', 'terminal': '3', 'at': '2020-07-09T08:30:00-07:00'}, 'arrival': {'iataCode': 'ONT', 'terminal': '2', 'at': '2020-07-09T09:48:00-07:00'}, 'carrierCode': 'UA', 'number': '5228', 'aircraft': {'code': 'CRJ'}, 'operating': {'number': '5228'}, 'duration': '0DT1H18M'}, 'pricingDetailPerAdult': {'travelClass': 'ECONOMY', 'fareClass': 'K', 'availability': 5, 'fareBasis': 'KAA4AKDN'}}]}], 'price': {'total': '127.30', 'totalTaxes': '21.30'}, 'pricePerAdult': {'total': '127.30', 'totalTaxes': '21.30'}}]}, {'type': 'flight-offer', 'id': '1583015327667--465362970', 'offerItems': [{'services': [{'segments': [{'flightSegment': {'departure': {'iataCode': 'SFO', 'terminal': '1', 'at': '2020-07-09T08:25:00-07:00'}, 'arrival': {'iataCode': 'LAX', 'terminal': '2', 'at': '2020-07-09T10:00:00-07:00'}, 'carrierCode': 'DL', 'number': '777', 'aircraft': {'code': '319'}, 'operating': {'carrierCode': 'DL', 'number': '777'}, 'duration': '0DT1H35M'}, 'pricingDetailPerAdult': {'travelClass': 'ECONOMY', 'fareClass': 'E', 'availability': 9, 'fareBasis': 'TAUVA0BQ'}}]}], 'price': {'total': '77.81', 'totalTaxes': '17.81'}, 'pricePerAdult': {'total': '77.81', 'totalTaxes': '17.81'}}]}, {'type': 'flight-offer', 'id': '1583015327667-1039611321', 'offerItems': [{'services': [{'segments': [{'flightSegment': {'departure': {'iataCode': 'SFO', 'terminal': '3', 'at': '2020-07-09T08:00:00-07:00'}, 'arrival': {'iataCode': 'LAX', 'terminal': '7', 'at': '2020-07-09T09:52:00-07:00'}, 'carrierCode': 'UA', 'number': '613', 'aircraft': {'code': '739'}, 'operating': {'carrierCode': 'UA', 'number': '613'}, 'duration': '0DT1H52M'}, 'pricingDetailPerAdult': {'travelClass': 'ECONOMY', 'fareClass': 'K', 'availability': 6, 'fareBasis': 'KAA4AQDN'}}]}], 'price': {'total': '119.72', 'totalTaxes': '20.72'}, 'pricePerAdult': {'total': '119.72', 'totalTaxes': '20.72'}}]}, {'type': 'flight-offer', 'id': '1583015327667--2043280160', 'offerItems': [{'services': [{'segments': [{'flightSegment': {'departure': {'iataCode': 'SFO', 'terminal': '3', 'at': '2020-07-09T09:30:00-07:00'}, 'arrival': {'iataCode': 'LAX', 'terminal': '7', 'at': '2020-07-09T11:13:00-07:00'}, 'carrierCode': 'UA', 'number': '1897', 'aircraft': {'code': '738'}, 'operating': {'carrierCode': 'UA', 'number': '1897'}, 'duration': '0DT1H43M'}, 'pricingDetailPerAdult': {'travelClass': 'ECONOMY', 'fareClass': 'G', 'availability': 9, 'fareBasis': 'GAA2AQDN'}}]}], 'price': {'total': '96.10', 'totalTaxes': '19.10'}, 'pricePerAdult': {'total': '96.10', 'totalTaxes': '19.10'}}]}, {'type': 'flight-offer', 'id': '1583015327667--1666249787', 'offerItems': [{'services': [{'segments': [{'flightSegment': {'departure': {'iataCode': 'SFO', 'terminal': '2', 'at': '2020-07-09T11:35:00-07:00'}, 'arrival': {'iataCode': 'LAX', 'terminal': '6', 'at': '2020-07-09T13:14:00-07:00'}, 'carrierCode': 'AS', 'number': '3444', 'aircraft': {'code': 'E75'}, 'operating': {'number': '3444'}, 'duration': '0DT1H39M'}, 'pricingDetailPerAdult': {'travelClass': 'ECONOMY', 'fareClass': 'X', 'availability': 7, 'fareBasis': 'TH2OAVBN'}}]}], 'price': {'total': '63.85', 'totalTaxes': '16.85'}, 'pricePerAdult': {'total': '63.85', 'totalTaxes': '16.85'}}]}, {'type': 'flight-offer', 'id': '1583015327667-502868613', 'offerItems': [{'services': [{'segments': [{'flightSegment': {'departure': {'iataCode': 'SFO', 'terminal': '1', 'at': '2020-07-09T06:03:00-07:00'}, 'arrival': {'iataCode': 'LAX', 'terminal': '2', 'at': '2020-07-09T07:35:00-07:00'}, 'carrierCode': 'DL', 'number': '1904', 'aircraft': {'code': '319'}, 'operating': {'carrierCode': 'DL', 'number': '1904'}, 'duration': '0DT1H32M'}, 'pricingDetailPerAdult': {'travelClass': 'ECONOMY', 'fareClass': 'E', 'availability': 9, 'fareBasis': 'TAUVA0BQ'}}]}], 'price': {'total': '77.81', 'totalTaxes': '17.81'}, 'pricePerAdult': {'total': '77.81', 'totalTaxes': '17.81'}}]}, {'type': 'flight-offer', 'id': '1583015327667-1521513834', 'offerItems': [{'services': [{'segments': [{'flightSegment': {'departure': {'iataCode': 'SFO', 'terminal': '3', 'at': '2020-07-09T15:55:00-07:00'}, 'arrival': {'iataCode': 'SMF', 'terminal': 'A', 'at': '2020-07-09T16:45:00-07:00'}, 'carrierCode': 'UA', 'number': '5473', 'aircraft': {'code': 'CRJ'}, 'operating': {'number': '5473'}, 'duration': '0DT0H50M'}, 'pricingDetailPerAdult': {'travelClass': 'ECONOMY', 'fareClass': 'S', 'availability': 9, 'fareBasis': 'SAA4AFDN'}}, {'flightSegment': {'departure': {'iataCode': 'SMF', 'terminal': 'A', 'at': '2020-07-09T19:30:00-07:00'}, 'arrival': {'iataCode': 'LAX', 'terminal': '7', 'at': '2020-07-09T21:07:00-07:00'}, 'carrierCode': 'UA', 'number': '5864', 'aircraft': {'code': 'CRJ'}, 'operating': {'number': '5864'}, 'duration': '0DT1H37M'}, 'pricingDetailPerAdult': {'travelClass': 'ECONOMY', 'fareClass': 'W', 'availability': 9, 'fareBasis': 'WAA3AKEN'}}]}], 'price': {'total': '342.93', 'totalTaxes': '43.93'}, 'pricePerAdult': {'total': '342.93', 'totalTaxes': '43.93'}}]}, {'type': 'flight-offer', 'id': '1583015327667-101227269', 'offerItems': [{'services': [{'segments': [{'flightSegment': {'departure': {'iataCode': 'SFO', 'terminal': '3', 'at': '2020-07-09T18:12:00-07:00'}, 'arrival': {'iataCode': 'ONT', 'terminal': '2', 'at': '2020-07-09T19:30:00-07:00'}, 'carrierCode': 'UA', 'number': '5930', 'aircraft': {'code': 'CRJ'}, 'operating': {'number': '5930'}, 'duration': '0DT1H18M'}, 'pricingDetailPerAdult': {'travelClass': 'ECONOMY', 'fareClass': 'V', 'availability': 6, 'fareBasis': 'VAA0AKDN'}}]}], 'price': {'total': '240.10', 'totalTaxes': '29.10'}, 'pricePerAdult': {'total': '240.10', 'totalTaxes': '29.10'}}]}, {'type': 'flight-offer', 'id': '1583015327667-554495130', 'offerItems': [{'services': [{'segments': [{'flightSegment': {'departure': {'iataCode': 'SFO', 'terminal': '2', 'at': '2020-07-09T13:00:00-07:00'}, 'arrival': {'iataCode': 'LAX', 'terminal': '6', 'at': '2020-07-09T14:39:00-07:00'}, 'carrierCode': 'AS', 'number': '3456', 'aircraft': {'code': 'E75'}, 'operating': {'number': '3456'}, 'duration': '0DT1H39M'}, 'pricingDetailPerAdult': {'travelClass': 'ECONOMY', 'fareClass': 'X', 'availability': 7, 'fareBasis': 'GH4OAVBN'}}]}], 'price': {'total': '73.49', 'totalTaxes': '17.49'}, 'pricePerAdult': {'total': '73.49', 'totalTaxes': '17.49'}}]}, {'type': 'flight-offer', 'id': '1583015327667-1567775083', 'offerItems': [{'services': [{'segments': [{'flightSegment': {'departure': {'iataCode': 'SFO', 'terminal': '3', 'at': '2020-07-09T18:30:00-07:00'}, 'arrival': {'iataCode': 'LAX', 'terminal': '7', 'at': '2020-07-09T20:14:00-07:00'}, 'carrierCode': 'UA', 'number': '2264', 'aircraft': {'code': '739'}, 'operating': {'carrierCode': 'UA', 'number': '2264'}, 'duration': '0DT1H44M'}, 'pricingDetailPerAdult': {'travelClass': 'ECONOMY', 'fareClass': 'K', 'availability': 3, 'fareBasis': 'KAA4AQDN'}}]}], 'price': {'total': '119.72', 'totalTaxes': '20.72'}, 'pricePerAdult': {'total': '119.72', 'totalTaxes': '20.72'}}]}, {'type': 'flight-offer', 'id': '1583015327667--86614509', 'offerItems': [{'services': [{'segments': [{'flightSegment': {'departure': {'iataCode': 'SFO', 'terminal': '3', 'at': '2020-07-09T12:30:00-07:00'}, 'arrival': {'iataCode': 'LAX', 'terminal': '7', 'at': '2020-07-09T14:13:00-07:00'}, 'carrierCode': 'UA', 'number': '433', 'aircraft': {'code': '739'}, 'operating': {'carrierCode': 'UA', 'number': '433'}, 'duration': '0DT1H43M'}, 'pricingDetailPerAdult': {'travelClass': 'ECONOMY', 'fareClass': 'G', 'availability': 9, 'fareBasis': 'GAA2AQDN'}}]}], 'price': {'total': '96.10', 'totalTaxes': '19.10'}, 'pricePerAdult': {'total': '96.10', 'totalTaxes': '19.10'}}]}, {'type': 'flight-offer', 'id': '1583015327667--161207687', 'offerItems': [{'services': [{'segments': [{'flightSegment': {'departure': {'iataCode': 'SFO', 'terminal': '2', 'at': '2020-07-09T09:15:00-07:00'}, 'arrival': {'iataCode': 'SEA', 'at': '2020-07-09T11:35:00-07:00'}, 'carrierCode': 'AS', 'number': '379', 'aircraft': {'code': '73J'}, 'operating': {'carrierCode': 'AS', 'number': '379'}, 'duration': '0DT2H20M'}, 'pricingDetailPerAdult': {'travelClass': 'ECONOMY', 'fareClass': 'X', 'availability': 7, 'fareBasis': 'RH2OAVBN'}}, {'flightSegment': {'departure': {'iataCode': 'SEA', 'at': '2020-07-09T12:45:00-07:00'}, 'arrival': {'iataCode': 'LAX', 'terminal': '6', 'at': '2020-07-09T15:35:00-07:00'}, 'carrierCode': 'AS', 'number': '1436', 'aircraft': {'code': '32S'}, 'operating': {'carrierCode': 'AS', 'number': '1436'}, 'duration': '0DT2H50M'}, 'pricingDetailPerAdult': {'travelClass': 'ECONOMY', 'fareClass': 'X', 'availability': 7, 'fareBasis': 'RH2OAVBN'}}]}], 'price': {'total': '135.46', 'totalTaxes': '29.46'}, 'pricePerAdult': {'total': '135.46', 'totalTaxes': '29.46'}}]}, {'type': 'flight-offer', 'id': '1583015327667-1926715411', 'offerItems': [{'services': [{'segments': [{'flightSegment': {'departure': {'iataCode': 'SFO', 'terminal': '1', 'at': '2020-07-09T15:00:00-07:00'}, 'arrival': {'iataCode': 'LAX', 'terminal': '2', 'at': '2020-07-09T16:35:00-07:00'}, 'carrierCode': 'DL', 'number': '1327', 'aircraft': {'code': '319'}, 'operating': {'carrierCode': 'DL', 'number': '1327'}, 'duration': '0DT1H35M'}, 'pricingDetailPerAdult': {'travelClass': 'ECONOMY', 'fareClass': 'E', 'availability': 9, 'fareBasis': 'UA3NA0BQ'}}]}], 'price': {'total': '103.60', 'totalTaxes': '19.60'}, 'pricePerAdult': {'total': '103.60', 'totalTaxes': '19.60'}}]}, {'type': 'flight-offer', 'id': '1583015327667-1794346723', 'offerItems': [{'services': [{'segments': [{'flightSegment': {'departure': {'iataCode': 'SFO', 'terminal': '2', 'at': '2020-07-09T06:00:00-07:00'}, 'arrival': {'iataCode': 'SEA', 'at': '2020-07-09T08:19:00-07:00'}, 'carrierCode': 'AS', 'number': '1341', 'aircraft': {'code': '73J'}, 'operating': {'carrierCode': 'AS', 'number': '1341'}, 'duration': '0DT2H19M'}, 'pricingDetailPerAdult': {'travelClass': 'ECONOMY', 'fareClass': 'X', 'availability': 7, 'fareBasis': 'RH2OAVBN'}}, {'flightSegment': {'departure': {'iataCode': 'SEA', 'at': '2020-07-09T09:15:00-07:00'}, 'arrival': {'iataCode': 'LAX', 'terminal': '6', 'at': '2020-07-09T12:05:00-07:00'}, 'carrierCode': 'AS', 'number': '416', 'aircraft': {'code': '32S'}, 'operating': {'carrierCode': 'AS', 'number': '416'}, 'duration': '0DT2H50M'}, 'pricingDetailPerAdult': {'travelClass': 'ECONOMY', 'fareClass': 'X', 'availability': 7, 'fareBasis': 'RH2OAVBN'}}]}], 'price': {'total': '135.46', 'totalTaxes': '29.46'}, 'pricePerAdult': {'total': '135.46', 'totalTaxes': '29.46'}}]}, {'type': 'flight-offer', 'id': '1583015327667-288568539', 'offerItems': [{'services': [{'segments': [{'flightSegment': {'departure': {'iataCode': 'SFO', 'terminal': '2', 'at': '2020-07-09T12:35:00-07:00'}, 'arrival': {'iataCode': 'SEA', 'at': '2020-07-09T14:50:00-07:00'}, 'carrierCode': 'AS', 'number': '1477', 'aircraft': {'code': '73J'}, 'operating': {'carrierCode': 'AS', 'number': '1477'}, 'duration': '0DT2H15M'}, 'pricingDetailPerAdult': {'travelClass': 'ECONOMY', 'fareClass': 'X', 'availability': 7, 'fareBasis': 'RH2OAVBN'}}, {'flightSegment': {'departure': {'iataCode': 'SEA', 'at': '2020-07-09T15:50:00-07:00'}, 'arrival': {'iataCode': 'LAX', 'terminal': '6', 'at': '2020-07-09T18:35:00-07:00'}, 'carrierCode': 'AS', 'number': '398', 'aircraft': {'code': '7M9'}, 'operating': {'carrierCode': 'AS', 'number': '398'}, 'duration': '0DT2H45M'}, 'pricingDetailPerAdult': {'travelClass': 'ECONOMY', 'fareClass': 'X', 'availability': 7, 'fareBasis': 'RH2OAVBN'}}]}], 'price': {'total': '135.46', 'totalTaxes': '29.46'}, 'pricePerAdult': {'total': '135.46', 'totalTaxes': '29.46'}}]}, {'type': 'flight-offer', 'id': '1583015327667--1143547020', 'offerItems': [{'services': [{'segments': [{'flightSegment': {'departure': {'iataCode': 'SFO', 'terminal': '2', 'at': '2020-07-09T07:00:00-07:00'}, 'arrival': {'iataCode': 'LAX', 'terminal': '6', 'at': '2020-07-09T08:38:00-07:00'}, 'carrierCode': 'AS', 'number': '3320', 'aircraft': {'code': 'E75'}, 'operating': {'number': '3320'}, 'duration': '0DT1H38M'}, 'pricingDetailPerAdult': {'travelClass': 'ECONOMY', 'fareClass': 'X', 'availability': 7, 'fareBasis': 'TH2OAVBN'}}]}], 'price': {'total': '63.85', 'totalTaxes': '16.85'}, 'pricePerAdult': {'total': '63.85', 'totalTaxes': '16.85'}}]}, {'type': 'flight-offer', 'id': '1583015327667-1959417810', 'offerItems': [{'services': [{'segments': [{'flightSegment': {'departure': {'iataCode': 'SFO', 'terminal': '1', 'at': '2020-07-09T06:00:00-07:00'}, 'arrival': {'iataCode': 'SLC', 'terminal': '2', 'at': '2020-07-09T08:50:00-06:00'}, 'carrierCode': 'DL', 'number': '2401', 'aircraft': {'code': '321'}, 'operating': {'carrierCode': 'DL', 'number': '2401'}, 'duration': '0DT1H50M'}, 'pricingDetailPerAdult': {'travelClass': 'ECONOMY', 'fareClass': 'E', 'availability': 9, 'fareBasis': 'TAVQA0BQ'}}, {'flightSegment': {'departure': {'iataCode': 'SLC', 'terminal': '2', 'at': '2020-07-09T09:30:00-06:00'}, 'arrival': {'iataCode': 'LAX', 'terminal': '2', 'at': '2020-07-09T10:31:00-07:00'}, 'carrierCode': 'DL', 'number': '817', 'aircraft': {'code': '739'}, 'operating': {'carrierCode': 'DL', 'number': '817'}, 'duration': '0DT2H1M'}, 'pricingDetailPerAdult': {'travelClass': 'ECONOMY', 'fareClass': 'E', 'availability': 9, 'fareBasis': 'TAVQA0BC'}}]}], 'price': {'total': '214.95', 'totalTaxes': '34.95'}, 'pricePerAdult': {'total': '214.95', 'totalTaxes': '34.95'}}]}, {'type': 'flight-offer', 'id': '1583015327667--1088268279', 'offerItems': [{'services': [{'segments': [{'flightSegment': {'departure': {'iataCode': 'SFO', 'terminal': '2', 'at': '2020-07-09T17:40:00-07:00'}, 'arrival': {'iataCode': 'LAX', 'terminal': '6', 'at': '2020-07-09T19:15:00-07:00'}, 'carrierCode': 'AS', 'number': '3486', 'aircraft': {'code': 'E75'}, 'operating': {'number': '3486'}, 'duration': '0DT1H35M'}, 'pricingDetailPerAdult': {'travelClass': 'ECONOMY', 'fareClass': 'X', 'availability': 7, 'fareBasis': 'KH2OASBN'}}]}], 'price': {'total': '80.00', 'totalTaxes': '18.00'}, 'pricePerAdult': {'total': '80.00', 'totalTaxes': '18.00'}}]}, {'type': 'flight-offer', 'id': '1583015327667-933343851', 'offerItems': [{'services': [{'segments': [{'flightSegment': {'departure': {'iataCode': 'SFO', 'terminal': '2', 'at': '2020-07-09T06:00:00-07:00'}, 'arrival': {'iataCode': 'PDX', 'at': '2020-07-09T07:49:00-07:00'}, 'carrierCode': 'AS', 'number': '249', 'aircraft': {'code': '32S'}, 'operating': {'carrierCode': 'AS', 'number': '249'}, 'duration': '0DT1H49M'}, 'pricingDetailPerAdult': {'travelClass': 'ECONOMY', 'fareClass': 'X', 'availability': 7, 'fareBasis': 'RH2OAVBN'}}, {'flightSegment': {'departure': {'iataCode': 'PDX', 'at': '2020-07-09T08:35:00-07:00'}, 'arrival': {'iataCode': 'LAX', 'terminal': '6', 'at': '2020-07-09T11:04:00-07:00'}, 'carrierCode': 'AS', 'number': '358', 'aircraft': {'code': '32S'}, 'operating': {'carrierCode': 'AS', 'number': '358'}, 'duration': '0DT2H29M'}, 'pricingDetailPerAdult': {'travelClass': 'ECONOMY', 'fareClass': 'X', 'availability': 7, 'fareBasis': 'GH4OAVBN'}}]}], 'price': {'total': '181.69', 'totalTaxes': '32.69'}, 'pricePerAdult': {'total': '181.69', 'totalTaxes': '32.69'}}]}, {'type': 'flight-offer', 'id': '1583015327667-648802819', 'offerItems': [{'services': [{'segments': [{'flightSegment': {'departure': {'iataCode': 'SFO', 'terminal': '3', 'at': '2020-07-09T15:30:00-07:00'}, 'arrival': {'iataCode': 'LAX', 'terminal': '7', 'at': '2020-07-09T17:14:00-07:00'}, 'carrierCode': 'UA', 'number': '215', 'aircraft': {'code': '739'}, 'operating': {'carrierCode': 'UA', 'number': '215'}, 'duration': '0DT1H44M'}, 'pricingDetailPerAdult': {'travelClass': 'ECONOMY', 'fareClass': 'G', 'availability': 4, 'fareBasis': 'GAA2AQDN'}}]}], 'price': {'total': '96.10', 'totalTaxes': '19.10'}, 'pricePerAdult': {'total': '96.10', 'totalTaxes': '19.10'}}]}, {'type': 'flight-offer', 'id': '1583015327667--200974178', 'offerItems': [{'services': [{'segments': [{'flightSegment': {'departure': {'iataCode': 'SFO', 'terminal': '3', 'at': '2020-07-09T20:00:00-07:00'}, 'arrival': {'iataCode': 'LAX', 'terminal': '7', 'at': '2020-07-09T21:52:00-07:00'}, 'carrierCode': 'UA', 'number': '1200', 'aircraft': {'code': '739'}, 'operating': {'carrierCode': 'UA', 'number': '1200'}, 'duration': '0DT1H52M'}, 'pricingDetailPerAdult': {'travelClass': 'ECONOMY', 'fareClass': 'G', 'availability': 9, 'fareBasis': 'GAA2AQDN'}}]}], 'price': {'total': '96.10', 'totalTaxes': '19.10'}, 'pricePerAdult': {'total': '96.10', 'totalTaxes': '19.10'}}]}, {'type': 'flight-offer', 'id': '1583015327667-2125040166', 'offerItems': [{'services': [{'segments': [{'flightSegment': {'departure': {'iataCode': 'SFO', 'terminal': '2', 'at': '2020-07-09T22:15:00-07:00'}, 'arrival': {'iataCode': 'LAX', 'terminal': '6', 'at': '2020-07-09T23:48:00-07:00'}, 'carrierCode': 'AS', 'number': '3496', 'aircraft': {'code': 'E75'}, 'operating': {'number': '3496'}, 'duration': '0DT1H33M'}, 'pricingDetailPerAdult': {'travelClass': 'ECONOMY', 'fareClass': 'X', 'availability': 7, 'fareBasis': 'GH4OAVBN'}}]}], 'price': {'total': '73.49', 'totalTaxes': '17.49'}, 'pricePerAdult': {'total': '73.49', 'totalTaxes': '17.49'}}]}, {'type': 'flight-offer', 'id': '1583015327667--1562699338', 'offerItems': [{'services': [{'segments': [{'flightSegment': {'departure': {'iataCode': 'SFO', 'terminal': '3', 'at': '2020-07-09T21:30:00-07:00'}, 'arrival': {'iataCode': 'LAX', 'terminal': '7', 'at': '2020-07-09T23:22:00-07:00'}, 'carrierCode': 'UA', 'number': '1294', 'aircraft': {'code': '739'}, 'operating': {'carrierCode': 'UA', 'number': '1294'}, 'duration': '0DT1H52M'}, 'pricingDetailPerAdult': {'travelClass': 'ECONOMY', 'fareClass': 'G', 'availability': 9, 'fareBasis': 'GAA2AQDN'}}]}], 'price': {'total': '96.10', 'totalTaxes': '19.10'}, 'pricePerAdult': {'total': '96.10', 'totalTaxes': '19.10'}}]}, {'type': 'flight-offer', 'id': '1583015327667--612326430', 'offerItems': [{'services': [{'segments': [{'flightSegment': {'departure': {'iataCode': 'SFO', 'terminal': '2', 'at': '2020-07-09T16:10:00-07:00'}, 'arrival': {'iataCode': 'LAX', 'terminal': '6', 'at': '2020-07-09T17:45:00-07:00'}, 'carrierCode': 'AS', 'number': '3434', 'aircraft': {'code': 'E75'}, 'operating': {'number': '3434'}, 'duration': '0DT1H35M'}, 'pricingDetailPerAdult': {'travelClass': 'ECONOMY', 'fareClass': 'X', 'availability': 7, 'fareBasis': 'GH4OAVBN'}}]}], 'price': {'total': '73.49', 'totalTaxes': '17.49'}, 'pricePerAdult': {'total': '73.49', 'totalTaxes': '17.49'}}]}]
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:

Now, with a better understanding of the structure, I can pull specific variables using a key or an index.
# Creating an empty Pandas dataframe to store flight data
flightsdf = pd.DataFrame(columns=['flight_id'])
try:
'''
What are the flight options for flying to Los Angeles from San Francisco on July 9th, 2020?
'''
response = amadeus.shopping.flight_offers.get(origin='SFO', destination='LAX', departureDate='2020-07-09')
# Looping through response, adding each variable to Pandas dataframe
for r in response.data:
flightsdf = flightsdf.append({'flight_id': r['id'],
'total': r['offerItems'][0]['price']['total'],
'totalTaxes': r['offerItems'][0]['price']['totalTaxes'],
'departure_port': r['offerItems'][0]['services'][0]['segments'][0]['flightSegment']['departure']['iataCode'],
'arrival_port': r['offerItems'][0]['services'][0]['segments'][0]['flightSegment']['arrival']['iataCode'],
'd_time': r['offerItems'][0]['services'][0]['segments'][0]['flightSegment']['departure']['at'],
'a_time': r['offerItems'][0]['services'][0]['segments'][0]['flightSegment']['arrival']['at'],
'd_fl_num': r['offerItems'][0]['services'][0]['segments'][0]['flightSegment']['number'],
'carrier': r['offerItems'][0]['services'][0]['segments'][0]['flightSegment']['carrierCode'],
'duration': r['offerItems'][0]['services'][0]['segments'][0]['flightSegment']['duration'],
'class': r['offerItems'][0]['services'][0]['segments'][0]['pricingDetailPerAdult']['travelClass'],
'availability': r['offerItems'][0]['services'][0]['segments'][0]['pricingDetailPerAdult']['availability'],
'aircraft_code': r['offerItems'][0]['services'][0]['segments'][0]['flightSegment']['aircraft']['code'],
'fare_class': r['offerItems'][0]['services'][0]['segments'][0]['pricingDetailPerAdult']['fareClass']
},
ignore_index=True)
except ResponseError as error:
print(error)
print(flightsdf)
flight_id a_time aircraft_code \
0 1583014646520--1088268279 2020-07-09T19:15:00-07:00 E75
1 1583014646520-1686947287 2020-07-09T21:45:00-07:00 319
2 1583014646520--161207687 2020-07-09T11:35:00-07:00 73J
3 1583014646520--1143547020 2020-07-09T08:38:00-07:00 E75
4 1583014646520-2125040166 2020-07-09T23:48:00-07:00 E75
5 1583014646520-101227269 2020-07-09T19:30:00-07:00 CRJ
6 1583014646520--1666249787 2020-07-09T13:14:00-07:00 E75
7 1583014646520-795525582 2020-07-09T15:36:00-07:00 E75
8 1583014646520-2070373450 2020-07-09T09:15:00-07:00 CRJ
9 1583014646520-108207099 2020-07-09T18:44:00-07:00 739
10 1583014646520-1499058599 2020-07-09T15:38:00-07:00 738
11 1583014646520-1021995922 2020-07-10T00:24:00-07:00 319
12 1583014646520-389555624 2020-07-09T20:20:00-07:00 739
13 1583014646520--612326430 2020-07-09T17:45:00-07:00 E75
14 1583014646520-1567775083 2020-07-09T20:14:00-07:00 739
15 1583014646520-2041443946 2020-07-09T11:18:00-07:00 CRJ
16 1583014646520--465362970 2020-07-09T10:00:00-07:00 319
17 1583014646520-136522242 2020-07-09T09:29:00-07:00 CRJ
18 1583014646520--2013142932 2020-07-09T21:35:00-07:00 E75
19 1583014646520--1562699338 2020-07-09T23:22:00-07:00 739
20 1583014646520-1794346723 2020-07-09T08:19:00-07:00 73J
21 1583014646520-1039611321 2020-07-09T09:52:00-07:00 739
22 1583014646520-554495130 2020-07-09T14:39:00-07:00 E75
23 1583014646520-502868613 2020-07-09T07:35:00-07:00 319
24 1583014646520--1859054511 2020-07-09T18:40:00-07:00 319
25 1583014646520-1871803817 2020-07-09T08:21:00-07:00 739
26 1583014646520-933343851 2020-07-09T07:49:00-07:00 32S
27 1583014646520-2020987402 2020-07-09T16:33:00-07:00 73H
28 1583014646520-1547356594 2020-07-09T12:18:00-07:00 E75
29 1583014646520-648802819 2020-07-09T17:14:00-07:00 739
30 1583014646520-581136118 2020-07-09T20:33:00-07:00 32S
31 1583014646520--86614509 2020-07-09T14:13:00-07:00 739
32 1583014646520-844438014 2020-07-09T04:22:00-06:00 320
33 1583014646520-1926715411 2020-07-09T16:35:00-07:00 319
34 1583014646520-2014550491 2020-07-09T09:38:00-07:00 32S
35 1583014646520-1766326436 2020-07-09T12:10:00-07:00 319
36 1583014646520-288568539 2020-07-09T14:50:00-07:00 73J
37 1583014646520--501107881 2020-07-09T10:40:00-07:00 E75
38 1583014646520--550361565 2020-07-09T14:25:00-07:00 319
39 1583014646520--702364065 2020-07-09T17:37:00-07:00 E75
40 1583014646520-1106064779 2020-07-09T07:39:00-07:00 E75
41 1583014646520-1959417810 2020-07-09T08:50:00-06:00 321
42 1583014646520-124681231 2020-07-09T09:34:00-07:00 E75
43 1583014646520--200974178 2020-07-09T21:52:00-07:00 739
44 1583014646520-1186805071 2020-07-09T12:43:00-07:00 738
45 1583014646520--2043280160 2020-07-09T11:13:00-07:00 738
46 1583014646520-1283747356 2020-07-09T23:48:00-07:00 CRJ
47 1583014646520-2094684728 2020-07-09T09:48:00-07:00 CRJ
48 1583014646520-325495069 2020-07-09T15:38:00-07:00 CRJ
49 1583014646520-1521513834 2020-07-09T16:45:00-07:00 CRJ
arrival_port availability carrier class d_fl_num \
0 LAX 7.0 AS ECONOMY 3486
1 LAX 9.0 DL ECONOMY 1898
2 SEA 7.0 AS ECONOMY 379
3 LAX 7.0 AS ECONOMY 3320
4 LAX 7.0 AS ECONOMY 3496
5 ONT 6.0 UA ECONOMY 5930
6 LAX 7.0 AS ECONOMY 3444
7 LAX 7.0 AS ECONOMY 2428
8 ONT 9.0 UA ECONOMY 5792
9 LAX 4.0 UA ECONOMY 2176
10 LAX 9.0 UA ECONOMY 2114
11 LAX 3.0 UA ECONOMY 257
12 LAX 9.0 DL ECONOMY 1897
13 LAX 7.0 AS ECONOMY 3434
14 LAX 3.0 UA ECONOMY 2264
15 ONT 1.0 UA ECONOMY 5371
16 LAX 9.0 DL ECONOMY 777
17 SMF 9.0 UA ECONOMY 5445
18 LAX 4.0 AS ECONOMY 3440
19 LAX 9.0 UA ECONOMY 1294
20 SEA 7.0 AS ECONOMY 1341
21 LAX 6.0 UA ECONOMY 613
22 LAX 7.0 AS ECONOMY 3456
23 LAX 9.0 DL ECONOMY 1904
24 LAX 9.0 DL ECONOMY 2757
25 LAX 9.0 UA ECONOMY 504
26 PDX 7.0 AS ECONOMY 249
27 LAX 7.0 AS ECONOMY 418
28 LAX 7.0 AS ECONOMY 3432
29 LAX 4.0 UA ECONOMY 215
30 LAX 7.0 AS ECONOMY 1238
31 LAX 9.0 UA ECONOMY 433
32 DEN 4.0 F9 ECONOMY 662
33 LAX 9.0 DL ECONOMY 1327
34 LAX 7.0 AS ECONOMY 1446
35 LAX 9.0 DL ECONOMY 708
36 SEA 7.0 AS ECONOMY 1477
37 LAX 7.0 AS ECONOMY 3446
38 LAX 9.0 DL ECONOMY 2600
39 LAS 7.0 AS ECONOMY 3386
40 LAX 7.0 AS ECONOMY 3318
41 SLC 9.0 DL ECONOMY 2401
42 LAS 7.0 AS ECONOMY 3302
43 LAX 9.0 UA ECONOMY 1200
44 LAX 6.0 UA ECONOMY 256
45 LAX 9.0 UA ECONOMY 1897
46 ONT 4.0 UA ECONOMY 5611
47 ONT 5.0 UA ECONOMY 5228
48 ONT 6.0 UA ECONOMY 5422
49 SMF 9.0 UA ECONOMY 5473
d_time departure_port duration fare_class total \
0 2020-07-09T17:40:00-07:00 SFO 0DT1H35M X 80.00
1 2020-07-09T20:09:00-07:00 SFO 0DT1H36M E 77.81
2 2020-07-09T09:15:00-07:00 SFO 0DT2H20M X 135.46
3 2020-07-09T07:00:00-07:00 SFO 0DT1H38M X 63.85
4 2020-07-09T22:15:00-07:00 SFO 0DT1H33M X 73.49
5 2020-07-09T18:12:00-07:00 SFO 0DT1H18M V 240.10
6 2020-07-09T11:35:00-07:00 SFO 0DT1H39M X 63.85
7 2020-07-09T14:00:00-07:00 SFO 0DT1H36M X 63.85
8 2020-07-09T07:45:00-07:00 SFO 0DT1H30M G 100.42
9 2020-07-09T17:00:00-07:00 SFO 0DT1H44M W 174.60
10 2020-07-09T14:00:00-07:00 SFO 0DT1H38M G 96.10
11 2020-07-09T22:45:00-07:00 SFO 0DT1H39M Q 217.56
12 2020-07-09T18:39:00-07:00 SFO 0DT1H41M E 77.81
13 2020-07-09T16:10:00-07:00 SFO 0DT1H35M X 73.49
14 2020-07-09T18:30:00-07:00 SFO 0DT1H44M K 119.72
15 2020-07-09T09:51:00-07:00 SFO 0DT1H27M G 100.42
16 2020-07-09T08:25:00-07:00 SFO 0DT1H35M E 77.81
17 2020-07-09T08:35:00-07:00 SFO 0DT0H54M S 342.93
18 2020-07-09T20:00:00-07:00 SFO 0DT1H35M V 100.42
19 2020-07-09T21:30:00-07:00 SFO 0DT1H52M G 96.10
20 2020-07-09T06:00:00-07:00 SFO 0DT2H19M X 135.46
21 2020-07-09T08:00:00-07:00 SFO 0DT1H52M K 119.72
22 2020-07-09T13:00:00-07:00 SFO 0DT1H39M X 73.49
23 2020-07-09T06:03:00-07:00 SFO 0DT1H32M E 77.81
24 2020-07-09T17:02:00-07:00 SFO 0DT1H38M E 103.60
25 2020-07-09T06:30:00-07:00 SFO 0DT1H51M K 119.72
26 2020-07-09T06:00:00-07:00 SFO 0DT1H49M X 181.69
27 2020-07-09T15:00:00-07:00 SFO 0DT1H33M X 63.85
28 2020-07-09T10:40:00-07:00 SFO 0DT1H38M X 63.85
29 2020-07-09T15:30:00-07:00 SFO 0DT1H44M G 96.10
30 2020-07-09T19:00:00-07:00 SFO 0DT1H33M X 63.85
31 2020-07-09T12:30:00-07:00 SFO 0DT1H43M G 96.10
32 2020-07-09T00:49:00-07:00 SFO 0DT2H33M B 174.11
33 2020-07-09T15:00:00-07:00 SFO 0DT1H35M E 103.60
34 2020-07-09T08:00:00-07:00 SFO 0DT1H38M X 63.85
35 2020-07-09T10:38:00-07:00 SFO 0DT1H32M E 77.81
36 2020-07-09T12:35:00-07:00 SFO 0DT2H15M X 135.46
37 2020-07-09T09:00:00-07:00 SFO 0DT1H40M X 80.00
38 2020-07-09T12:58:00-07:00 SFO 0DT1H27M E 77.81
39 2020-07-09T16:00:00-07:00 SFO 0DT1H37M V 198.85
40 2020-07-09T06:00:00-07:00 SFO 0DT1H39M X 63.85
41 2020-07-09T06:00:00-07:00 SFO 0DT1H50M E 214.95
42 2020-07-09T07:55:00-07:00 SFO 0DT1H39M V 198.85
43 2020-07-09T20:00:00-07:00 SFO 0DT1H52M G 96.10
44 2020-07-09T11:00:00-07:00 SFO 0DT1H43M G 96.10
45 2020-07-09T09:30:00-07:00 SFO 0DT1H43M G 96.10
46 2020-07-09T22:30:00-07:00 SFO 0DT1H18M W 207.92
47 2020-07-09T08:30:00-07:00 SFO 0DT1H18M K 127.30
48 2020-07-09T14:11:00-07:00 SFO 0DT1H27M L 146.60
49 2020-07-09T15:55:00-07:00 SFO 0DT0H50M S 342.93
totalTaxes
0 18.00
1 17.81
2 29.46
3 16.85
4 17.49
5 29.10
6 16.85
7 16.85
8 19.42
9 24.60
10 19.10
11 27.56
12 17.81
13 17.49
14 20.72
15 19.42
16 17.81
17 43.93
18 19.42
19 19.10
20 29.46
21 20.72
22 17.49
23 17.81
24 19.60
25 20.72
26 32.69
27 16.85
28 16.85
29 19.10
30 16.85
31 19.10
32 32.11
33 19.60
34 16.85
35 17.81
36 29.46
37 18.00
38 17.81
39 33.85
40 16.85
41 34.95
42 33.85
43 19.10
44 19.10
45 19.10
46 26.92
47 21.30
48 22.60
49 43.93
# Summary of dataframe
print(flightsdf.info())
<class 'pandas.core.frame.DataFrame'> RangeIndex: 50 entries, 0 to 49 Data columns (total 14 columns): flight_id 50 non-null object a_time 50 non-null object aircraft_code 50 non-null object arrival_port 50 non-null object availability 50 non-null float64 carrier 50 non-null object class 50 non-null object d_fl_num 50 non-null object d_time 50 non-null object departure_port 50 non-null object duration 50 non-null object fare_class 50 non-null object total 50 non-null object totalTaxes 50 non-null object dtypes: float64(1), object(13) memory usage: 5.5+ KB None
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.
# New arrival time data frame with split value columns
a_time_df = flightsdf["a_time"].str.split("T", n = 1, expand = True)
# Making separate date column from new data frame
flightsdf["a_date"]= a_time_df[0]
# Making separate time column from new data frame
flightsdf["a_time_new"]= a_time_df[1]
# Dropping old time column
flightsdf.drop(columns =["a_time"], inplace = True)
# Previewing cleaned data
print(flightsdf.head())
flight_id aircraft_code arrival_port availability carrier \
0 1583014646520--1088268279 E75 LAX 7.0 AS
1 1583014646520-1686947287 319 LAX 9.0 DL
2 1583014646520--161207687 73J SEA 7.0 AS
3 1583014646520--1143547020 E75 LAX 7.0 AS
4 1583014646520-2125040166 E75 LAX 7.0 AS
class d_fl_num d_time departure_port duration \
0 ECONOMY 3486 2020-07-09T17:40:00-07:00 SFO 0DT1H35M
1 ECONOMY 1898 2020-07-09T20:09:00-07:00 SFO 0DT1H36M
2 ECONOMY 379 2020-07-09T09:15:00-07:00 SFO 0DT2H20M
3 ECONOMY 3320 2020-07-09T07:00:00-07:00 SFO 0DT1H38M
4 ECONOMY 3496 2020-07-09T22:15:00-07:00 SFO 0DT1H33M
fare_class total totalTaxes a_date a_time_new
0 X 80.00 18.00 2020-07-09 19:15:00-07:00
1 E 77.81 17.81 2020-07-09 21:45:00-07:00
2 X 135.46 29.46 2020-07-09 11:35:00-07:00
3 X 63.85 16.85 2020-07-09 08:38:00-07:00
4 X 73.49 17.49 2020-07-09 23:48:00-07:00
# New departure time data frame with split value columns
d_time_df = flightsdf["d_time"].str.split("T", n = 1, expand = True)
# Making separate date column from new data frames
flightsdf["d_date"]= d_time_df[0]
# Making separate time column from new data frames
flightsdf["d_time_new"]= d_time_df[1]
# Dropping old time column
flightsdf.drop(columns =["d_time"], inplace = True)
# Previewing cleaned data
print(flightsdf.head())
flight_id aircraft_code arrival_port availability carrier \
0 1583014646520--1088268279 E75 LAX 7.0 AS
1 1583014646520-1686947287 319 LAX 9.0 DL
2 1583014646520--161207687 73J SEA 7.0 AS
3 1583014646520--1143547020 E75 LAX 7.0 AS
4 1583014646520-2125040166 E75 LAX 7.0 AS
class d_fl_num departure_port duration fare_class total totalTaxes \
0 ECONOMY 3486 SFO 0DT1H35M X 80.00 18.00
1 ECONOMY 1898 SFO 0DT1H36M E 77.81 17.81
2 ECONOMY 379 SFO 0DT2H20M X 135.46 29.46
3 ECONOMY 3320 SFO 0DT1H38M X 63.85 16.85
4 ECONOMY 3496 SFO 0DT1H33M X 73.49 17.49
a_date a_time_new d_date d_time_new
0 2020-07-09 19:15:00-07:00 2020-07-09 17:40:00-07:00
1 2020-07-09 21:45:00-07:00 2020-07-09 20:09:00-07:00
2 2020-07-09 11:35:00-07:00 2020-07-09 09:15:00-07:00
3 2020-07-09 08:38:00-07:00 2020-07-09 07:00:00-07:00
4 2020-07-09 23:48:00-07:00 2020-07-09 22:15:00-07:00
Now that I have them successfully separated, I'll clean up those column names.
flightsdf=flightsdf.rename(columns = {'a_time_new':'arr_time', 'd_time_new':'dep_time', 'a_date':'arr_date', 'd_date':'dep_date'})
print(flightsdf.head())
flight_id aircraft_code arrival_port availability carrier \
0 1583014646520--1088268279 E75 LAX 7.0 AS
1 1583014646520-1686947287 319 LAX 9.0 DL
2 1583014646520--161207687 73J SEA 7.0 AS
3 1583014646520--1143547020 E75 LAX 7.0 AS
4 1583014646520-2125040166 E75 LAX 7.0 AS
class d_fl_num departure_port duration fare_class total totalTaxes \
0 ECONOMY 3486 SFO 0DT1H35M X 80.00 18.00
1 ECONOMY 1898 SFO 0DT1H36M E 77.81 17.81
2 ECONOMY 379 SFO 0DT2H20M X 135.46 29.46
3 ECONOMY 3320 SFO 0DT1H38M X 63.85 16.85
4 ECONOMY 3496 SFO 0DT1H33M X 73.49 17.49
arr_date arr_time dep_date dep_time
0 2020-07-09 19:15:00-07:00 2020-07-09 17:40:00-07:00
1 2020-07-09 21:45:00-07:00 2020-07-09 20:09:00-07:00
2 2020-07-09 11:35:00-07:00 2020-07-09 09:15:00-07:00
3 2020-07-09 08:38:00-07:00 2020-07-09 07:00:00-07:00
4 2020-07-09 23:48:00-07:00 2020-07-09 22:15:00-07:00
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.
# New duration data frame with stripped values
dur_df = flightsdf["duration"].str.split("T", n = 1, expand = True)
# Making new duration column from new data frame
flightsdf["duration_new"]= dur_df[1]
# Dropping old duration column
flightsdf.drop(columns =["duration"], inplace = True)
# Renaming cleaned duration column
flightsdf=flightsdf.rename(columns = {'duration_new':'duration'})
# Previewing cleaned data
print(flightsdf.head())
flight_id aircraft_code arrival_port availability carrier \
0 1583014646520--1088268279 E75 LAX 7.0 AS
1 1583014646520-1686947287 319 LAX 9.0 DL
2 1583014646520--161207687 73J SEA 7.0 AS
3 1583014646520--1143547020 E75 LAX 7.0 AS
4 1583014646520-2125040166 E75 LAX 7.0 AS
class d_fl_num departure_port fare_class total totalTaxes arr_date \
0 ECONOMY 3486 SFO X 80.00 18.00 2020-07-09
1 ECONOMY 1898 SFO E 77.81 17.81 2020-07-09
2 ECONOMY 379 SFO X 135.46 29.46 2020-07-09
3 ECONOMY 3320 SFO X 63.85 16.85 2020-07-09
4 ECONOMY 3496 SFO X 73.49 17.49 2020-07-09
arr_time dep_date dep_time duration
0 19:15:00-07:00 2020-07-09 17:40:00-07:00 1H35M
1 21:45:00-07:00 2020-07-09 20:09:00-07:00 1H36M
2 11:35:00-07:00 2020-07-09 09:15:00-07:00 2H20M
3 08:38:00-07:00 2020-07-09 07:00:00-07:00 1H38M
4 23:48:00-07:00 2020-07-09 22:15:00-07:00 1H33M
# Writing cleaned dataframe to CSV file
flightsdf.to_csv('flights_sfo_lax_07092020.csv')
With the CSV file successfully created, I feel great!
