How to Book a Flight in 5 Minutes Using Amadeus APIs in Postman
This is a guest post written by Anna Tsolakou, developer advocate at Amadeus.
Amadeus is the leading technology provider in the global travel industry—its data and APIs have helped airlines, booking sites, and travel agencies run their businesses for more than 30 years. On the company’s API portal, Amadeus for Developers, everyone from airline development teams to startups can connect to Amadeus services and build their applications.
Amadeus provides a catalog of Self-Service APIs that help developers quickly access essential functionalities like flight booking, hotel booking, or COVID-19 travel restriction data. It’s easy to get started working with Amadeus APIs, and this blog post will show you how to find and book a flight in minutes using the Amadeus for Developers collection in Postman.
Prerequisites
To follow along, you will need the following:
- An Amadeus Self-Service API key: To get one, create a free account, log in, and create a new app in your Self-Service Workspace
- Postman: Download the app or use the web version
- Fork the Amadeus for Developers Postman public workspace:
Understanding the flight booking flow
To book a flight with Amadeus Self-Service APIs, you’ll need to use three interconnected APIs that each serve a key function in the flight booking process:
- Flight Offer Search: Search for the cheapest flights matching given search criteria
- Flight Offer Price: Confirm that a given flight is available to book at the quoted price
- Flight Create Orders: Book a given flight and get a booking reference number
That’s it! Now that you have your environment set up and are familiar with the booking flow, let’s go over how to easily book a flight step by step.
Step 1: Getting your access token
First, generate your access token in Postman by following the steps in this guide. Note that the access token expires after 30 minutes, so you’ll need to make sure to generate a new one when needed.
Step 2: Searching for flights
Once you have your access token, you can search for flights using Flight Offer Search. The API supports the GET
methods for simple queries and also the POST
methods for more advanced searches. To keep it simple in this example, let’s call the GET
method.
Within the Amadeus for Developers collection, go to the Flight Offers Search under the Air/Search & Shopping category. Thanks to the Postman UI, it’s simple to add the query parameters and perform the search. Add the parameters to search for direct flights from Madrid to Athens on February 1, 2022, as shown below:
The API returns a list of flight offers matching your parameters, with details like schedule information, carrier information, and pricing. The API provides a comprehensive list of flights matching the search criteria, but for the sake of this tutorial, you’ll focus on the first result:
{
"type":"flight-offer",
"id":"1",
"source":"GDS",
"instantTicketingRequired":false,
"nonHomogeneous":false,
"oneWay":false,
"lastTicketingDate":"2021-10-26",
"numberOfBookableSeats":9,
"itineraries":[
{
"duration":"PT3H35M",
"segments":[
{
"departure":{
"iataCode":"MAD",
"terminal":"4",
"at":"2022-02-01T10:40:00"
},
"arrival":{
"iataCode":"ATH",
"at":"2022-02-01T15:15:00"
},
"carrierCode":"IB",
"number":"3150",
"aircraft":{
"code":"320"
},
"operating":{
"carrierCode":"IB"
},
"duration":"PT3H35M",
"id":"2",
"numberOfStops":0,
"blacklistedInEU":false
}
]
}
],
"price":{
"currency":"EUR",
"total":"71.95",
"base":"53.00",
"fees":[
{
"amount":"0.00",
"type":"SUPPLIER"
},
{
"amount":"0.00",
"type":"TICKETING"
}
],
"grandTotal":"71.95",
"additionalServices":[
{
"amount":"28.00",
"type":"CHECKED_BAGS"
}
]
},
"pricingOptions":{
"fareType":[
"PUBLISHED"
],
"includedCheckedBagsOnly":false
},
"validatingAirlineCodes":[
"IB"
],
"travelerPricings":[
{
"travelerId":"1",
"fareOption":"STANDARD",
"travelerType":"ADULT",
"price":{
"currency":"EUR",
"total":"71.95",
"base":"53.00"
},
"fareDetailsBySegment":[
{
"segmentId":"2",
"cabin":"ECONOMY",
"fareBasis":"ADLNAOB4",
"brandedFare":"NOBAG",
"class":"A",
"includedCheckedBags":{
"quantity":0
}
}
]
}
]
}
Step 3: Confirming flight price and availability
Now that you’ve found a flight, the next step is to call Flight Offer Price to confirm the fare price and availability. This step is important because you don’t want to accidentally book a more expensive fare.
Within the Amadeus for Developers collection, go to the Flight Offers Price API under the Air/Search & Shopping category and pass the previous flight offer within the body of the request as follows:
Flight Offers Price will then return a confirmation that the fare is available at the quoted price and a list of the documents and information required to book the flight. If the price has changed, the API returns a warning and a flight offer with the updated price.
Step 4: Booking the flight
Now that you’ve confirmed the fare availability, you can book the flight using Flight Create Orders. Within the Amadeus for Developers collection, go to Flight Create Orders in the Air/Booking category. Pass the confirmed flight offer from the response of Flight Offers Price into the body of the request, as shown below.
Note that you’ll also have to include the passenger information required by the airlines.
Flight Create Orders will book the flight and return the flight itself and the PNR (Passenger Name Record), or booking reference:
{
"type":"flight-order",
"id":"eJzTd9cPinD39fYBAAu6Ans%3D",
"associatedRecords":[
{
"reference":"RXGMKL",
"creationDate":"2021-10-25T14:49:00.000",
"originSystemCode":"GDS",
"flightOfferId":"1"
}
]
}
Conclusion
You’ve just searched, confirmed, and booked your first flight using Amadeus Self-Service APIs in Postman. Now that you know how it works, you can start building in your own programming environment—or keep exploring our Postman Collection and testing other APIs for booking hotels or finding things to see and do in your destination. If you have any questions or suggestions along the way, feel free to get in touch with our Amadeus developer relations team.
Technical review by Arlemi Turpault.
Please i did my offer search but dont know how to copy and paste the flight information can you help please. thank you