Reference¶
Client¶
-
class
amadeus.
Client
(**options)[source]¶ The Amadeus client library for accessing the travel APIs.
-
__init__
(**options)[source]¶ Initialize using your credentials:
from amadeus import Client amadeus = Client( client_id='YOUR_CLIENT_ID', client_secret='YOUR_CLIENT_SECRET' )
Alternatively, initialize the library using the environment variables
AMADEUS_CLIENT_ID
andAMADEUS_CLIENT_SECRET
.amadeus = amadeus.Client()
- Parameters
client_id (str) – the API key used to authenticate the API
client_secret (str) – the API secret used to authenticate the API
logger (logging.Logger) – (optional) a Python compatible logger (Default:
logging.Logger
)log_level (str) – (optional) the log level of the client, either
"debug"
,"warn"
, or"silent"
mode (Default:"silent"
)hostname (str) – (optional) the name of the server API calls are made to,
"production"
or"test"
. (Default:"test"
)host (str) – (optional) alternatively, you can specify a full host domain name instead, e.g.
"api.example.com"
ssl (bool) – if this client is should use HTTPS (Default:
True
)port (int) – the port this client should use (Default:
80
for HTTP and443
for HTTPS)custom_app_id (str) – (optional) a custom App ID to be passed in the User Agent to the server (Default:
None
)custom_app_version (str) – (optional) a custom App Version number to be passed in the User Agent to the server (Default:
None
)http (urllib.request.urlopen) – (optional) a
urllib.request.urlopen()
compatible client that accepts aurllib.request.Request
compatible object (Default:urlopen
)
- Raises
ValueError – when a required param is missing
-
get
(path, **params)¶ A helper function for making generic GET requests calls. It is used by every namespaced API GET method.
It can be used to make any generic API call that is automatically authenticated using your API credentials:
amadeus.get('/foo/bar', airline='1X')
- Parameters
- Return type
- Raises
amadeus.ResponseError – when the request fails
-
post
(path, params=None)¶ A helper function for making generic POST requests calls. It is used by every namespaced API POST method.
It can be used to make any generic API call that is automatically authenticated using your API credentials:
amadeus.post('/foo/bar', airline='1X')
- Parameters
- Return type
- Raises
amadeus.ResponseError – when the request fails
-
request
(verb, path, params)¶ A helper function for making generic POST requests calls. It is used by every namespaced API method. It can be used to make any generic API call that is automatically authenticated using your API credentials:
amadeus.request('GET', '/foo/bar', airline='1X')
- Parameters
- Return type
- Raises
amadeus.ResponseError – when the request fails
-
Response¶
-
class
amadeus.
Response
(http_response, request)[source]¶ The response object returned for every API call.
- Variables
http_response – the raw http response
request (amadeus.Request) – the original Request object used to make this call
result (dict) – the parsed JSON received from the API, if the result was JSON
data (dict) – the data extracted from the JSON data, if the body contained JSON
body (str) – the raw body received from the API
parsed (bool) – wether the raw body has been parsed into JSON
status_code (int) – The HTTP status code for the response, if any
ResponseError¶
-
class
amadeus.
ResponseError
(response)[source]¶ An Amadeus error
- Variables
response (amadeus.Response) – The response object containing the raw HTTP response and the request used to make the API call.
code (str) – A unique code for this type of error. Options include
NetworkError
,ParserError
,ServerError
,AuthenticationError
,NotFoundError
andUnknownError
.
-
class
amadeus.
AuthenticationError
(response)[source]¶ Bases:
amadeus.client.errors.ResponseError
This error occurs when the client did not provide the right credentials
-
class
amadeus.
ClientError
(response)[source]¶ Bases:
amadeus.client.errors.ResponseError
This error occurs when the client did not provide the right parameters
-
class
amadeus.
NetworkError
(response)[source]¶ Bases:
amadeus.client.errors.ResponseError
This error occurs when there is some kind of error in the network
-
class
amadeus.
ServerError
(response)[source]¶ Bases:
amadeus.client.errors.ResponseError
This error occurs when there is an error on the server
Request¶
-
class
amadeus.
Request
(options)[source]¶ An object containing all the compiled information about the request made.
- Variables
host (str) – The host used for this API call
port (int) – The port for this API call. Standard set to 443.
scheme (str) – The scheme used to make the API call
params (dict) – The GET/POST params for the API call
path (str) – The path of the API to be called
verb (str) – The verb used to make an API call (‘GET’ or ‘POST’)
bearer_token (str) – The bearer token (if any) that was used for authentication
headers (dict) – The headers used for the API call
client_version (str) – The library version used for this request
language_version (str) – The Python language version used for this request
app_id (str) – The custom app ID passed in for this request
app_version (str) – The custom app version used for this request
Shopping/Flights¶
-
class
amadeus.shopping.
FlightDestinations
(client)[source]¶ -
get
(**params)[source]¶ Find the cheapest destinations where you can fly to.
amadeus.shopping.flight_destinations.get(origin='LON')
- Parameters
origin – the City/Airport IATA code from which the flight will depart.
"LON"
, for example for London.- Return type
- Raises
amadeus.ResponseError – if the request could not be completed
-
-
class
amadeus.shopping.
FlightDates
(client)[source]¶ -
get
(**params)[source]¶ Find the cheapest flight dates from an origin to a destination.
amadeus.shopping.flight_dates.get(origin='NYC', destination='MAD')
- Parameters
origin – the City/Airport IATA code from which the flight will depart.
"NYC"
, for example for New-York.destination – the City/Airport IATA code to which the flight is going.
"MAD"
, for example for Madrid.
- Return type
- Raises
amadeus.ResponseError – if the request could not be completed
-
-
class
amadeus.shopping.
FlightOffersSearch
(client)[source]¶ -
get
(**params)[source]¶ Get the cheapest flights on a given journey
amadeus.shopping.flight_offers_search.get( originLocationCode='MAD', destinationLocationCode='BOS', departureDate='2019-11-01', adults='1' )
- Parameters
originLocationCode – the City/Airport IATA code from which the flight will depart.
"MAD"
, for example for Madrid.destinationLocationCode – the City/Airport IATA code to which the flight is going.
"BOS"
, for example for Boston.departureDate – the date on which to fly out, in YYYY-MM-DD format
adults – the number of adult passengers with age 12 or older
- Return type
- Raises
amadeus.ResponseError – if the request could not be completed
-
-
class
amadeus.shopping.
FlightOffersSearch
(client)[source]¶ -
post
(body)[source]¶ Get the cheapest flights on a given journey.
amadeus.shopping.flight_offers_search.post(body)
- Parameters
body – the parameters to send to the API
- Return type
- Raises
amadeus.ResponseError – if the request could not be completed
-
Shopping/Hotels¶
Shopping/FlightOffers¶
-
class
amadeus.shopping.flight_offers.
FlightChoicePrediction
(client)[source]¶ -
post
(body)[source]¶ Forecast traveler choices in the context of search & shopping.
amadeus.shopping.flight_offers.prediction.post( amadeus.shopping.flight_offers_search.get( originLocationCode='SYD', destinationLocationCode='BKK', departureDate='2020-11-01', adults=1).result
)
- Return type
- Raises
amadeus.ResponseError – if the request could not be completed
-
-
class
amadeus.shopping.flight_offers.
Upselling
(client)[source]¶ -
post
(body)[source]¶ Get flight offers with branded fares
amadeus.shopping.flight_offers.upselling.post(body)
- Parameters
body – the parameters to send to the API
- Return type
- Raises
amadeus.ResponseError – if the request could not be completed
-
Shopping/Activities¶
-
class
amadeus.shopping.
Activities
(client)[source]¶ -
get
(**params)[source]¶ Returns activities for a given location
client.shopping.activities.get( longitude=2.160873, latitude=41.397158 )
- Parameters
latitude – latitude of geographic location to search around. For example:
41.397158
longitude – longitude of geographic location to search around. For example:
2.160873
- Return type
- Raises
amadeus.ResponseError – if the request could not be completed
-
-
class
amadeus.shopping.activities.
BySquare
(client)[source]¶ -
get
(**params)[source]¶ - Returns a list of activities
around a defined square (4 points).
client.shopping.activities.by_square.get( north=41.397158, west=2.160873, south=41.394582, east=2.177181 )
- Parameters
north – latitude north of bounding box. For example:
41.397158
west – longitude west of bounding box. For example:
2.160873
south – latitude south of bounding box. For example:
41.394582
east – longitude east of bounding box. For example:
2.177181
- Return type
- Raises
amadeus.ResponseError – if the request could not be completed
-
Shopping/Availability¶
-
class
amadeus.shopping.availability.
FlightAvailabilities
(client)[source]¶ -
post
(body)[source]¶ Get available seats in different fare classes
amadeus.shopping.availability.flight_availabilities.post(body)
- Parameters
body – the parameters to send to the API
- Return type
- Raises
amadeus.ResponseError – if the request could not be completed
-
Travel/Analytics¶
Travel/Predictions¶
-
class
amadeus.travel.predictions.
TripPurpose
(client)[source]¶ -
get
(**params)[source]¶ Predicts traveler purpose, Business or Leisure, with the probability in the context of search & shopping
amadeus.travel.predictions.trip_purpose.get( originLocationCode='NYC', destinationLocationCode='MAD', departureDate='2020-08-01', returnDate='2020-08-12', searchDate='2020-06-11')
- Parameters
originLocationCode – the City/Airport IATA code from which the flight will depart.
"NYC"
, for example for New YorkdestinationLocationCode – the City/Airport IATA code to which the flight is going.
"MAD"
, for example for MadriddepartureDate – the date on which to fly out, in YYYY-MM-DD format
returnDate – the date on which the flight returns to the origin, in YYYY-MM-DD format
searchDate – the date on which the traveler performs the search, in YYYY-MM-DD format. If it is not specified the current date will be used
- Return type
- Raises
amadeus.ResponseError – if the request could not be completed
-
-
class
amadeus.travel.predictions.
FlightDelay
(client)[source]¶ -
get
(**params)[source]¶ Forecast the chances for a flight to be delayed
- amadeus.travel.predictions.flight_delay.get(originLocationCode=’NCE’,
destinationLocationCode=’IST’, departureDate=’2020-08-01’, departureTime=’18:20:00’, arrivalDate=’2020-08-01’, arrivalTime=’22:15:00’, aircraftCode=’321’, carrierCode=’TK’, flightNumber=’1816’, duration=’PT31H10M’)
- Parameters
originLocationCode – the City/Airport IATA code from which the flight will depart.
"NYC"
, for example for New YorkdestinationLocationCode – the City/Airport IATA code to which the flight is going.
"MAD"
, for example for MadriddepartureDate – the date on which the traveler departs from the origin, in YYYY-MM-DD format
departureTime – local time on which to fly out, in HH:MM:SS format
arrivalDate – the date on which the traveler arrives to the destination, in YYYY-MM-DD format
arrivalTime – local time on which the traveler arrives to the destination, in HH:MM:SS format
aircraftCode – IATA aircraft code
carrierCode – airline / carrier code
flightNumber – flight number as assigned by the carrier
duration – flight duration, in PnYnMnDTnHnMnS format e.g. PT2H10M
- Return type
- Raises
amadeus.ResponseError – if the request could not be completed
-
Travel/TripParser¶
-
class
amadeus.travel.
TripParser
(client)[source]¶ -
post
(body)[source]¶ Sends the request for the parsing with the booking details and input parameters.
amadeus.travel.trip_parser.post( '{ "payload": "base64string" }'
You can call our helper functions with your booking details in a file or the content encoded in Base64
- Return type
- Raises
amadeus.ResponseError – if the request could not be completed
-
ReferenceData/Locations¶
-
class
amadeus.reference_data.
Location
(client, location_id)[source]¶ -
get
(**params)[source]¶ Returns details for a specific airport.
amadeus.reference_data.location('ALHR').get()
- Return type
- Raises
amadeus.ResponseError – if the request could not be completed
-
-
class
amadeus.reference_data.
Locations
(client)[source]¶ -
get
(**params)[source]¶ Returns details for a specific airport.
from amadeus import Location amadeus.reference_data.locations.get( keyword='lon', subType=Location.ANY )
- Parameters
keyword – keyword that should represent the start of a word in a city or airport name or code
subType – a comma seperate list of location types to search for. You can use
amadeus.Location
as a helper for this.
- Return type
- Raises
amadeus.ResponseError – if the request could not be completed
-
-
class
amadeus.reference_data.locations.
Airports
(client)[source]¶ -
get
(**params)[source]¶ Returns a list of relevant airports near to a given point.
amadeus.reference_data.locations.airports.get( longitude=49.0000, latitude=2.55 )
- Parameters
latitude – latitude of geographic location to search around. For example:
52.5238
longitude – longitude of geographic location to search around. For example:
13.3835
- Return type
- Raises
amadeus.ResponseError – if the request could not be completed
-
-
class
amadeus.reference_data.
Airlines
(client)[source]¶ -
get
(**params)[source]¶ Returns the name of the airline given an IATA code.
amadeus.reference_data.airlines.get(airlineCodes='U2')
- Parameters
airlineCodes – the IATA or ICAO code for the airline, e.g.
:
"AF"
(Air France IATA code) :or"AFR"
(Air France ICAO code)- Return type
- Raises
amadeus.ResponseError – if the request could not be completed
-
ReferenceData/Locations/PointsOfInterest¶
-
class
amadeus.reference_data.locations.
PointsOfInterest
(client)[source]¶ -
get
(**params)[source]¶ Returns a list of relevant point of interests near to a given point.
client.reference_data.locations.points_of_interest.get( longitude=2.160873, latitude=41.397158 )
- Parameters
latitude – latitude of geographic location to search around. For example:
41.397158
longitude – longitude of geographic location to search around. For example:
2.160873
- Return type
- Raises
amadeus.ResponseError – if the request could not be completed
-
-
class
amadeus.reference_data.locations.points_of_interest.
BySquare
(client)[source]¶ -
get
(**params)[source]¶ - Returns a list of relevant point of interests
around a defined square (4 points).
client.reference_data.locations.points_of_interest.by_square.get( north=41.397158, west=2.160873, south=41.394582, east=2.177181 )
- Parameters
north – latitude north of bounding box. For example:
41.397158
west – longitude west of bounding box. For example:
2.160873
south – latitude south of bounding box. For example:
41.394582
east – longitude east of bounding box. For example:
2.177181
- Return type
- Raises
amadeus.ResponseError – if the request could not be completed
-
ReferenceData/Urls¶
-
class
amadeus.reference_data.urls.
CheckinLinks
(client)[source]¶ -
get
(**params)[source]¶ Returns the checkin links for an airline, for the language of your choice
amadeus.reference_data.urls.checkin_links.get(airlineCode='BA')
- Parameters
airlineCode – the IATA code for the airline, e.g.
"BA"
language – the locale for the links, for example
"en-GB"
- Return type
- Raises
amadeus.ResponseError – if the request could not be completed
-
ReferenceData/RecommendedLocations¶
-
class
amadeus.reference_data.
RecommendedLocations
(client)[source]¶ -
get
(**params)[source]¶ Returns a list of destination recommendations
client.reference_data.recommended_locations.get( cityCodes='PAR' travelerCountryCode='FR' )
- Parameters
cityCodes – city used by the algorithm to recommend new destinations For example:
PAR
travelerCountryCode – origin country following IATA standard For example:
FR
- Return type
- Raises
amadeus.ResponseError – if the request could not be completed
-
ReferenceData/Locations/Hotels¶
ReferenceData/Locations/Hotel¶
-
class
amadeus.reference_data.locations.
Hotel
(client)[source]¶ -
get
(**params)[source]¶ Returns a list of hotels matching a given keyword.
amadeus.reference_data.locations.hotel.get( keyword='PARI', subType=[Hotel.HOTEL_LEISURE, Hotel.HOTEL_GDS] )
- Parameters
keyword – location query keyword. For example:
PARI
subType – category of search. For example:
[Hotel.HOTEL_LEISURE, Hotel.HOTEL_GDS]
- Return type
- Raises
amadeus.ResponseError – if the request could not be completed
-
ReferenceData/Locations/Cities¶
-
class
amadeus.reference_data.locations.
Cities
(client)[source]¶ -
get
(**params)[source]¶ Returns cities that match a specific word or letters.
amadeus.reference_data.locations.cities.get( keyword='PARI' )
- Parameters
keyword – location query keyword. For example:
PARI
- Return type
- Raises
amadeus.ResponseError – if the request could not be completed
-
Helper/Location¶
Airport/Predictions¶
-
class
amadeus.airport.predictions.
AirportOnTime
(client)[source]¶ -
get
(**params)[source]¶ Returns a percentage of on-time flight departures
amadeus.airport.predictions.on_time.get( airportCode='JFK', date='2020-09-01')
- Parameters
airportCode – the City/Airport IATA code from which the flight will depart.
"NYC"
, for example for New Yorkdate – the date on which to fly out, in YYYY-MM-DD format
- Return type
- Raises
amadeus.ResponseError – if the request could not be completed
-
Airport/DirectDestinations¶
-
class
amadeus.airport.
DirectDestinations
(client)[source]¶ -
get
(**params)[source]¶ Returns airport direct routes.
amadeus.airport.direct_destinations.get( departureAirportCode='BLR')
- Parameters
departureAirportCode – the departure Airport code following IATA standard.
"BLR"
, for example for Bengaluru- Return type
- Raises
amadeus.ResponseError – if the request could not be completed
-
Media/Files¶
Booking¶
-
class
amadeus.booking.
FlightOrders
(client)[source]¶ -
post
(flight, travelers)[source]¶ Books a flight
amadeus.booking.flight_orders.post(flight, travelers)
- Return type
- Raises
amadeus.ResponseError – if the request could not be completed
-
-
class
amadeus.booking.
FlightOrder
(client, flight_order_id)[source]¶ -
get
(**params)[source]¶ Retrieves a flight order based on its ID.
amadeus.booking.flight_order('eJzTd9f3NjIJdzUGAAp%2fAiY=').get()
- Return type
- Raises
amadeus.ResponseError – if the request could not be completed
-
-
class
amadeus.booking.
FlightOrder
(client, flight_order_id)[source]¶ -
delete
(**params)[source]¶ Deletes a flight order based on its ID.
amadeus.booking.flight_order('eJzTd9f3NjIJdzUGAAp%2fAiY=').delete()
- Return type
- Raises
amadeus.ResponseError – if the request could not be completed
-
-
class
amadeus.booking.
HotelBookings
(client)[source]¶ -
post
(hotel_offer_id, guests, payments)[source]¶ Books a hotel
amadeus.booking.hotel_bookings.post(hotel_offer_id, guests, payments)
The parameters guests and payments can be passed as dictionary or list of dictionaries. If they are dictionary in this method they are converted to a list of dictionaries.
- Return type
- Raises
amadeus.ResponseError – if the request could not be completed
-
Safety/SafetyRatedLocations¶
-
class
amadeus.safety.
SafetyRatedLocations
(client)[source]¶ -
get
(**params)[source]¶ - Returns the overall safety ranking and a detailed safety
ranking of all the districts within the given radius.
amadeus.safety.safety_rated_locations.get( longitude=2.160873, latitude=41.397158 )
- Parameters
latitude – latitude of the location to safety ranking search. For example:
41.397158
longitude – longitude of the location to safety ranking search. For example:
2.160873
- Return type
- Raises
amadeus.ResponseError – if the request could not be completed
-
-
class
amadeus.safety.safety_rated_locations.
BySquare
(client)[source]¶ -
get
(**params)[source]¶ - Returns detailed safety ranking of all the districts
within the designated area.
amadeus.safety.safety_rated_locations.by_square.get( north=41.397158, west=2.160873, south=41.394582, east=2.177181 )
- Parameters
north – latitude north of bounding box. For example:
41.397158
west – longitude west of bounding box. For example:
2.160873
south – latitude south of bounding box. For example:
41.394582
east – longitude east of bounding box. For example:
2.177181
- Return type
- Raises
amadeus.ResponseError – if the request could not be completed
-
Schedule/Flights¶
-
class
amadeus.schedule.
Flights
(client)[source]¶ -
get
(**params)[source]¶ Retrieves a unique flight status by search criteria
amadeus.schedule.flights.get( carrierCode='AZ', flightNumber='319', scheduledDepartureDate='2021-03-13')
- Parameters
carrierCode – the IATA carrier code
flightNumber – flight number as assigned by the carrier
scheduledDepartureDate – scheduled departure date of the flight, local to the departure airport, format YYYY-MM-DD
- Return type
- Raises
amadeus.ResponseError – if the request could not be completed
-
Analytics/ItineraryPriceMetrics¶
-
class
amadeus.analytics.
ItineraryPriceMetrics
(client)[source]¶ -
get
(**params)[source]¶ Returns itinerary price metrics by search criteria
amadeus.analytics.itinerary_price_metrics.get( originIataCode='MAD', destinationIataCode='CDG', departureDate='2021-03-21')
- Parameters
originIataCode – IATA code of the origin city, for example
"BOS"
for Boston.destinationIataCode – IATA code of the destination city, for example
"ATH"
for Athens.departureDate – scheduled departure date of the flight, local to the departure airport, format YYYY-MM-DD
- Return type
- Raises
amadeus.ResponseError – if the request could not be completed
-
Location/Analytics¶
-
class
amadeus.location.analytics.
CategoryRatedAreas
(client)[source]¶ -
get
(**params)[source]¶ Gets popularity score for location categories
amadeus.location.analytics.category_rated_areas.get( latitude=41.397158, longitude=2.160873)
- Parameters
latitude – latitude of geographic location to search around. For example:
41.397158
longitude – longitude of geographic location to search around. For example:
2.160873
- Return type
- Raises
amadeus.ResponseError – if the request could not be completed
-
DutyOfCare/Diseases¶
-
class
amadeus.duty_of_care.diseases.
Covid19Report
(client)[source]¶ -
get
(**params)[source]¶ Returns the Covid-19 restrictions on targeted area.
amadeus.duty_of_care.diseases.covid19_report.get( countryCode='US' )
- Parameters
countryCode – Country code following ISO 3166 Alpha-2 standard, for example
"US"
for United States of America- Return type
- Raises
amadeus.ResponseError – if the request could not be completed
-
Airline/Destinations¶
-
class
amadeus.airline.
Destinations
(client)[source]¶ -
get
(**params)[source]¶ Get airline destinations.
amadeus.airline.destinations.get(airlineCode='BA')
- Parameters
airlineCode – the airline code following IATA standard. Example:
"BA"
- Return type
- Raises
amadeus.ResponseError – if the request could not be completed
-