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

Repository files navigation

Amadeus Ruby SDK

Gem VersionBuild StatusMaintainabilityDependenciesDiscord

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.

⚠️ Important message ⚠️

❗ This SDK is maintained by the developer community only. The Amadeus for Developers team doesn't support or maintain it. ❗

Installation

This gem requires Ruby 2.5+. You can install it directly or via bundler.

Command line

gem install amadeus

Bundler

gem'amadeus'

Getting Started

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

require'amadeus'amadeus=Amadeus::Client.new({client_id: 'REPLACE_BY_YOUR_API_KEY',client_secret: 'REPLACE_BY_YOUR_API_SECRET'})beginputsamadeus.shopping.flight_offers_search.get(originLocationCode: 'NYC',destinationLocationCode: 'MAD',departureDate: '2021-05-01',adults: 1,max: 1).bodyrescueAmadeus::ResponseError=>errorputserrorend

Initialization

The client can be initialized directly.

# Initialize using parametersamadeus=Amadeus::Client.new(client_id: 'REPLACE_BY_YOUR_API_KEY',client_secret: 'REPLACE_BY_YOUR_API_SECRET')

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

amadeus=Amadeus::Client.new

Your credentials can be found on the Amadeus dashboard.

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

amadeus=Amadeus::Client.new(hostname: :production)

Documentation

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.

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.reference_data.urls.checkin_links.get(airlineCode: 'BA')

Similarly, to select a resource by ID, you can pass in the ID to the singular path. For example, GET /v2/shopping/hotel-offers/XZY would be:

amadeus.shopping.hotel_offer('XZY').get

You can make any arbitrary API call as well directly with the .get method:

amadeus.get('/v2/reference-data/urls/checkin-links',airlineCode: 'BA')

Response

Every API call returns a Amadeus::Response object. If the API call contained a JSON response, it will parse the JSON into .result attribute. If this data also contains a data key, that will be made available in .data attribute. The raw body of the response is always available in .body attribute.

response=amadeus.reference_data.locations.get(keyword: 'LON',subType: Amadeus::Location::ANY)presponse.body#=> The raw response, as a stringpresponse.result#=> The body parsed as JSON, if the result was parsablepresponse.data#=> The list of locations, extracted from the JSON

Pagination

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

response=amadeus.reference_data.locations.get(keyword: 'LON',subType: Amadeus::Location::ANY)amadeus.next(response)#=> returns a new response for the next page

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

Logging & Debugging

The SDK makes it easy to add your own logger.

require'logger'amadeus=Amadeus::Client.new(client_id: 'REPLACE_BY_YOUR_API_KEY',client_secret: 'REPLACE_BY_YOUR_API_SECRET',logger: Logger.new(STDOUT))

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 on initialization, or using the AMADEUS_LOG_LEVEL environment variable.

require'logger'amadeus=Amadeus::Client.new(client_id: 'REPLACE_BY_YOUR_API_KEY',client_secret: 'REPLACE_BY_YOUR_API_SECRET',log_level: 'debug'# or "warn" or "silent", defaults to "silent")

List of supported endpoints

# Flight Inspiration Searchamadeus.shopping.flight_destinations.get(origin: 'MAD')# Flight Cheapest Date Searchamadeus.shopping.flight_dates.get(origin: 'MAD',destination: 'MUC')# Flight Offers Searchamadeus.shopping.flight_offers_search.get(originLocationCode: 'NYC',destinationLocationCode: 'MAD',departureDate: '2021-05-01',adults: 1)# Flight Choice Prediction / Be careful, this example combines 2 API calls: 1. Flight Offers Search then Flight Choice Predictionflight_offers=amadeus.shopping.flight_offers_search.get(originLocationCode: 'NYC',destinationLocationCode: 'MAD',departureDate: '2021-05-01',adults: 1,max: 1).bodyamadeus.shopping.flight_offers_search.prediction.post(flight_offers)# Flight Delay Predictionamadeus.travel.predictions.flight_delay.get(originLocationCod: 'NCE',destinationLocationCod: 'IST',departureDat: '2021-05-01',departureTim: '18:20:00',arrivalDat: '2020-08-01',arrivalTim: '22:15:00',aircraftCod: '321',carrierCod: 'TK',flightNumber: '1816',duration: 'PT31H10M')# Flight Check-in Linksamadeus.reference_data.urls.checkin_links.get(airlineCode: 'BA')# Airline Code Lookupamadeus.reference_data.airlines.get(airlineCodes: 'U2')# Airport & City Search (autocomplete)# Find all the cities and airports starting by the keyword 'LON'amadeus.reference_data.locations.get(keyword: 'LON',subType: Amadeus::Location::ANY)# Get a specific city or airport based on its idamadeus.reference_data.location('ALHR').get# Airport Nearest Relevant (for London)amadeus.reference_data.locations.airports.get(longitude: 0.1278,latitude: 51.5074)# Flight Most Booked Destinationsamadeus.travel.analytics.air_traffic.booked.get(originCityCode: 'MAD',period: '2017-08')# Flight Most Traveled Destinationsamadeus.travel.analytics.air_traffic.traveled.get(originCityCode: 'MAD',period: '2017-01')# Flight Busiest Periodamadeus.travel.analytics.air_traffic.busiest_period.get(cityCode: 'MAD',period: '2017',direction: Amadeus::Direction::ARRIVING)# Hotel Search# Get list of hotels by cityCodeamadeus.shopping.hotel_offers.get(cityCode: 'MAD')# Get list of offers for a specific hotelamadeus.shopping.hotel_offers_by_hotel.get(hotelId: 'IALONCHO')# Confirm the availability of a specific offeramadeus.shopping.hotel_offer('D5BEE9D0D08B6678C2F5FAD910DC110BCDA187D21D4FCE68ED423426D0A246BB').get# Hotel Booking# The offerId comes from the hotel_offer aboveamadeus.booking.hotel_bookings.post(offerId,guests,payments)# Hotel Ratings# What are the reviews for the Holiday INN Manhattan and the Hilton London Paddingtonamadeus.e_reputation.hotel_sentiments.get(hotelIds: 'SJNYCAJA,TELONMFS')# Points of Interest# What are the popular places in Barcelona (based a geo location and a radius)amadeus.reference_data.locations.points_of_interest.get(latitude: 41.397158,longitude: 2.160873)# What are the popular places in Barcelona? (based on a square)amadeus.reference_data.locations.points_of_interest.by_square.get(north: 41.397158,west: 2.160873,south: 41.394582,east: 2.177181)# Returns a single Point of Interest from a given idamadeus.reference_data.locations.point_of_interest('9CB40CB5D0').get()# Safe Place# How safe is Barcelona? (based a geo location and a radius)amadeus.safety.safety_rated_locations.get(latitude: 41.397158,longitude: 2.160873)# How safe is Barcelona? (based on a square)amadeus.safety.safety_rated_locations.by_square.get(north: 41.397158,west: 2.160873,south: 41.394582,east: 2.177181)# What is the safety information of a location based on it's Id?amadeus.safety.safety_rated_location('Q930402753').get()# Airport On-Time Performanceamadeus.airport.predictions.on_time.get(airportCode: 'JFK',date: '2020-08-01')# Flight Price Analysisamadeus.analytics.itinerary_price_metrics.get(originIataCode: 'AMS',destinationIataCode: 'CDG',departureDate: '2021-08-18')# Trip Purpose Predictionamadeus.travel.predictions.trip_purpose.get(originLocationCode: 'ATH',destinationLocationCode: 'MAD',departureDate: '2020-08-01',returnDate: '2020-08-12',searchDate: '2020-06-11')

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.

About

Ruby library for the Amadeus Self-Service travel APIs

Topics

Resources

Code of conduct

Contributing

Stars

16 stars

Watchers

3 watching

Forks

Releases

Packages

Used by

Contributors

Languages