Skip to content
This repository was archived by the owner on Jul 17, 2026. It is now read-only.

Repository files navigation

Amadeus Java SDK

BuildDiscord

Amadeus provides a rich set of APIs for the travel industry. For more details, check out the Amadeus for Developers Portal or the SDK class reference.

Installation

This library requires Java 1.7+ and the Gson library. You can install the SDK via Maven or Gradle:

Maven

<dependency>
<groupId>com.amadeus</groupId>
<artifactId>amadeus-java</artifactId>
<version>10.0.0</version>
</dependency>

Gradle

compile"com.amadeus:amadeus-java:10.0.0"

Getting Started

To make your first API call, you will need to register for an Amadeus Developer Account and set up your first application.

importcom.amadeus.Amadeus;
importcom.amadeus.Params;
importcom.amadeus.exceptions.ResponseException;
importcom.amadeus.referenceData.Locations;
importcom.amadeus.resources.Location;
publicclassAmadeusExample {
publicstaticvoidmain(String[] args) throwsResponseException {
Amadeusamadeus = Amadeus
.builder("REPLACE_BY_YOUR_API_KEY", "REPLACE_BY_YOUR_API_SECRET")
.build();
Location[] locations = amadeus.referenceData.locations.get(Params
.with("keyword", "LON")
.and("subType", Locations.ANY));
System.out.println(locations);
}
}

Examples

You can find all the endpoints in self-contained code examples.

Initialization

The client can be initialized directly:

//Initialize using parametersAmadeusamadeus = Amadeus
.builder("REPLACE_BY_YOUR_API_KEY", "REPLACE_BY_YOUR_API_SECRET")
.build();

Alternatively, it can be initialized without any parameters if the environment variables AMADEUS_CLIENT_ID and AMADEUS_CLIENT_SECRET are present.

Amadeusamadeus = Amadeus
.builder(System.getenv())
.build();

Your credentials can be found on the Amadeus dashboard.

By default the SDK is set to test environment. To switch to a production (pay-as-you-go) environment, please switch the hostname as follows:

Amadeusamadeus = Amadeus
.builder(System.getenv())
.setHostname("production")
.build();

Documentation

Amadeus has a large set of APIs, and our documentation is here to get you started. Head over to our reference documentation for in-depth information about every SDK method, its arguments and return types.

Making API calls

This library conveniently maps every API path to a similar path. For example, GET /v2/reference-data/urls/checkin-links?airlineCode=BA would be:

amadeus.referenceData.urls.checkinLinks.get(Params.with("airlineCode", "BA"));

Similarly, to select a resource by ID, you can pass in the ID to the singular path. For example, GET v1/reference-data/locations/pois would be:

amadeus.referenceData.locations.pointOfInterest("9CB40CB5D0").get();

You can make any arbitrary API call as well directly with the .get method. Keep in mind, this returns a raw Resource.

Responseresponse = amadeus.get("/v2/reference-data/urls/checkin-links", Params.with("airlineCode", "BA"));
response.getResult();

Or, with POST method:

Responseresponse = amadeus.post("/v1/shopping/availability/flight-availabilities", body);

Response

Every successful API call returns a Resource object. The Resource object has the raw response body (in string format) available:

Location[] locations = amadeus.referenceData.locations.get(Params
.with("keyword", "LON")
.and("subType", Locations.ANY));
// The raw response, as a stringlocations[0].getResponse().getBody();

Pagination

If an API endpoint supports pagination, the other pages are available under the .next, .previous, .last and .first methods.

Location[] locations = amadeus.referenceData.locations.get(Params
.with("keyword", "LON")
.and("subType", Locations.ANY));
// Fetches the next pageLocation[] locations = (Location[]) amadeus.next(locations[0]);

If a page is not available, the method will return null.

Logging & Debugging

The SDK makes it easy to add your own logger.

importjava.util.logging.Logger;
// Assumes the current class is called MyLoggerprivatefinalstaticLoggerLOGGER = Logger.getLogger(MyLogger.class.getName());
...
Amadeusamadeus = Amadeus
.builder("REPLACE_BY_YOUR_API_KEY", "REPLACE_BY_YOUR_API_SECRET")
.setLogger(LOGGER)
.build();
)

Additionally, to enable more verbose logging, you can set the appropriate level on your own logger. The easiest way would be to enable debugging via a parameter during initialization, or using the AMADEUS_LOG_LEVEL environment variable.

Amadeusamadeus = Amadeus
.builder("REPLACE_BY_YOUR_API_KEY", "REPLACE_BY_YOUR_API_SECRET")
.setLogLevel("debug") // or warn
.build();

List of supported endpoints

// Flight Inspiration SearchFlightDestination[] flightDestinations = amadeus.shopping.flightDestinations.get(Params
.with("origin", "MAD"));
// Flight Cheapest Date SearchFlightDate[] flightDates = amadeus.shopping.flightDates.get(Params
.with("origin", "MAD")
.and("destination", "MUC"));
// Flight Offers Search v2 GETFlightOfferSearch[] flightOffersSearches = amadeus.shopping.flightOffersSearch.get(
Params.with("originLocationCode", "SYD")
.and("destinationLocationCode", "BKK")
.and("departureDate", "2023-11-01")
.and("returnDate", "2023-11-08")
.and("adults", 2)
.and("max", 3));
// Flight Offers Search v2 POST// body can be a String version of your JSON or a JsonObjectFlightOfferSearch[] flightOffersSearches = amadeus.shopping.flightOffersSearch.post(body);
// Flight Order Management// The flightOrderID comes from the Flight Create Orders (in test environment it's temporary)// Retrieve a flight orderFlightOrderorder = amadeus.booking.flightOrder("eJzTd9f3NjIJdzUGAAp%2fAiY=").get();
// Cancel a flight orderResponseorder = amadeus.booking.flightOrder("eJzTd9f3NjIJdzUGAAp%2fAiY=").delete();
// Flight Offers priceFlightPrice[] flightPricing = amadeus.shopping.flightOffersSearch.pricing.post(
body,
Params.with("include", "other-services")
.and("forceClass", "false"));
// Flight Choice Prediction// Note that the example calls 2 APIs: Flight Offers Search & Flight Choice PredictionFlightOfferSearch[] flightOffers = amadeus.shopping.flightOffersSearch.get(
Params.with("originLocationCode", "NYC")
.and("destinationLocationCode", "MAD")
.and("departureDate", "2024-04-01")
.and("returnDate", "2024-04-08")
.and("adults", 1));
// Using a JSonObjectJsonObjectresult = flightOffers[0].getResponse().getResult();
FlightOfferSearch[] flightOffersPrediction = amadeus.shopping.flightOffers.prediction.post(result);
// Using a StringStringbody = flightOffers[0].getResponse().getBody();
FlightOfferSearch[] flightOffersPrediction = amadeus.shopping.flightOffers.prediction.post(body);
// Flight Check-in LinksCheckinLink[] checkinLinks = amadeus.referenceData.urls.checkinLinks.get(Params
.with("airlineCode", "BA"));
// Airline Code LookUpAirline[] airlines = amadeus.referenceData.airlines.get(Params
.with("airlineCodes", "BA"));
// Airport & City Search (autocomplete)// Find all the cities and airports starting by the keyword 'LON'Location[] locations = amadeus.referenceData.locations.get(Params
.with("keyword", "LON")
.and("subType", Locations.ANY));
// Get a specific city or airport based on its idLocationlocation = amadeus.referenceData
.location("ALHR").get();
// Airport Nearest Relevant (for London)Location[] locations = amadeus.referenceData.locations.airports.get(Params
.with("latitude", 0.1278)
.and("longitude", 51.5074));
// City SearchCity[] cities = amadeus.referenceData.locations.cities.get(Params
.with("keyword","PARIS"));
// Flight Most Booked DestinationsAirTraffic[] airTraffics = amadeus.travel.analytics.airTraffic.booked.get(Params
.with("originCityCode", "MAD")
.and("period", "2017-08"));
// Flight Most Traveled DestinationsAirTraffic[] airTraffics = amadeus.travel.analytics.airTraffic.traveled.get(Params
.with("originCityCode", "MAD")
.and("period", "2017-01"));
// Flight Busiest Traveling PeriodPeriod[] busiestPeriods = amadeus.travel.analytics.airTraffic.busiestPeriod.get(Params
.with("cityCode", "MAD")
.and("period", "2017")
.and("direction", BusiestPeriod.ARRIVING));
// Points of Interest// What are the popular places in Barcelona (based a geo location and a radius)PointOfInterest[] pointsOfInterest = amadeus.referenceData.locations.pointsOfInterest.get(Params
.with("latitude", "41.39715")
.and("longitude", "2.160873"));
// What are the popular places in Barcelona? (based on a square)PointOfInterest[] pointsOfInterest = amadeus.referenceData.locations.pointsOfInterest.bySquare.get(Params
.with("north", "41.397158")
.and("west", "2.160873")
.and("south", "41.394582")
.and("east", "2.177181"));
// Returns a single Point of Interest from a given idPointOfInterestpointOfInterest = amadeus.referenceData.locations.pointOfInterest("9CB40CB5D0").get();
// Tours and Activities// What are the popular activities in Barcelona (based a geo location and a radius)Activity[] activities = amadeus.shopping.activities.get(Params
.with("latitude", "41.39715")
.and("longitude", "2.160873"));
// What are the popular activities in Barcelona? (based on a square)Activity[] activities = amadeus.shopping.activities.bySquare.get(Params
.with("north", "41.397158")
.and("west", "2.160873")
.and("south", "41.394582")
.and("east", "2.177181"));
// Returns a single activity from a given idActivityactivity = amadeus.shopping.activity("4615").get();
// What's the likelihood flights from this airport will leave on time?PredictionAirportOnTime = amadeus.airport.predictions.onTime.get(Params
.with("airportCode", "NCE")
.and("date", "2024-04-01"));
// What's the likelihood of a given flight to be delayed?Prediction[] flightDelay = amadeus.travel.predictions.flightDelay.get(Params
.with("originLocationCode", "NCE")
.and("destinationLocationCode", "IST")
.and("departureDate", "2020-08-01")
.and("departureTime", "18:20:00")
.and("arrivalDate", "2020-08-01")
.and("arrivalTime", "22:15:00")
.and("aircraftCode", "321")
.and("carrierCode", "TK")
.and("flightNumber", "1816")
.and("duration", "PT31H10M"));
// Flight Create Orders to book a flight// Using a JSonObject or StringFlightOrdercreatedOrder = amadeus.booking.flightOrders.post(body);
// Using a JsonObject for flight offer and Traveler[] as traveler information// see example at src/main/java/examples/flight/createorders/FlightCreateOrders.javaFlightOrdercreatedOrder = amadeus.booking.flightOrders.post(flightOffersSearches, travelerArray);
// What is the the seat map of a given flight?SeatMap[] seatmap = amadeus.shopping.seatMaps.get(Params
.with("flight-orderId", "eJzTd9f3NjIJdzUGAAp%2fAiY="));
// What is the the seat map of a given flight?// The body can be a String version of your JSON or a JsonObjectSeatMap[] seatmap = amadeus.shopping.seatMaps.post(body);
// Trip Purpose PredictionPredictiontripPurpose = amadeus.travel.predictions.tripPurpose.get(Params
.with("originLocationCode", "NYC")
.and("destinationLocationCode", "MAD")
.and("departureDate", "2024-04-01")
.and("returnDate", "2024-04-08"));
// Travel RecommendationsLocationdestinations = amadeus.referenceData.recommendedLocations.get(Params
.with("cityCodes", "PAR")
.and("travelerCountryCode", "FR"));
// On Demand Flight StatusDatedFlight[] flightStatus = amadeus.schedule.flights.get(Params
.with("carrierCode", "AZ")
.and("flightNumber", "319")
.and("scheduledDepartureDate", "2024-03-13"));
// Flight Price AnalysisItineraryPriceMetric[] metrics = amadeus.analytics.itineraryPriceMetrics.get(Params
.with("originIataCode", "MAD")
.and("destinationIataCode", "CDG")
.and("departureDate", "2024-03-21"));
// Airport RoutesDestination[] directDestinations = amadeus.airport.directDestinations.get(Params
.with("departureAirportCode","MAD")
.and("max","2"));
// Flight Availabilites Search POST// body can be a String version of your JSON or a JsonObjectFlightAvailability[] flightAvailabilities
= amadeus.shopping.availability.flightAvailabilities.post(body);
// Location Score GETScoredLocation[] scoredLocations
= amadeus.location.analytics.categoryRatedAreas.get(Params
.with("latitude", "41.397158")
.and("longitude", "2.160873"));
// Branded Fares Upsell Post// body can be a String version of your JSON or a JsonObjectFlightOfferSearch[] upsellFlightOffers
= amadeus.shopping.flightOffers.upselling.post(body);
// Hotel List// Get list of hotels by hotel idHotel[] hotels = amadeus.referenceData.locations.hotels.byHotels.get(Params
.with("hotelIds", "ADPAR001"));
// Get list of hotels by city codeHotel[] hotels = amadeus.referenceData.locations.hotels.byCity.get(Params
.with("cityCode", "PAR"));
// Get list of hotels by a geocodeHotel[] hotels = amadeus.referenceData.locations.hotels.byGeocode.get(Params
.with("longitude", 2.160873)
.and("latitude", 41.397158));
// Hotel autocomplete namesHotel[] result = amadeus.referenceData.locations.hotel.get(Params
.with("keyword", "PARI")
.and("subType", "HOTEL_GDS")
.and("countryCode", "FR")
.and("lang", "EN")
.and("max", "20"));
// Hotel Offers Search API v3// Get multiple hotel offersHotelOfferSearch[] offers = amadeus.shopping.hotelOffersSearch.get(Params
.with("hotelIds", "MCLONGHM")
.and("adults", 1)
.and("checkInDate", "2023-11-22")
.and("roomQuantity", 1)
.and("paymentPolicy", "NONE")
.and("bestRateOnly", true));
// Get hotel offer pricing by offer idHotelOfferSearchoffer = amadeus.shopping.hotelOfferSearch("QF3MNOBDQ8").get();
// Hotel Booking// The body can be a String version of your JSON or a JsonObjectHotelBooking[] hotel = amadeus.booking.hotelBookings.post(body);
// Hotel Booking v2HotelOrderhotel = amadeus.booking.hotelOrders.post(body);
// Hotel Ratings / SentimentsHotelSentiment[] hotelSentiments = amadeus.ereputation.hotelSentiments.get(Params.with("hotelIds", "ELONMFS,ADNYCCTB"));
// Airline Routes// Get airline destinationsDestination[] destinations = amadeus.airline.destinations.get(Params
.with("airlineCode", "BA")
.and("max", 2));
// Transfer SearchTransferOffersPost[] transfers = amadeus.shopping.transferOffers.post(body);
// Transfer BookingTransferOrdertransfers = amadeus.ordering.transferOrders.post(body, params);
// Transfer ManagementTransferCancellationtransfers = amadeus.ordering.transferOrder("123456").transfers.cancellation.post(params);

Development & Contributing

Want to contribute? Read our Contributors Guide for guidance on installing and running this code in a development environment.

License

This library is released under the MIT License.

Help

You can find us on StackOverflow or join our developer community on Discord.

Releases

Packages

Used by

Contributors

Languages