Amadeus provides a set of APIs for the travel industry. Flights, Hotels, Locations and more.
For more details see the Java documentation on Amadeus.com.
This library requires Java 1.7+. You can install install it via Maven or Gradle.
<dependency>
<groupId>com.amadeus</groupId>
<artifactId>amadeus-java</artifactId>
<version>1.0.0</version>
</dependency>compile "com.amadeus:amadeus-java:1.0.0"To send make your first API call you will need to register for an Amadeus Developer Account and set up your first application.
import com.amadeus.Amadeus;
import com.amadeus.Params;
import com.amadeus.exceptions.ResponseException;
import com.amadeus.referenceData.Locations;
import com.amadeus.resources.Location;
public class AmadeusExample {
public static void main(String[] args) throws ResponseException {
Amadeus amadeus = Amadeus
.builder("[client_id]", "[client_secret]")
.build();
Location[] locations = amadeus.referenceData.locations.get(Params
.with("keyword", "LON")
.and("subType", Locations.ANY));
System.out.println(locations);
}
}The client can be initialized directly.
//Initialize using parameters
Amadeus amadeus = Amadeus
.builder("[client_id]", "[client_secret]")
.build();Alternatively it can be initialized without any parameters if the environment
variables AMADEUS_CLIENT_ID and AMADEUS_CLIENT_SECRET are present.
Amadeus amadeus = Amadeus
.builder(System.getenv())
.build();Your credentials can be found on the Amadeus dashboard. Sign up for an account today.
By default the environment for the SDK is the test environment. To switch to
a production (paid-for) environment please switch the hostname as follows:
Amadeus amadeus = Amadeus
.builder(System.getenv())
.setHostname("production")
.build();Amadeus has a large set of APIs, and our documentation is here to get you started today. Head over to our Reference documentation for in-depth information about every SDK method, its arguments and return types.
This library conveniently maps every API path to a similar path.
For example, GET /v2/reference-data/urls/checkin-links?airline=1X would be:
amadeus.referenceData.urls.checkinLinks.get(Params.with("airline", "1X"));Similarly, to select a resource by ID, you can pass in the ID to the singular path.
For example, GET /v1/shopping/hotel/ABC123/offers/DEF234 would be:
amadeus.hotel("ABC123").offer("DEF234").get(...);You can make any arbitrary API call as well directly with the .get method.
Keep in mind, this returns a raw Resource
Resource resource = amadeus.get('/v2/reference-data/urls/checkin-links',
Params.with("airline", "1X"));
resource.getResult();Every successful API call returns a Resource object. The underlying
Resource with the raw available.
Location[] locations = amadeus.referenceData.locations.get(Params
.with("keyword", "LON")
.and("subType", Locations.ANY));
// The raw response, as a string
locations[0].getResponse().getBody();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 page
Location[] locations = (Location[]) amadeus.next(locations[0]);If a page is not available, the method will return null.
The SDK makes it easy to add your own logger.
require 'logger'
amadeus = Amadeus::Client.new(
client_id: '...',
client_secret: '...',
logger: Logger.new(STDOUT)
)Additionally, to enable more verbose logging, you can set the appropriate level
on your own logger, though the easiest way would be to enable debugging via a
parameter on initialization, or using the AMADEUS_LOG_LEVEL environment
variable.
Amadeus amadeus = Amadeus
.builder("[client_id]", "[client_secret]")
.setLogLevel("debug") // or warn
.build();// Flight Cheapest Date Search
FlightDate[] flightDates = amadeus.shopping.flightDates.get(Params
.with("origin", "NCE")
.and("destination", "PAR")
.and("duration", 1));
// Flight Inspiration Search
FlightDestination[] flightDestinations = amadeus.shopping.flightDestinations.get(Params
.with("origin", "MAD"));
// Flight Low-fare Search
FlightOffer[] flightOffers = amadeus.shopping.flightOffers.get(Params
.with("origin", "MAD")
.and("destination", "OPO")
.and("departureDate", "2018-07-08"));
// Flight Check-in Links
CheckinLink[] checkinLinks = amadeus.referenceData.urls.checkinLinks.get(Params
.with("airline", "1X"));
// 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 id
Location location = amadeus.referenceData
.location("ALHR").get();
// Airport Nearest Relevant
Location[] locations = amadeus.referenceData.locations.airports.get(Params
.with("latitude", 49.0000)
.and("longitude", 2.55));
// Flight Most Searched Destinations
FareSearch[] fareSearches = amadeus.travel.analytics.fareSearches.get(Params
.with("origin", "SFO")
.and("sourceCountry", "US")
.and("period", "2017-08"));
// Flight Most Traveled Destinations
AirTraffic[] airTraffics = amadeus.travel.analytics.airTraffic.traveled.get(Params
.with("origin", "NCE")
.and("period", "2017-08"));
// Hotel Search API
// Get list of hotels by cityCode
HotelOffer[] offers = amadeus.shopping.hotelOffers.get(Params
.with("cityCode", "PAR"));
// Get list of offers for a specific hotel
HotelOffer offer = amadeus.shopping
.hotel("SMPARCOL")
.hotelOffers.get();
// Confirm the availability of a specific offer for a specific hotel
Offer offer = amadeus.shopping
.hotel("SMPARCOL")
.offer("4BA070CE929E135B3268A9F2D0C51E9D4A6CF318BA10485322FA2C7E78C7852E").get();Want to contribute? Read our Contributors Guide for guidance on installing and running this code in a development environment.
This library is released under the MIT License.
Our developer support team is here to help you. You can find us on StackOverflow and email.