Skip to content

Code Examples

To help you get up and running with the Amadeus Self-Service APIs as smoothly as possible, we have provided code examples for each SDK and API endpoint. Simply copy and paste these examples into your project to make API requests.

If you have any questions or ideas for improvement, don't hesitate to raise an issue or a pull request directly from GitHub examples repository.

Flights

Airline Routes

# Install the Python library from https://pypi.org/project/amadeus
from amadeus import Client, ResponseError

amadeus = Client(
    client_id='YOUR_AMADEUS_API_KEY',
    client_secret='YOUR_AMADEUS_API_SECRET'
)

try:
    '''
    What are the destinations served by the British Airways (BA)?
    '''
    response = amadeus.airline.destinations.get(airlineCode='BA')
    print(response.data)
except ResponseError as error:
    raise error
const Amadeus = require("amadeus");

const amadeus = new Amadeus({
  clientId: "YOUR_AMADEUS_API_KEY",
  clientSecret: "YOUR_AMADEUS_API_SECRET",
});
// Or `const amadeus = new Amadeus()` if the environment variables are set

async function main() {
  try {
    // What are the destinations served by the British Airways (BA)?
    const response = await amadeus.airline.destinations.get({
      airlineCode: "BA",
    });

    console.log(response);
  } catch (error) {
    console.error(error);
  }
}

main();
// How to install the library at https://github.com/amadeus4dev/amadeus-java
import com.amadeus.Amadeus;
import com.amadeus.exceptions.ResponseException;
import com.amadeus.resources.Destination;

// What are the destinations served by the British Airways (BA)?
public class AirlineRoutes {
  public static void main(String[] args) throws ResponseException {

    Amadeus amadeus = Amadeus
        .builder("YOUR_AMADEUS_API_KEY", "YOUR_AMADEUS_API_SECRET")
        .build();

    // Set query parameters
    Params params = Params
        .with("airlineCode", "BA");

    // Run the query
    Destination[] destinations = amadeus.airline.destinations.get(params);

    if (destinations[0].getResponse().getStatusCode() != 200) {
      System.out.println("Wrong status code: " + destinations[0].getResponse().getStatusCode());
      System.exit(-1);
    }

    System.out.println(destinations[0]);
  }
}

Airport Routes

# Install the Python library from https://pypi.org/project/amadeus
from amadeus import Client, ResponseError

amadeus = Client(
    client_id='YOUR_AMADEUS_API_KEY',
    client_secret='YOUR_AMADEUS_API_SECRET'
)

try:
    '''
    What are the destinations served by MAD airport?
    '''
    response = amadeus.airport.direct_destinations.get(departureAirportCode='MAD')
    print(response.data)
except ResponseError as error:
    raise error
const Amadeus = require("amadeus");

const amadeus = new Amadeus({
  clientId: "YOUR_API_KEY",
  clientSecret: "YOUR_API_SECRET",
});

async function main() {
  try {
    // Find all destinations served by CDG Airport
    const response = await amadeus.airport.directDestinations.get({
      departureAirportCode: "MAD",
    });

    console.log(response);
  } catch (error) {
    console.error(error);
  }
}

main();
// How to install the library at https://github.com/amadeus4dev/amadeus-java

import com.amadeus.Amadeus;
import com.amadeus.Params;
import com.amadeus.exceptions.ResponseException;
import com.amadeus.resources.Destination;

public class AirportRoutes {

  public static void main(String[] args) throws ResponseException {
    Amadeus amadeus = Amadeus
      .builder("YOUR_AMADEUS_API_KEY", "YOUR_AMADEUS_API_SECRET")
      .build();

    Destination[] directDestinations = amadeus.airport.directDestinations.get(
      Params.with("departureAirportCode", "MAD"));

    if (directDestinations[0].getResponse().getStatusCode() != 200) {
      System.out.println("Wrong status code: " + directDestinations[0].getResponse().getStatusCode());
      System.exit(-1);
    }

    System.out.println(directDestinations[0]);
  }
}

GET

# Install the Python library from https://pypi.org/project/amadeus
from amadeus import Client, ResponseError

amadeus = Client(
    client_id='YOUR_AMADEUS_API_KEY',
    client_secret='YOUR_AMADEUS_API_SECRET'
)

try:
    '''
    Find the cheapest flights from SYD to BKK
    '''
    response = amadeus.shopping.flight_offers_search.get(
        originLocationCode='SYD', destinationLocationCode='BKK', departureDate='2022-07-01', adults=1)
    print(response.data)
except ResponseError as error:
    raise error
const Amadeus = require("amadeus");

const amadeus = new Amadeus({
  clientId: "YOUR_API_KEY",
  clientSecret: "YOUR_API_SECRET",
});

async function main() {
  try {
    // Find the cheapest flights from SYD to BKK
    const response = await amadeus.shopping.flightOffersSearch.get({
      originLocationCode: "SYD",
      destinationLocationCode: "BKK",
      departureDate: "2022-08-01",
      adults: "2",
    });

    console.log(response);
  } catch (error) {
    console.error(error);
  }
}

main();
// How to install the library at https://github.com/amadeus4dev/amadeus-java

import com.amadeus.Amadeus;
import com.amadeus.Params;
import com.amadeus.exceptions.ResponseException;
import com.amadeus.resources.FlightOfferSearch;

public class FlightOffersSearch {

  public static void main(String[] args) throws ResponseException {

    Amadeus amadeus = Amadeus
        .builder("YOUR_AMADEUS_API_KEY","YOUR_AMADEUS_API_SECRET")
        .build();

    FlightOfferSearch[] flightOffersSearches = amadeus.shopping.flightOffersSearch.get(
                  Params.with("originLocationCode", "SYD")
                          .and("destinationLocationCode", "BKK")
                          .and("departureDate", "2022-11-01")
                          .and("returnDate", "2022-11-08")
                          .and("adults", 2)
                          .and("max", 3));

    if (flightOffersSearches[0].getResponse().getStatusCode() != 200) {
        System.out.println("Wrong status code: " + flightOffersSearches[0].getResponse().getStatusCode());
        System.exit(-1);
    }

    System.out.println(flightOffersSearches[0]);
  }
}

POST

import json
from amadeus import Client, ResponseError

amadeus = Client(
    client_id='YOUR_AMADEUS_API_KEY',
    client_secret='YOUR_AMADEUS_API_SECRET'
)

json_string = '{ "currencyCode": "ZAR", "originDestinations": [ { "id": "1", "originLocationCode": "JNB", ' \
              '"destinationLocationCode": "CPT", "departureDateTimeRange": { "date": "2022-07-01", "time": "00:00:00" ' \
              '} }, { "id": "2", "originLocationCode": "CPT", "destinationLocationCode": "JNB", ' \
              '"departureDateTimeRange": { "date": "2022-07-29", "time": "00:00:00" } } ], "travelers": [ { "id": ' \
              '"1", "travelerType": "ADULT" }, { "id": "2", "travelerType": "ADULT" }, { "id": "3", "travelerType": ' \
              '"HELD_INFANT", "associatedAdultId": "1" } ], "sources": [ "GDS" ], "searchCriteria": { ' \
              '"excludeAllotments": true, "addOneWayOffers": false, "maxFlightOffers": 10, ' \
              '"allowAlternativeFareOptions": true, "oneFlightOfferPerDay": true, "additionalInformation": { ' \
              '"chargeableCheckedBags": true, "brandedFares": true, "fareRules": false }, "pricingOptions": { ' \
              '"includedCheckedBagsOnly": false }, "flightFilters": { "crossBorderAllowed": true, ' \
              '"moreOvernightsAllowed": true, "returnToDepartureAirport": true, "railSegmentAllowed": true, ' \
              '"busSegmentAllowed": true, "carrierRestrictions": { "blacklistedInEUAllowed": true, ' \
              '"includedCarrierCodes": [ "FA" ] }, "cabinRestrictions": [ { "cabin": "ECONOMY", "coverage": ' \
              '"MOST_SEGMENTS", "originDestinationIds": [ "2" ] }, { "cabin": "ECONOMY", "coverage": "MOST_SEGMENTS", ' \
              '"originDestinationIds": [ "1" ] } ], "connectionRestriction": { "airportChangeAllowed": true, ' \
              '"technicalStopsAllowed": true } } } }'

body = json.loads(json_string)
try:
    response = amadeus.shopping.flight_offers_search.post(body)
    print(response.data)
except ResponseError as error:
    raise error
const Amadeus = require("amadeus");

const amadeus = new Amadeus({
  clientId: "YOUR_API_KEY",
  clientSecret: "YOUR_API_SECRET",
});

async function main() {
  try {
    // Find the cheapest flights from SYD to BKK
    const response = await amadeus.shopping.flightOffersSearch.post({
      currencyCode: "USD",
      originDestinations: [
        {
          id: "1",
          originLocationCode: "SYD",
          destinationLocationCode: "BKK",
          departureDateTimeRange: {
            date: "2022-08-01",
            time: "10:00:00",
          },
        },
        {
          id: "2",
          originLocationCode: "BKK",
          destinationLocationCode: "SYD",
          departureDateTimeRange: {
            date: "2022-08-05",
            time: "17:00:00",
          },
        },
      ],
      travelers: [
        {
          id: "1",
          travelerType: "ADULT",
          fareOptions: ["STANDARD"],
        },
        {
          id: "2",
          travelerType: "CHILD",
          fareOptions: ["STANDARD"],
        },
      ],
      sources: ["GDS"],
      searchCriteria: {
        maxFlightOffers: 50,
        flightFilters: {
          cabinRestrictions: [
            {
              cabin: "BUSINESS",
              coverage: "MOST_SEGMENTS",
              originDestinationIds: ["1"],
            },
          ],
          carrierRestrictions: {
            excludedCarrierCodes: ["AA", "TP", "AZ"],
          },
        },
      },
    });

    console.log(response);
  } catch (error) {
    console.error(error);
  }
}

main();
// How to install the library at https://github.com/amadeus4dev/amadeus-java

import com.amadeus.Amadeus;
import com.amadeus.exceptions.ResponseException;
import com.amadeus.resources.FlightOfferSearch;

public class FlightOffersSearch {

  public static void main(String[] args) throws ResponseException {

    Amadeus amadeus = Amadeus
        .builder("YOUR_AMADEUS_API_KEY","YOUR_AMADEUS_API_SECRET")
        .build();

    String body = "{\"currencyCode\":\"USD\",\"originDestinations\":[{\"id\":\"1\",\"originLocationCode\":\"RIO\",\"destinationLocationCode\":\"MAD\",\"departureDateTimeRange\":{\"date\":\"2022-08-01\",\"time\":\"10:00:00\"}},{\"id\":\"2\",\"originLocationCode\":\"MAD\",\"destinationLocationCode\":\"RIO\",\"departureDateTimeRange\":{\"date\":\"2022-08-05\",\"time\":\"17:00:00\"}}],\"travelers\":[{\"id\":\"1\",\"travelerType\":\"ADULT\",\"fareOptions\":[\"STANDARD\"]},{\"id\":\"2\",\"travelerType\":\"CHILD\",\"fareOptions\":[\"STANDARD\"]}],\"sources\":[\"GDS\"],\"searchCriteria\":{\"maxFlightOffers\":2,\"flightFilters\":{\"cabinRestrictions\":[{\"cabin\":\"BUSINESS\",\"coverage\":\"MOST_SEGMENTS\",\"originDestinationIds\":[\"1\"]}],\"carrierRestrictions\":{\"excludedCarrierCodes\":[\"AA\",\"TP\",\"AZ\"]}}}}";

    FlightOfferSearch[] flightOffersSearches = amadeus.shopping.flightOffersSearch.post(body);

    if (flightOffersSearches[0].getResponse().getStatusCode() != 200) {
        System.out.println("Wrong status code: " + flightOffersSearches[0].getResponse().getStatusCode());
        System.exit(-1);
    }

    System.out.println(flightOffersSearches[0]);
  }
}

Flight Offers Price

# Install the Python library from https://pypi.org/project/amadeus
from amadeus import Client, ResponseError

amadeus = Client(
    client_id='YOUR_AMADEUS_API_KEY',
    client_secret='YOUR_AMADEUS_API_SECRET'
)

try:
    '''
    Confirm availability and price from SYD to BKK in summer 2022
    '''
    flights = amadeus.shopping.flight_offers_search.get(originLocationCode='SYD', destinationLocationCode='BKK',
                                                        departureDate='2022-07-01', adults=1).data
    response_one_flight = amadeus.shopping.flight_offers.pricing.post(
        flights[0])
    print(response_one_flight.data)

    response_two_flights = amadeus.shopping.flight_offers.pricing.post(
        flights[0:2])
    print(response_two_flights.data)
except ResponseError as error:
    raise error
const Amadeus = require("amadeus");

const amadeus = new Amadeus({
  clientId: "YOUR_API_KEY",
  clientSecret: "YOUR_API_SECRET",
});

async function main() {
  try {
    // Confirm availability and price from MAD to ATH in summer 2024
    const flightOffersResponse = await amadeus.shopping.flightOffersSearch.get({
      originLocationCode: "MAD",
      destinationLocationCode: "ATH",
      departureDate: "2024-07-01",
      adults: "1",
    });

    const response = await amadeus.shopping.flightOffers.pricing.post(
      {
        data: {
          type: "flight-offers-pricing",
          flightOffers: [flightOffersResponse.data[0]],
        },
      },
      { include: "credit-card-fees,detailed-fare-rules" }
    );
    console.log(response);
  } catch (error) {
    console.error(error);
  }
}

main();
// How to install the library at https://github.com/amadeus4dev/amadeus-java

import com.amadeus.Amadeus;
import com.amadeus.Params;
import com.amadeus.exceptions.ResponseException;
import com.amadeus.resources.FlightOfferSearch;
import com.amadeus.resources.FlightPrice;

public class FlightOffersPrice {

  public static void main(String[] args) throws ResponseException {

    Amadeus amadeus = Amadeus
        .builder("YOUR_AMADEUS_API_KEY","YOUR_AMADEUS_API_SECRET")
        .build();

    FlightOfferSearch[] flightOffersSearches = amadeus.shopping.flightOffersSearch.get(
        Params.with("originLocationCode", "SYD")
                .and("destinationLocationCode", "BKK")
                .and("departureDate", "2022-11-01")
                .and("returnDate", "2022-11-08")
                .and("adults", 1)
                .and("max", 2));

    // We price the 2nd flight of the list to confirm the price and the availability
    FlightPrice flightPricing = amadeus.shopping.flightOffersSearch.pricing.post(
            flightOffersSearches[1],
            Params.with("include", "detailed-fare-rules")
              .and("forceClass", "false")
          );

    System.out.println(flightPricing.getResponse());
  }
}
# Install the Python library from https://pypi.org/project/amadeus/# Install the Python library from https://pypi.org/project/amadeus
from amadeus import Client, ResponseError

amadeus = Client(
    client_id='YOUR_AMADEUS_API_KEY',
    client_secret='YOUR_AMADEUS_API_SECRET'
)

try:
    '''
    Find cheapest destinations from Madrid
    '''
    response = amadeus.shopping.flight_destinations.get(origin='MAD')
    print(response.data)
except ResponseError as error:
    raise error
const Amadeus = require("amadeus");

const amadeus = new Amadeus({
  clientId: "YOUR_API_KEY",
  clientSecret: "YOUR_API_SECRET",
});

async function main() {
  try {
    // Find cheapest destinations from Madrid
    const response = await amadeus.shopping.flightDestinations.get({
      origin: "MAD",
    });

    console.log(response);
  } catch (error) {
    console.error(error);
  }
}

main();
// How to install the library at https://github.com/amadeus4dev/amadeus-java

import com.amadeus.Amadeus;
import com.amadeus.Params;
import com.amadeus.exceptions.ResponseException;
import com.amadeus.resources.FlightDestination;

public class FlightInspirationSearch {

  public static void main(String[] args) throws ResponseException {

    Amadeus amadeus = Amadeus
        .builder("YOUR_AMADEUS_API_KEY","YOUR_AMADEUS_API_SECRET")
        .build();

    FlightDestination[] flightDestinations = amadeus.shopping.flightDestinations.get(Params
    .with("origin", "MAD"));

    if (flightDestinations[0].getResponse().getStatusCode() != 200) {
        System.out.println("Wrong status code: " + flightDestinations[0].getResponse().getStatusCode());
        System.exit(-1);
    }

    System.out.println(flightDestinations[0]);
  }
}
# Install the Python library from https://pypi.org/project/amadeus
from amadeus import Client, ResponseError

amadeus = Client(
    client_id='YOUR_AMADEUS_API_KEY',
    client_secret='YOUR_AMADEUS_API_SECRET'
)

try:
    '''
    Find cheapest dates from Madrid to Munich
    '''
    response = amadeus.shopping.flight_dates.get(origin='MAD', destination='MUC')
    print(response.data)
except ResponseError as error:
    raise error
const Amadeus = require("amadeus");

const amadeus = new Amadeus({
  clientId: "YOUR_API_KEY",
  clientSecret: "YOUR_API_SECRET",
});

async function main() {
  try {
    // Find cheapest dates from Madrid to Munich
    const response = await amadeus.shopping.flightDates.get({
      origin: "MAD",
      destination: "MUC",
    });

    console.log(response);
  } catch (error) {
    console.error(error);
  }
}

main();
// How to install the library at https://github.com/amadeus4dev/amadeus-java

import com.amadeus.Amadeus;
import com.amadeus.Params;
import com.amadeus.exceptions.ResponseException;
import com.amadeus.resources.FlightDate;

public class FlightCheapestDate {

  public static void main(String[] args) throws ResponseException {

    Amadeus amadeus = Amadeus
        .builder("YOUR_AMADEUS_API_KEY","YOUR_AMADEUS_API_SECRET")
        .build();

    FlightDate[] flightDates = amadeus.shopping.flightDates.get(Params
      .with("origin", "MAD")
      .and("destination", "MUC"));

    if(flightDates[0].getResponse().getStatusCode() != 200) {
        System.out.println("Wrong status code: " + (flightDates[0].getResponse().getStatusCode());
        System.exit(-1);
    }
    System.out.println((flightDates[0]);
  }
}
# Install the Python library from https://pypi.org/project/amadeus
from amadeus import Client, ResponseError

amadeus = Client(
    client_id='YOUR_AMADEUS_API_KEY',
    client_secret='YOUR_AMADEUS_API_SECRET'
)

try:
    body = {
        "originDestinations": [
            {
                "id": "1",
                "originLocationCode": "MIA",
                "destinationLocationCode": "ATL",
                "departureDateTime": {
                    "date": "2022-11-01"
                }
            }
        ],
        "travelers": [
            {
                "id": "1",
                "travelerType": "ADULT"
            }
        ],
        "sources": [
            "GDS"
        ]
    }

    response = amadeus.shopping.availability.flight_availabilities.post(body)
    print(response.data)
except ResponseError as error:
    raise error
const Amadeus = require("amadeus");

const amadeus = new Amadeus({
  clientId: "YOUR_API_KEY",
  clientSecret: "YOUR_API_SECRET",
});

async function main() {
  try {
    const response =
      await amadeus.shopping.availability.flightAvailabilities.post({
        originDestinations: [
          {
            id: "1",
            originLocationCode: "MIA",
            destinationLocationCode: "ATL",
            departureDateTime: {
              date: "2022-11-01",
            },
          },
        ],
        travelers: [
          {
            id: "1",
            travelerType: "ADULT",
          },
        ],
        sources: ["GDS"],
      });
    console.log(response);
  } catch (error) {
    console.error(error);
  }
}

main();
// How to install the library at https://github.com/amadeus4dev/amadeus-java

import com.amadeus.Amadeus;
import com.amadeus.Response;
import com.amadeus.exceptions.ResponseException;
import com.amadeus.resources.FlightAvailability;

public class FlightAvailabilities {

  public static void main(String[] args) throws ResponseException {

    Amadeus amadeus = Amadeus
        .builder("YOUR_AMADEUS_API_KEY","YOUR_AMADEUS_API_SECRET")
        .build();

    String body = "{\"originDestinations\":[{\"id\":\"1\",\"originLocationCode\":\"ATH\",\"destinationLocationCode\":\"SKG\",\"departureDateTime\":{\"date\":\"2023-08-14\",\"time\":\"21:15:00\"}}],\"travelers\":[{\"id\":\"1\",\"travelerType\":\"ADULT\"}],\"sources\":[\"GDS\"]}";

    FlightAvailability[] flightAvailabilities = amadeus.shopping.availability.flightAvailabilities.post(body);

    if (flightAvailabilities[0].getResponse().getStatusCode() != 200) {
        System.out.println("Wrong status code: " + flightAvailabilities[0].getResponse().getStatusCode());
        System.exit(-1);
    }

    System.out.println(flightAvailabilities[0]);
  }

}

Branded Upsell

# Install the Python library from https://pypi.org/project/amadeus
import json
from amadeus import Client, ResponseError

amadeus = Client(
    client_id='YOUR_AMADEUS_API_KEY',
    client_secret='YOUR_AMADEUS_API_SECRET'
)

try:
    json_string = '{ "data": { "type": "flight-offers-upselling", "flightOffers": [ { "type": "flight-offer", ' \
                  '"id": "1", ' \
                  '"source": "GDS", "instantTicketingRequired": false, "nonHomogeneous": false, "oneWay": false, ' \
                  '"lastTicketingDate": "2022-05-11", "numberOfBookableSeats": 9, "itineraries": [ { "duration": ' \
                  '"PT2H10M", ' \
                  '"segments": [ { "departure": { "iataCode": "CDG", "terminal": "3", "at": "2022-07-04T20:45:00" }, ' \
                  '"arrival": { ' \
                  '"iataCode": "MAD", "terminal": "4", "at": "2022-07-04T22:55:00" }, "carrierCode": "IB", ' \
                  '"number": "3741", ' \
                  '"aircraft": { "code": "32A" }, "operating": { "carrierCode": "I2" }, "duration": "PT2H10M", ' \
                  '"id": "4", ' \
                  '"numberOfStops": 0, "blacklistedInEU": false } ] } ], "price": { "currency": "EUR", ' \
                  '"total": "123.02", ' \
                  '"base": "92.00", "fees": [ { "amount": "0.00", "type": "SUPPLIER" }, { "amount": "0.00", ' \
                  '"type": "TICKETING" } ' \
                  '], "grandTotal": "123.02", "additionalServices": [ { "amount": "30.00", "type": "CHECKED_BAGS" } ] ' \
                  '}, ' \
                  '"pricingOptions": { "fareType": [ "PUBLISHED" ], "includedCheckedBagsOnly": false }, ' \
                  '"validatingAirlineCodes": [ ' \
                  '"IB" ], "travelerPricings": [ { "travelerId": "1", "fareOption": "STANDARD", "travelerType": ' \
                  '"ADULT", ' \
                  '"price": { "currency": "EUR", "total": "123.02", "base": "92.00" }, "fareDetailsBySegment": [ { ' \
                  '"segmentId": ' \
                  '"4", "cabin": "ECONOMY", "fareBasis": "SDNNEOB2", "brandedFare": "NOBAG", "class": "S", ' \
                  '"includedCheckedBags": { ' \
                  '"quantity": 0 } } ] } ] } ], "payments": [ { "brand": "VISA_IXARIS", "binNumber": 123456, ' \
                  '"flightOfferIds": [ 1 ' \
                  '] } ] } } '

    body = json.loads(json_string)
    response = amadeus.shopping.flight_offers.upselling.post(body)
    print(response.data)
except ResponseError as error:
    raise error
const Amadeus = require("amadeus");

const amadeus = new Amadeus({
  clientId: "YOUR_AMADEUS_API_KEY",
  clientSecret: "YOUR_AMADEUS_API_SECRET",
});

async function main() {
  try {
    // Search flights from LON to DEL
    const flightOffersResponse = await amadeus.shopping.flightOffersSearch.get({
      originLocationCode: "LON",
      destinationLocationCode: "DEL",
      departureDate: "2023-06-01",
      returnDate: "2023-06-30",
      adults: "1",
    });

    //then Get branded fares available from the first offer
    const response = await amadeus.shopping.flightOffers.upselling.post({
      data: {
        type: "flight-offers-upselling",
        flightOffers: [flightOffersResponse.data[0]],
        payments: [
          {
            brand: "VISA_IXARIS",
            binNumber: 123456,
            flightOfferIds: [1],
          },
        ],
      },
    });
    console.log(response);
  } catch (error) {
    console.error(error);
  }
}

main();
// How to install the library at https://github.com/amadeus4dev/amadeus-java

import com.amadeus.Amadeus;
import com.amadeus.Params;
import com.amadeus.exceptions.ResponseException;
import com.amadeus.resources.FlightOfferSearch;

public class BrandedFaresUpsell {

  public static void main(String[] args) throws ResponseException {

        Amadeus amadeus = Amadeus
            .builder("YOUR_AMADEUS_API_KEY","YOUR_AMADEUS_API_SECRET")
            .build();

        FlightOfferSearch[] flightOffersSearches = amadeus.shopping.flightOffersSearch.get(
            Params.with("originLocationCode", "SYD")
                    .and("destinationLocationCode", "BKK")
                    .and("departureDate", "2023-11-01")
                    .and("returnDate", "2023-11-08")
                    .and("adults", 1)
                    .and("max", 2));

        FlightOfferSearch[] upsellFlightOffers = amadeus.shopping.flightOffers.upselling.post(flightOffersSearches[0]);

        if (upsellFlightOffers[0].getResponse().getStatusCode() != 200) {
            System.out.println("Wrong status code: " + upsellFlightOffers[0].getResponse().getStatusCode());
            System.exit(-1);
        }

        System.out.println(upsellFlightOffers[0]);
    }
}

SeatMap Display

GET

# Install the Python library from https://pypi.org/project/amadeus
from amadeus import Client, ResponseError

amadeus = Client(
    client_id='YOUR_AMADEUS_API_KEY',
    client_secret='YOUR_AMADEUS_API_SECRET'
)

try:
    '''
    Retrieve the seat map of a flight present in an order
    '''
    response = amadeus.shopping.seatmaps.get(flightorderId='eJzTd9cPDPMwcooAAAtXAmE=')
    print(response.data)
except ResponseError as error:
    raise error
const Amadeus = require("amadeus");

const amadeus = new Amadeus({
  clientId: "YOUR_API_KEY",
  clientSecret: "YOUR_API_SECRET",
});

async function main() {
  try {
    // Returns all the seat maps of a given order
    const response = await amadeus.shopping.seatmaps.get({
      "flight-orderId": "eJzTd9cPDPMwcooAAAtXAmE=",
    });

    console.log(response);
  } catch (error) {
    console.error(error);
  }
}

main();
// How to install the library at https://github.com/amadeus4dev/amadeus-java

import com.amadeus.Amadeus;
import com.amadeus.Params;
import com.amadeus.exceptions.ResponseException;
import com.amadeus.resources.SeatMap;

public class SeatMaps {
    public static void main(String[] args) throws ResponseException {

        Amadeus amadeus = Amadeus
              .builder("YOUR_AMADEUS_API_KEY","YOUR_AMADEUS_API_SECRET")
              .build();

        SeatMap[] seatmap = amadeus.shopping.seatMaps.get(Params
                .with("flight-orderId", "eJzTd9cPDPMwcooAAAtXAmE="));
        if(seatmap.length != 0){
          if (seatmap[0].getResponse().getStatusCode() != 200) {
            System.out.println("Wrong status code: " + seatmap[0].getResponse().getStatusCode());
            System.exit(-1);
          }
          System.out.println(seatmap[0]);
        }
        else {
          System.out.println("No booking found for this flight-orderId");
          System.exit(-1);
        }
     }
}

POST

# Install the Python library from https://pypi.org/project/amadeus
from amadeus import Client, ResponseError

amadeus = Client(
    client_id='YOUR_AMADEUS_API_KEY',
    client_secret='YOUR_AMADEUS_API_SECRET'
)

try:
    '''
    Retrieve the seat map of a given flight offer 
    '''
    body = amadeus.shopping.flight_offers_search.get(originLocationCode='MAD',
                                                     destinationLocationCode='NYC',
                                                     departureDate='2022-11-01',
                                                     adults=1,
                                                     max=1).result
    response = amadeus.shopping.seatmaps.post(body)
    print(response.data)
except ResponseError as error:
    raise error
const Amadeus = require("amadeus");

const amadeus = new Amadeus({
  clientId: "YOUR_API_KEY",
  clientSecret: "YOUR_API_SECRET",
});

async function main() {
  try {
    // Returns all the seat maps of a given flightOffer
    const flightOffersResponse = await amadeus.shopping.flightOffersSearch.get({
      originLocationCode: "SYD",
      destinationLocationCode: "BKK",
      departureDate: "2022-08-01",
      adults: "2",
    });

    const response = await amadeus.shopping.seatmaps.post({
      data: [flightOffersResponse.data[0]],
    });

    console.log(response);
  } catch (error) {
    console.error(error);
  }
}

main();
// How to install the library at https://github.com/amadeus4dev/amadeus-java

import com.amadeus.Amadeus;
import com.amadeus.Params;
import com.amadeus.exceptions.ResponseException;
import com.amadeus.resources.FlightOfferSearch;
import com.amadeus.resources.SeatMap;
import com.google.gson.JsonObject;

public class SeatMaps {
    public static void main(String[] args) throws ResponseException {

      Amadeus amadeus = Amadeus
              .builder("YOUR_AMADEUS_API_KEY","YOUR_AMADEUS_API_SECRET")
              .build();

      FlightOfferSearch[] flightOffers = amadeus.shopping.flightOffersSearch.get(
                    Params.with("originLocationCode", "NYC")
                            .and("destinationLocationCode", "MAD")
                            .and("departureDate", "2022-11-01")
                            .and("returnDate", "2022-11-09")
                            .and("max", "1")
                            .and("adults", 1));

      JsonObject body = flightOffers[0].getResponse().getResult();
      SeatMap[] seatmap = amadeus.shopping.seatMaps.post(body);

      if (seatmap[0].getResponse().getStatusCode() != 200) {
        System.out.println("Wrong status code: " + seatmap[0].getResponse().getStatusCode());
        System.exit(-1);
      }

      System.out.println(seatmap[0]);
    }
}

Flight Create Orders

# Install the Python library from https://pypi.org/project/amadeus
from amadeus import Client, ResponseError

amadeus = Client(
    client_id='YOUR_AMADEUS_API_KEY',
    client_secret='YOUR_AMADEUS_API_SECRET'
)

traveler = {
    'id': '1',
    'dateOfBirth': '1982-01-16',
    'name': {
        'firstName': 'JORGE',
        'lastName': 'GONZALES'
    },
    'gender': 'MALE',
    'contact': {
        'emailAddress': 'jorge.gonzales833@telefonica.es',
        'phones': [{
            'deviceType': 'MOBILE',
            'countryCallingCode': '34',
            'number': '480080076'
        }]
    },
    'documents': [{
        'documentType': 'PASSPORT',
        'birthPlace': 'Madrid',
        'issuanceLocation': 'Madrid',
        'issuanceDate': '2015-04-14',
        'number': '00000000',
        'expiryDate': '2025-04-14',
        'issuanceCountry': 'ES',
        'validityCountry': 'ES',
        'nationality': 'ES',
        'holder': True
    }]
}

try:
    # Flight Offers Search to search for flights from MAD to ATH
    flight_search = amadeus.shopping.flight_offers_search.get(originLocationCode='MAD',
                                                              destinationLocationCode='ATH',
                                                              departureDate='2022-12-01',
                                                              adults=1).data

    # Flight Offers Price to confirm the price of the chosen flight
    price_confirm = amadeus.shopping.flight_offers.pricing.post(
        flight_search[0]).data

    # Flight Create Orders to book the flight
    booked_flight = amadeus.booking.flight_orders.post(
        flight_search[0], traveler).data

except ResponseError as error:
    raise error
const Amadeus = require("amadeus");

const amadeus = new Amadeus({
  clientId: "YOUR_API_KEY",
  clientSecret: "YOUR_API_SECRET",
});

async function main() {
  try {
    // Book a flight from MAD to ATH on 2022-08-01
    const flightOffersResponse = await amadeus.shopping.flightOffersSearch.get({
      originLocationCode: "MAD",
      destinationLocationCode: "ATH",
      departureDate: "2022-08-01",
      adults: "1",
    });

    const pricingResponse = await amadeus.shopping.flightOffers.pricing.post({
      data: {
        type: "flight-offers-pricing",
        flightOffers: [flightOffersResponse.data[0]],
      },
    });

    const response = await amadeus.booking.flightOrders.post({
      data: {
        type: "flight-order",
        flightOffers: [pricingResponse.data.flightOffers[0]],
        travelers: [
          {
            id: "1",
            dateOfBirth: "1982-01-16",
            name: {
              firstName: "JORGE",
              lastName: "GONZALES",
            },
            gender: "MALE",
            contact: {
              emailAddress: "jorge.gonzales833@telefonica.es",
              phones: [
                {
                  deviceType: "MOBILE",
                  countryCallingCode: "34",
                  number: "480080076",
                },
              ],
            },
            documents: [
              {
                documentType: "PASSPORT",
                birthPlace: "Madrid",
                issuanceLocation: "Madrid",
                issuanceDate: "2015-04-14",
                number: "00000000",
                expiryDate: "2025-04-14",
                issuanceCountry: "ES",
                validityCountry: "ES",
                nationality: "ES",
                holder: true,
              },
            ],
          },
        ],
      },
    });
    console.log(response);
  } catch (error) {
    console.error(error);
  }
}

main();
// How to install the library at https://github.com/amadeus4dev/amadeus-java

import com.amadeus.Amadeus;
import com.amadeus.Params;
import com.amadeus.exceptions.ResponseException;
import com.amadeus.resources.FlightOfferSearch;
import com.amadeus.resources.FlightPrice;
import com.amadeus.resources.FlightOrder;
import com.amadeus.resources.FlightOrder.Traveler;
import com.amadeus.resources.FlightOrder.Document.DocumentType;
import com.amadeus.resources.FlightOrder.Phone.DeviceType;
import com.amadeus.resources.FlightOrder.Name;
import com.amadeus.resources.FlightOrder.Phone;
import com.amadeus.resources.FlightOrder.Contact;
import com.amadeus.resources.FlightOrder.Document;

public class FlightSearch {

  public static void main(String[] args) throws ResponseException {

    Amadeus amadeus = Amadeus
            .builder("YOUR_AMADEUS_API_KEY","YOUR_AMADEUS_API_SECRET")
            .build();

    Traveler traveler = new Traveler();

    traveler.setId("1");
    traveler.setDateOfBirth("2000-04-14");
    traveler.setName(new Name("JORGE", "GONZALES"));

    Phone[] phone = new Phone[1];
    phone[0] = new Phone();
    phone[0].setCountryCallingCode("33");
    phone[0].setNumber("675426222");
    phone[0].setDeviceType(DeviceType.MOBILE);

    Contact contact = new Contact();
    contact.setPhones(phone);
    traveler.setContact(contact);

    Document[] document = new Document[1];
    document[0] = new Document();
    document[0].setDocumentType(DocumentType.PASSPORT);
    document[0].setNumber("480080076");
    document[0].setExpiryDate("2023-10-11");
    document[0].setIssuanceCountry("ES");
    document[0].setNationality("ES");
    document[0].setHolder(true);
    traveler.setDocuments(document);

    Traveler[] travelerArray = new Traveler[1];
    travelerArray[0] = traveler;
    System.out.println(travelerArray[0]);

    FlightOfferSearch[] flightOffersSearches = amadeus.shopping.flightOffersSearch.get(
            Params.with("originLocationCode", "MAD")
                    .and("destinationLocationCode", "ATH")
                    .and("departureDate", "2023-08-01")
                    .and("returnDate", "2023-08-08")
                    .and("adults", 1)
                    .and("max", 3));

    // We price the 2nd flight of the list to confirm the price and the availability
    FlightPrice flightPricing = amadeus.shopping.flightOffersSearch.pricing.post(
            flightOffersSearches[0]);

    // We book the flight previously priced
    FlightOrder order = amadeus.booking.flightOrders.post(flightPricing, travelerArray);
    System.out.println(order.getResponse());

    // Return CO2 Emission of the previously booked flight
    int weight = order.getFlightOffers()[0].getItineraries(
    )[0].getSegments()[0].getCo2Emissions()[0].getWeight();
    String unit = order.getFlightOffers()[0].getItineraries(
    )[0].getSegments()[0].getCo2Emissions()[0].getWeightUnit();

  }
}

Flight Order Management

GET

# Install the Python library from https://pypi.org/project/amadeus
from amadeus import ResponseError, Client

amadeus = Client(
    client_id='YOUR_AMADEUS_API_KEY',
    client_secret='YOUR_AMADEUS_API_SECRET'
)

try:
    '''
    # Retrieve the flight order based on it's id
    '''
    response = amadeus.booking.flight_order('MlpZVkFMfFdBVFNPTnwyMDE1LTExLTAy').get()
    print(response.data)
except ResponseError as error:
    raise error
const Amadeus = require("amadeus");

const amadeus = new Amadeus({
  clientId: "YOUR_API_KEY",
  clientSecret: "YOUR_API_SECRET",
});

async function main() {
  try {
    // Book a flight from MAD to ATH on 2020-08-01 and then retrieve it
    const flightOffersResponse = await amadeus.shopping.flightOffersSearch.get({
      originLocationCode: "MAD",
      destinationLocationCode: "ATH",
      departureDate: "2020-08-01",
      adults: "1",
    });

    const pricingResponse = await amadeus.shopping.flightOffers.pricing.post({
      data: {
        type: "flight-offers-pricing",
        flightOffers: [flightOffersResponse.data[0]],
      },
    });

    const flightOrdersResponse = await amadeus.booking.flightOrders.post({
      data: {
        type: "flight-order",
        flightOffers: [pricingResponse.data.flightOffers[0]],
        travelers: [
          {
            id: "1",
            dateOfBirth: "1982-01-16",
            name: {
              firstName: "JORGE",
              lastName: "GONZALES",
            },
            gender: "MALE",
            contact: {
              emailAddress: "jorge.gonzales833@telefonica.es",
              phones: [
                {
                  deviceType: "MOBILE",
                  countryCallingCode: "34",
                  number: "480080076",
                },
              ],
            },
            documents: [
              {
                documentType: "PASSPORT",
                birthPlace: "Madrid",
                issuanceLocation: "Madrid",
                issuanceDate: "2015-04-14",
                number: "00000000",
                expiryDate: "2025-04-14",
                issuanceCountry: "ES",
                validityCountry: "ES",
                nationality: "ES",
                holder: true,
              },
            ],
          },
        ],
      },
    });

    const response = await amadeus.booking
      .flightOrder(flightOrdersResponse.data.id)
      .get();

    console.log(response);
  } catch (error) {
    console.error(error);
  }
}

main();
// How to install the library at https://github.com/amadeus4dev/amadeus-java

import com.amadeus.Amadeus;
import com.amadeus.booking.FlightOrder;
import com.amadeus.exceptions.ResponseException;

public class FlightOrderManagement {
    public static void main(String[] args) throws ResponseException {

      Amadeus amadeus = Amadeus
              .builder("YOUR_AMADEUS_API_KEY","YOUR_AMAEUS_API_SECRET")
              .build();

      com.amadeus.resources.FlightOrder order = amadeus.booking.flightOrder("MlpZVkFMfFdBVFNPTnwyMDE1LTExLTAy").get();

      if (order.getResponse().getStatusCode() != 200) {
        System.out.println("Wrong status code: " + order.getResponse().getStatusCode());
        System.exit(-1);
      }

      System.out.println(order);
     }
}

DELETE

# Install the Python library from https://pypi.org/project/amadeus
from amadeus import ResponseError, Client

amadeus = Client(
    client_id='YOUR_AMADEUS_API_KEY',
    client_secret='YOUR_AMADEUS_API_SECRET'
)

try:
    '''
    # Delete a given flight order based on it's id
    '''
    response = amadeus.booking.flight_order('MlpZVkFMfFdBVFNPTnwyMDE1LTExLTAy').delete()
    print(response.data)
except ResponseError as error:
    raise error
const Amadeus = require("amadeus");

const amadeus = new Amadeus({
  clientId: "YOUR_API_KEY",
  clientSecret: "YOUR_API_SECRET",
});

async function main() {
  try {
    // Book a flight from MAD to ATH on 2020-08-01, retrieve it and then delete it
    const flightOffersResponse = await amadeus.shopping.flightOffersSearch.get({
      originLocationCode: "MAD",
      destinationLocationCode: "ATH",
      departureDate: "2020-08-01",
      adults: "1",
    });

    const pricingResponse = await amadeus.shopping.flightOffers.pricing.post({
      data: {
        type: "flight-offers-pricing",
        flightOffers: [flightOffersResponse.data[0]],
      },
    });

    const flightOrdersResponse = await amadeus.booking.flightOrders.post({
      data: {
        type: "flight-order",
        flightOffers: [pricingResponse.data.flightOffers[0]],
        travelers: [
          {
            id: "1",
            dateOfBirth: "1982-01-16",
            name: {
              firstName: "JORGE",
              lastName: "GONZALES",
            },
            gender: "MALE",
            contact: {
              emailAddress: "jorge.gonzales833@telefonica.es",
              phones: [
                {
                  deviceType: "MOBILE",
                  countryCallingCode: "34",
                  number: "480080076",
                },
              ],
            },
            documents: [
              {
                documentType: "PASSPORT",
                birthPlace: "Madrid",
                issuanceLocation: "Madrid",
                issuanceDate: "2015-04-14",
                number: "00000000",
                expiryDate: "2025-04-14",
                issuanceCountry: "ES",
                validityCountry: "ES",
                nationality: "ES",
                holder: true,
              },
            ],
          },
        ],
      },
    });

    const flightOrderResponse = await amadeus.booking
      .flightOrder(flightOrdersResponse.data.id)
      .get();

    const response = await amadeus.booking
      .flightOrder(flightOrderResponse.data.id)
      .delete();

    console.log(response);
  } catch (error) {
    console.error(error);
  }
}

main();
// How to install the library at https://github.com/amadeus4dev/amadeus-java

import com.amadeus.Amadeus;
import com.amadeus.booking.FlightOrder;
import com.amadeus.exceptions.ResponseException;

public class FlightOrderManagement {
    public static void main(String[] args) throws ResponseException {

      Amadeus amadeus = Amadeus
              .builder("YOUR_AMADEUS_API_KEY","YOUR_AMADEUS)API_SECRET")
              .build();

      com.amadeus.resources.FlightOrder order = amadeus.booking.flightOrder("MlpZVkFMfFdBVFNPTnwyMDE1LTExLTAy").delete();

      if (order.getResponse().getStatusCode() != 200) {
        System.out.println("Wrong status code: " + order.getResponse().getStatusCode());
        System.exit(-1);
      }

      System.out.println(order);
     }
}

Flight Price Analysis

# Install the Python library from https://pypi.org/project/amadeus
from amadeus import ResponseError, Client

amadeus = Client(
    client_id='YOUR_AMADEUS_API_KEY',
    client_secret='YOUR_AMADEUS_API_SECRET'
)

try:
    '''
    Returns price metrics of a given itinerary
    '''
    response = amadeus.analytics.itinerary_price_metrics.get(originIataCode='MAD',
                                                             destinationIataCode='CDG',
                                                             departureDate='2022-03-21')
    print(response.data)
except ResponseError as error:
    raise error
const Amadeus = require("amadeus");

const amadeus = new Amadeus({
  clientId: "YOUR_API_KEY",
  clientSecret: "YOUR_API_SECRET",
});

async function main() {
  try {
    // Am I getting a good deal on this flight?
    const response = await amadeus.analytics.itineraryPriceMetrics.get({
      originIataCode: "MAD",
      destinationIataCode: "CDG",
      departureDate: "2022-01-13",
    });

    console.log(response);
  } catch (error) {
    console.error(error);
  }
}

main();
// How to install the library at https://github.com/amadeus4dev/amadeus-java

import com.amadeus.Amadeus;
import com.amadeus.Params;
import com.amadeus.exceptions.ResponseException;
import com.amadeus.resources.ItineraryPriceMetric;

public class FlightPriceAnalysis {

  public static void main(String[] args) throws ResponseException {

    Amadeus amadeus = Amadeus
        .builder("YOUR_API_ID","YOUR_API_SECRET")
        .build();

    // What's the flight price analysis from MAD to CDG
    ItineraryPriceMetric[] metrics = amadeus.analytics.itineraryPriceMetrics.get(Params
        .with("originIataCode", "MAD")
        .and("destinationIataCode", "CDG")
        .and("departureDate", "2022-03-21"));

    if (metrics[0].getResponse().getStatusCode() != 200) {
        System.out.println("Wrong status code: " + metrics[0].getResponse().getStatusCode());
        System.exit(-1);
    }

    System.out.println(metrics[0]);
  }
}

Flight Delay Prediction

# Install the Python library from https://pypi.org/project/amadeus
from amadeus import Client, ResponseError

amadeus = Client(
    client_id='YOUR_AMADEUS_API_KEY',
    client_secret='YOUR_AMADEUS_API_SECRET'
)

try:
    '''
    Will there be a delay from BRU to FRA? If so how much delay?
    '''
    response = amadeus.travel.predictions.flight_delay.get(originLocationCode='NCE', destinationLocationCode='IST',
                                                           departureDate='2022-08-01', departureTime='18:20:00',
                                                           arrivalDate='2022-08-01', arrivalTime='22:15:00',
                                                           aircraftCode='321', carrierCode='TK',
                                                           flightNumber='1816', duration='PT31H10M')
    print(response.data)
except ResponseError as error:
    raise error
const Amadeus = require("amadeus");

const amadeus = new Amadeus({
  clientId: "YOUR_API_KEY",
  clientSecret: "YOUR_API_SECRET",
});

async function main() {
  try {
    // Will there be a delay from BRU to FRA? If so how much delay?
    const response = await amadeus.travel.predictions.flightDelay.get({
      originLocationCode: "NCE",
      destinationLocationCode: "IST",
      departureDate: "2022-08-01",
      departureTime: "18:20:00",
      arrivalDate: "2022-08-01",
      arrivalTime: "22:15:00",
      aircraftCode: "321",
      carrierCode: "TK",
      flightNumber: "1816",
      duration: "PT31H10M",
    });

    console.log(response);
  } catch (error) {
    console.error(error);
  }
}

main();
// How to install the library at https://github.com/amadeus4dev/amadeus-java

import com.amadeus.Amadeus;
import com.amadeus.Params;
import com.amadeus.exceptions.ResponseException;
import com.amadeus.resources.Delay;

public class FlightDelayPrediction {

  public static void main(String[] args) throws ResponseException {

    Amadeus amadeus = Amadeus
        .builder("YOUR_AMADEUS_API_KEY","YOUR_AMADEUS_API_SECRET")
        .build();

    Delay[] flightDelay = amadeus.travel.predictions.flightDelay.get(Params
    .with("originLocationCode", "NCE")
    .and("destinationLocationCode", "IST")
    .and("departureDate", "2022-08-01")
    .and("departureTime", "18:20:00")
    .and("arrivalDate", "2022-08-01")
    .and("arrivalTime", "22:15:00")
    .and("aircraftCode", "321")
    .and("carrierCode", "TK")
    .and("flightNumber", "1816")
    .and("duration", "PT31H10M"));

    if (flightDelay[0].getResponse().getStatusCode() != 200) {
        System.out.println("Wrong status code: " + flightDelay[0].getResponse().getStatusCode());
        System.exit(-1);
    }

    System.out.println(flightDelay[0]);
  }
}

Airport On Time Performance

# Install the Python library from https://pypi.org/project/amadeus
from amadeus import Client, ResponseError

amadeus = Client(
    client_id='YOUR_AMADEUS_API_KEY',
    client_secret='YOUR_AMADEUS_API_SECRET'
)

try:
    '''
    Will there be a delay in the JFK airport on the 1st of December?
    '''
    response = amadeus.airport.predictions.on_time.get(
        airportCode='JFK', date='2021-12-01')
    print(response.data)
except ResponseError as error:
    raise error
const Amadeus = require("amadeus");

const amadeus = new Amadeus({
  clientId: "YOUR_API_KEY",
  clientSecret: "YOUR_API_SECRET",
});

async function main() {
  try {
    // Will there be a delay in the JFK airport on the 1st of September?
    const response = await amadeus.airport.predictions.onTime.get({
      airportCode: "JFK",
      date: "2022-09-01",
    });

    console.log(response);
  } catch (error) {
    console.error(error);
  }
}

main();
// How to install the library at https://github.com/amadeus4dev/amadeus-java

import com.amadeus.Amadeus;
import com.amadeus.Params;
import com.amadeus.exceptions.ResponseException;
import com.amadeus.resources.OnTime;

public class AirportOnTime {

  public static void main(String[] args) throws ResponseException {

    Amadeus amadeus = Amadeus
        .builder("YOUR_AMADEUS_API_KEY","YOUR_AMADEUS_API_SECRET")
        .build();

    OnTime onTime = amadeus.airport.predictions.onTime.get(Params
        .with("airportCode", "JFK")
        .and("date", "2022-09-01"));

    if(onTime.getResponse().getStatusCode() != 200) {
        System.out.println("Wrong status code: " + onTime.getResponse().getStatusCode());
        System.exit(-1);
    }
    System.out.println(onTime);
  }
}

Flight Choice Prediction

# Install the Python library from https://pypi.org/project/amadeus
from amadeus import Client, ResponseError

amadeus = Client(
    client_id='YOUR_AMADEUS_API_KEY',
    client_secret='YOUR_AMADEUS_API_SECRET'
)

try:
    '''
    Find the probability of the flight MAD to NYC to be chosen
    '''
    body = amadeus.shopping.flight_offers_search.get(originLocationCode='MAD',
                                                     destinationLocationCode='NYC',
                                                     departureDate='2022-11-01',
                                                     returnDate='2022-11-09',
                                                     adults=1).result
    response = amadeus.shopping.flight_offers.prediction.post(body)
    print(response.data)
except ResponseError as error:
    raise error
const Amadeus = require("amadeus");

const amadeus = new Amadeus({
  clientId: "YOUR_API_KEY",
  clientSecret: "YOUR_API_SECRET",
});

async function main() {
  try {
    const flightOffersResponse = await amadeus.shopping.flightOffersSearch.get({
      originLocationCode: "SYD",
      destinationLocationCode: "BKK",
      departureDate: "2022-08-01",
      adults: "2",
    });
    const response = await amadeus.shopping.flightOffers.prediction.post(
      flightOffersResponse
    );
    console.log(response.data);
  } catch (error) {
    console.error(error);
  }
}

main();
// How to install the library at https://github.com/amadeus4dev/amadeus-java

import com.amadeus.Amadeus;
import com.amadeus.Params;
import com.amadeus.exceptions.ResponseException;
import com.amadeus.resources.FlightOfferSearch;
import com.google.gson.JsonObject;

public class FlightChoicePrediction {

  public static void main(String[] args) throws ResponseException {

    Amadeus amadeus = Amadeus
        .builder("YOUR_AMADEUS_API_KEY","YOUR_AMADEUS_API_SECRET")
        .build();

    FlightOfferSearch[] flightOffers = amadeus.shopping.flightOffersSearch.get(
                  Params.with("originLocationCode", "MAD")
                          .and("destinationLocationCode", "NYC")
                          .and("departureDate", "2022-11-01")
                          .and("returnDate", "2022-11-09")
                          .and("adults", 1));

    JsonObject body = flightOffers[0].getResponse().getResult();
    FlightOfferSearch[] flightOffersPrediction = amadeus.shopping.flightOffers.prediction.post(body);

    if (flightOffersPrediction[0].getResponse().getStatusCode() != 200) {
        System.out.println("Wrong status code: " + flightOffersPrediction[0].getResponse().getStatusCode());
        System.exit(-1);
    }

    System.out.println(flightOffersPrediction[0]);
  }
}

On Demand Flight Status

from amadeus import Client, ResponseError

amadeus = Client(
    client_id='YOUR_AMADEUS_API_KEY',
    client_secret='YOUR_AMADEUS_API_SECRET'
)

try:
    '''
    Returns flight status of a given flight
    '''
    response = amadeus.schedule.flights.get(carrierCode='AZ',
                                            flightNumber='319',
                                            scheduledDepartureDate='2022-03-13')
    print(response.data)
except ResponseError as error:
    raise error
const Amadeus = require("amadeus");

const amadeus = new Amadeus({
  clientId: "YOUR_API_KEY",
  clientSecret: "YOUR_API_SECRET",
});

async function main() {
  try {
    // What's the current status of my flight?
    const response = await amadeus.schedule.flights.get({
      carrierCode: "AZ",
      flightNumber: "319",
      scheduledDepartureDate: "2022-03-13",
    });

    console.log(response);
  } catch (error) {
    console.error(error);
  }
}

main();
// How to install the library at https://github.com/amadeus4dev/amadeus-java

import com.amadeus.Amadeus;
import com.amadeus.Params;
import com.amadeus.exceptions.ResponseException;
import com.amadeus.Response;
import com.amadeus.resources.DatedFlight;

public class OnDemandFlightStatus {

  public static void main(String[] args) throws ResponseException {

    Amadeus amadeus = Amadeus
        .builder("YOUR_AMADEUS_API_KEY","YOUR_AMADEUS_API_SECRET")
        .build();

    // Returns the status of a given flight
    DatedFlight[] flightStatus = amadeus.schedule.flights.get(Params
        .with("flightNumber", "319")
        .and("carrierCode", "AZ")
        .and("scheduledDepartureDate", "2022-03-13"));

   if (flightStatus[0].getResponse().getStatusCode() != 200) {
        System.out.println("Wrong status code: " + flightStatus[0].getResponse().getStatusCode());
        System.exit(-1);
    }

    System.out.println(flightStatus[0]);
  }
}

Flight Most Traveled Destinations

# Install the Python library from https://pypi.org/project/amadeus
from amadeus import Client, ResponseError

amadeus = Client(
    client_id='YOUR_AMADEUS_API_KEY',
    client_secret='YOUR_AMADEUS_API_SECRET'
)

try:
    '''
    Where were people flying to from Madrid in the January 2017?
    '''
    response = amadeus.travel.analytics.air_traffic.traveled.get(originCityCode='MAD', period='2017-01')
    print(response.data)
except ResponseError as error:
    raise error
const Amadeus = require("amadeus");

const amadeus = new Amadeus({
  clientId: "YOUR_API_KEY",
  clientSecret: "YOUR_API_SECRET",
});

async function main() {
  try {
    // Where were people flying to from Madrid in the January 2017?
    const response = await amadeus.travel.analytics.airTraffic.traveled.get({
      originCityCode: "MAD",
      period: "2017-01",
    });

    console.log(response);
  } catch (error) {
    console.error(error);
  }
}

main();
// How to install the library at https://github.com/amadeus4dev/amadeus-java

import com.amadeus.Amadeus;
import com.amadeus.Params;
import com.amadeus.exceptions.ResponseException;
import com.amadeus.resources.AirTraffic;

public class FlightMostTraveledDestinations {

  public static void main(String[] args) throws ResponseException {

    Amadeus amadeus = Amadeus
        .builder("YOUR_AMADEUS_API_KEY","YOUR_AMADEUS_API_SECRET")
        .build();

    // Flight Most Traveled Destinations
    AirTraffic[] airTraffics = amadeus.travel.analytics.airTraffic.traveled.get(Params
      .with("originCityCode", "MAD")
      .and("period", "2017-01"));

    if (airTraffics[0].getResponse().getStatusCode() != 200) {
        System.out.println("Wrong status code: " + airTraffics[0].getResponse().getStatusCode());
        System.exit(-1);
    }

    System.out.println(airTraffics[0]);
  }
}

Flight Busiest Traveling Period

# Install the Python library from https://pypi.org/project/amadeus
from amadeus import Client, ResponseError

amadeus = Client(
    client_id='YOUR_AMADEUS_API_KEY',
    client_secret='YOUR_AMADEUS_API_SECRET'
)

try:
    '''
    What were the busiest months for Madrid in 2022?
    '''
    response = amadeus.travel.analytics.air_traffic.busiest_period.get(
        cityCode='MAD', period='2017', direction='ARRIVING')
    print(response.data)
except ResponseError as error:
    raise error
const Amadeus = require("amadeus");

const amadeus = new Amadeus({
  clientId: "YOUR_API_KEY",
  clientSecret: "YOUR_API_SECRET",
});

async function main() {
  try {
    // What were the busiest months for Madrid in 2017?
    const response =
      await amadeus.travel.analytics.airTraffic.busiestPeriod.get({
        cityCode: "MAD",
        period: "2017",
        direction: Amadeus.direction.arriving,
      });

    console.log(response);
  } catch (error) {
    console.error(error);
  }
}

main();
// How to install the library at https://github.com/amadeus4dev/amadeus-java

import com.amadeus.Amadeus;
import com.amadeus.Params;
import com.amadeus.exceptions.ResponseException;
import com.amadeus.resources.Period;

public class FlightBusiestPeriod {

  public static void main(String[] args) throws ResponseException {

    Amadeus amadeus = Amadeus
        .builder("YOUR_AMADEUS_API_KEY","YOUR_AMADEUS_API_SECRET")
        .build();

    // Flight Busiest Traveling Period
    Period[] busiestPeriods = amadeus.travel.analytics.airTraffic.busiestPeriod.get(Params
      .with("cityCode", "MAD")
      .and("period", "2017")
      .and("direction", BusiestPeriod.ARRIVING));

    if(busiestPeriods[0].getResponse().getStatusCode() != 200) {
        System.out.println("Wrong status code: " + (busiestPeriods[0].getResponse().getStatusCode());
        System.exit(-1);
    }
    System.out.println((busiestPeriods[0]);
  }
}

Flight Most Booked Destinations

# Install the Python library from https://pypi.org/project/amadeus
from amadeus import Client, ResponseError

amadeus = Client(
    client_id='YOUR_AMADEUS_API_KEY',
    client_secret='YOUR_AMADEUS_API_SECRET'
)

try:
    '''
    Where were people flying to from Madrid in the August 2017?
    '''
    response = amadeus.travel.analytics.air_traffic.booked.get(originCityCode='MAD', period='2017-08')
    print(response.data)
except ResponseError as error:
    raise error
const Amadeus = require("amadeus");

const amadeus = new Amadeus({
  clientId: "YOUR_API_KEY",
  clientSecret: "YOUR_API_SECRET",
});

async function main() {
  try {
    // Where were people flying to from Madrid in the August 2017?
    const response = await amadeus.travel.analytics.airTraffic.booked.get({
      originCityCode: "MAD",
      period: "2017-08",
    });

    console.log(response);
  } catch (error) {
    console.error(error);
  }
}

main();
// How to install the library at https://github.com/amadeus4dev/amadeus-java

import com.amadeus.Amadeus;
import com.amadeus.Params;
import com.amadeus.exceptions.ResponseException;
import com.amadeus.resources.AirTraffic;

public class FlightMostBookedDestinations {

  public static void main(String[] args) throws ResponseException {

    Amadeus amadeus = Amadeus
        .builder("YOUR_AMADEUS_API_KEY","YOUR_AMADEUS_API_SECRET")
        .build();

    // Flight Most Booked Destinations
    AirTraffic[] airTraffics = amadeus.travel.analytics.airTraffic.booked.get(Params
      .with("originCityCode", "MAD")
      .and("period", "2017-08"));

    if (airTraffics[0].getResponse().getStatusCode() != 200) {
        System.out.println("Wrong status code: " + airTraffics[0].getResponse().getStatusCode());
        System.exit(-1);
    }

    System.out.println(airTraffics[0]);
  }
}
# Install the Python library from https://pypi.org/project/amadeus
from amadeus import Client, ResponseError

amadeus = Client(
    client_id='YOUR_AMADEUS_API_KEY',
    client_secret='YOUR_AMADEUS_API_SECRET'
)

try:
    '''
    What is the URL to my online check-in?
    '''
    response = amadeus.reference_data.urls.checkin_links.get(airlineCode='BA')
    print(response.data)
except ResponseError as error:
    raise error
const Amadeus = require("amadeus");

const amadeus = new Amadeus({
  clientId: "YOUR_API_KEY",
  clientSecret: "YOUR_API_SECRET",
});

async function main() {
  try {
    // What is the URL to my online check-in?
    const response = await amadeus.referenceData.urls.checkinLinks.get({
      airlineCode: "BA",
    });

    console.log(response);
  } catch (error) {
    console.error(error);
  }
}

main();
// How to install the library at https://github.com/amadeus4dev/amadeus-java

import com.amadeus.Amadeus;
import com.amadeus.Params;
import com.amadeus.exceptions.ResponseException;
import com.amadeus.resources.CheckinLink;

public class FlightCheckinLinks {

  public static void main(String[] args) throws ResponseException {

    Amadeus amadeus = Amadeus
        .builder("YOUR_AMADEUS_API_KEY","YOUR_AMADEUS_API_SECRET")
        .build();

    CheckinLink[] checkinLinks = amadeus.referenceData.urls.checkinLinks.get(Params
      .with("airlineCode", "BA"));

    if(checkinLinks[0].getResponse().getStatusCode() != 200) {
        System.out.println("Wrong status code: " + (checkinLinks[0].getResponse().getStatusCode()));
        System.exit(-1);
    }

    System.out.println((checkinLinks[0]));
  }
}

Airport Nearest Relevant

# Install the Python library from https://pypi.org/project/amadeus
from amadeus import Client, ResponseError

amadeus = Client(
    client_id='YOUR_AMADEUS_API_KEY',
    client_secret='YOUR_AMADEUS_API_SECRET'
)

try:
    '''
    What relevant airports are there around a specific location?
    '''
    response = amadeus.reference_data.locations.airports.get(longitude=49.000, latitude=2.55)
    print(response.data)
except ResponseError as error:
    raise error
const Amadeus = require("amadeus");

const amadeus = new Amadeus({
  clientId: "YOUR_API_KEY",
  clientSecret: "YOUR_API_SECRET",
});

async function main() {
  try {
    // What relevant airports are there around a specific location?
    const response = await amadeus.referenceData.locations.airports.get({
      longitude: 2.55,
      latitude: 49.0,
    });

    console.log(response);
  } catch (error) {
    console.error(error);
  }
}

main();
// How to install the library at https://github.com/amadeus4dev/amadeus-java

import com.amadeus.Amadeus;
import com.amadeus.Params;
import com.amadeus.exceptions.ResponseException;
import com.amadeus.resources.Location;

public class AirportNearest {

  public static void main(String[] args) throws ResponseException {

    Amadeus amadeus = Amadeus
        .builder("YOUR_API_ID","YOUR_API_SECRET")
        .build();

    // Airport Nearest Relevant (for London)
    Location[] locations = amadeus.referenceData.locations.airports.get(Params
      .with("latitude", 49.0000)
      .and("longitude", 2.55));

    if(locations[0].getResponse().getStatusCode() != 200) {
        System.out.println("Wrong status code: " + locations[0].getResponse().getStatusCode());
        System.exit(-1);
    }
    System.out.println(locations[0]);
  }
}

By keyword

# Install the Python library from https://pypi.org/project/amadeus
from amadeus import Client, ResponseError
from amadeus import Location

amadeus = Client(
    client_id='YOUR_AMADEUS_API_KEY',
    client_secret='YOUR_AMADEUS_API_SECRET'
)

try:
    '''
    Which cities or airports start with 'r'?
    '''
    response = amadeus.reference_data.locations.get(keyword='r',
                                                    subType=Location.ANY)
    print(response.data)
except ResponseError as error:
    raise error
const Amadeus = require("amadeus");

const amadeus = new Amadeus({
  clientId: "YOUR_API_KEY",
  clientSecret: "YOUR_API_KEY",
});

async function main() {
  try {
    // Retrieve information about the LHR airport?
    const response = await amadeus.referenceData.location("ALHR").get();

    console.log(response);
  } catch (error) {
    console.error(error);
  }
}

main();
// How to install the library at https://github.com/amadeus4dev/amadeus-java

import com.amadeus.Amadeus;
import com.amadeus.Params;
import com.amadeus.exceptions.ResponseException;
import com.amadeus.resources.Location;

public class AirportCitySearch {

  public static void main(String[] args) throws ResponseException {

    Amadeus amadeus = Amadeus
        .builder("YOUR_AMADEUS_API_KEY","YOUR_AMADEUS_API_SECRET")
        .build();

    // Get a specific city or airport based on its id
    Location location = amadeus.referenceData
      .location("ALHR").get();

    if(location.getResponse().getStatusCode() != 200) {
        System.out.println("Wrong status code: " + location.getResponse().getStatusCode());
        System.exit(-1);
    }

    System.out.println(location);
  }
}

By Id

# Install the Python library from https://pypi.org/project/amadeus
from amadeus import Client, ResponseError
from amadeus import Location

amadeus = Client(
    client_id='YOUR_AMADEUS_API_KEY',
    client_secret='YOUR_AMADEUS_API_SECRET'
)

try:
    '''
    Which cities or airports start with 'r'?
    '''
    response = amadeus.reference_data.locations.get(keyword='r',
                                                    subType=Location.ANY)
    print(response.data)
except ResponseError as error:
    raise error
const Amadeus = require("amadeus");

const amadeus = new Amadeus({
  clientId: "YOUR_API_KEY",
  clientSecret: "YOUR_API_SECRET",
});

async function main() {
  try {
    // Which cities or airports start with ’r'?
    const response = await amadeus.referenceData.locations.get({
      keyword: "r",
      subType: Amadeus.location.any,
    });

    console.log(response);
  } catch (error) {
    console.error(error);
  }
}

main();
// How to install the library at https://github.com/amadeus4dev/amadeus-java

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 AirportCitySearch {

  public static void main(String[] args) throws ResponseException {

    Amadeus amadeus = Amadeus
        .builder("YOUR_AMADEUS_API_KEY","YOUR_AMADEUS_API_SECRET")
        .build();

    // 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));

    if(locations[0].getResponse().getStatusCode() != 200) {
        System.out.println("Wrong status code: " + locations[0].getResponse().getStatusCode());
        System.exit(-1);
    }
    System.out.println(locations[0]);
  }
}

Airline Code Lookup

# Install the Python library from https://pypi.org/project/amadeus
from amadeus import Client, ResponseError

amadeus = Client(
    client_id='YOUR_AMADEUS_API_KEY',
    client_secret='YOUR_AMADEUS_API_SECRET'
)

try:
    '''
    What's the airline name for the IATA code BA?
    '''
    response = amadeus.reference_data.airlines.get(airlineCodes='BA')
    print(response.data)
except ResponseError as error:
    raise error
const Amadeus = require("amadeus");

const amadeus = new Amadeus({
  clientId: "YOUR_API_KEY",
  clientSecret: "YOUR_API_SECRET",
});

async function main() {
  try {
    // What's the airline name for the IATA code BA?
    const response = await amadeus.referenceData.airlines.get({
      airlineCodes: "BA",
    });
    console.log(response);
  } catch (error) {
    console.error(error);
  }
}

main();
// How to install the library at https://github.com/amadeus4dev/amadeus-java

import com.amadeus.Amadeus;
import com.amadeus.Params;
import com.amadeus.exceptions.ResponseException;
import com.amadeus.resources.Airline;

public class AirlineCodeLookup {

  public static void main(String[] args) throws ResponseException {

    Amadeus amadeus = Amadeus
        .builder("YOUR_AMADEUS_API_KEY","YOUR_AMADEUS_API_SECRET")
        .build();

    Airline[] airlines = amadeus.referenceData.airlines.get(Params
      .with("airlineCodes", "BA"));

    if (airlines[0].getResponse().getStatusCode() != 200) {
        System.out.println("Wrong status code: " + airlines[0].getResponse().getStatusCode());
        System.exit(-1);
    }

    System.out.println(airlines);
  }
}

Hotel

Hotel List

By geolocation

# Install the Python library from https://pypi.org/project/amadeus
from amadeus import ResponseError, Client

amadeus = Client(
    client_id='YOUR_AMADEUS_API_KEY',
    client_secret='YOUR_AMADEUS_API_SECRET'
)

try:
    '''
    Get list of hotels by a geocode
    '''
    response = amadeus.reference_data.locations.hotels.by_geocode.get(longitude=2.160873,latitude=41.397158)

    print(response.data)
except ResponseError as error:
    raise error
const Amadeus = require("amadeus");

const amadeus = new Amadeus({
  clientId: "YOUR_API_KEY",
  clientSecret: "YOUR_API_SECRET",
});

async function main() {
  try {
    // List of hotels in Paris
    const response = await amadeus.referenceData.locations.hotels.byGeocode.get(
      {
        latitude: 48.83152,
        longitude: 2.24691,
      }
    );

    console.log(response);
  } catch (error) {
    console.error(error);
  }
}

main();
// How to install the library at https://github.com/amadeus4dev/amadeus-java

import com.amadeus.Amadeus;
import com.amadeus.Params;
import com.amadeus.exceptions.ResponseException;
import com.amadeus.resources.Hotel;

public class HotelList {

  public static void main(String[] args) throws ResponseException {
    Amadeus amadeus = Amadeus
      .builder("YOUR_AMADEUS_API_KEY", "YOUR_AMADEUS_API_SECRET")
      .build();

    Hotel[] hotels = amadeus.referenceData.locations.hotels.byGeocode.get(
      Params.with("latitude", 48.83152)
        .and("longitude", 2.24691));

    if (hotels[0].getResponse().getStatusCode() != 200) {
      System.out.println("Wrong status code: " + hotels[0].getResponse().getStatusCode());
      System.exit(-1);
    }

    System.out.println(hotels[0]);
  }
}

By city

# Install the Python library from https://pypi.org/project/amadeus
from amadeus import ResponseError, Client

amadeus = Client(
    client_id='YOUR_AMADEUS_API_KEY',
    client_secret='YOUR_AMADEUS_API_SECRET'
)

try:
    '''
    Get list of hotels by city code
    '''
    response = amadeus.reference_data.locations.hotels.by_city.get(cityCode='PAR')

    print(response.data)
except ResponseError as error:
    raise error
const Amadeus = require("amadeus");

const amadeus = new Amadeus({
  clientId: "YOUR_API_KEY",
  clientSecret: "YOUR_API_SECRET",
});

async function main() {
  try {
    // List of hotels in Paris
    const response = await amadeus.referenceData.locations.hotels.byCity.get({
      cityCode: "PAR",
    });

    console.log(response);
  } catch (error) {
    console.error(error);
  }
}

main();
// How to install the library at https://github.com/amadeus4dev/amadeus-java

import com.amadeus.Amadeus;
import com.amadeus.Params;
import com.amadeus.exceptions.ResponseException;
import com.amadeus.resources.Hotel;

public class HotelList {

  public static void main(String[] args) throws ResponseException {
    Amadeus amadeus = Amadeus
      .builder("YOUR_AMADEUS_API_KEY", "YOUR_AMADEUS_API_SECRET")
      .build();

    Hotel[] hotels = amadeus.referenceData.locations.hotels.byCity.get(
      Params.with("cityCode", "PAR"));

    if (hotels[0].getResponse().getStatusCode() != 200) {
      System.out.println("Wrong status code: " + hotels[0].getResponse().getStatusCode());
      System.exit(-1);
    }

    System.out.println(hotels[0]);
  }
}

By hotel

# Install the Python library from https://pypi.org/project/amadeus
from amadeus import ResponseError, Client

amadeus = Client(
    client_id='YOUR_AMADEUS_API_KEY',
    client_secret='YOUR_AMADEUS_API_SECRET'
)

try:
    '''
    Get list of hotels by hotel id
    '''
    response = amadeus.reference_data.locations.hotels.by_hotels.get(hotelIds='ADPAR001')

    print(response.data)
except ResponseError as error:
    raise error
const Amadeus = require("amadeus");

const amadeus = new Amadeus({
  clientId: "YOUR_API_KEY",
  clientSecret: "YOUR_API_SECRET",
});

async function main() {
  try {
    // Get Marriot Hotel information in Paris
    const response = await amadeus.referenceData.locations.hotels.byHotels.get({
      hotelIds: "ARPARARA",
    });

    console.log(response);
  } catch (error) {
    console.error(error);
  }
}

main();
// How to install the library at https://github.com/amadeus4dev/amadeus-java

import com.amadeus.Amadeus;
import com.amadeus.Params;
import com.amadeus.exceptions.ResponseException;
import com.amadeus.resources.Hotel;

public class HotelList {

  public static void main(String[] args) throws ResponseException {
    Amadeus amadeus = Amadeus
      .builder("YOUR_AMADEUS_API_KEY", "YOUR_AMADEUS_API_SECRET")
      .build();

    Hotel[] hotels = amadeus.referenceData.locations.hotels.byHotels.get(
      Params.with("hotelIds", "ARPARARA"));

    if (hotels[0].getResponse().getStatusCode() != 200) {
      System.out.println("Wrong status code: " + hotels[0].getResponse().getStatusCode());
      System.exit(-1);
    }

    System.out.println(hotels[0]);
  }
}

By hotel

# Install the Python library from https://pypi.org/project/amadeus
from amadeus import Client, ResponseError

amadeus = Client(
    client_id='YOUR_AMADEUS_API_KEY',
    client_secret='YOUR_AMADEUS_API_SECRET'
)

try:
    # Get list of available offers in specific hotels by hotel ids
    hotels_by_city = amadeus.shopping.hotel_offers_search.get(
        hotelIds='RTPAR001', adults='2', checkInDate='2023-10-01', checkOutDate='2023-10-04')
except ResponseError as error:
    raise error
const Amadeus = require("amadeus");

const amadeus = new Amadeus({
  clientId: "YOUR_API_KEY",
  clientSecret: "YOUR_API_SECRET",
});

async function main() {
  try {
    // Get list of available offers in specific hotels by hotel ids
    const response = await amadeus.shopping.hotelOffersSearch.get({
      hotelIds: "RTPAR001",
      adults: "2",
      checkInDate: "2023-10-10",
      checkOutDate: "2023-10-12",
    });

    console.log(response);
  } catch (error) {
    console.error(error);
  }
}

main();
// How to install the library at https://github.com/amadeus4dev/amadeus-java

import com.amadeus.Amadeus;
import com.amadeus.Params;
import com.amadeus.exceptions.ResponseException;
import com.amadeus.resources.HotelOfferSearch;

public class HotelSearch {

  public static void main(String[] args) throws ResponseException {
    Amadeus amadeus = Amadeus
      .builder("YOUR_AMADEUS_API_KEY", "YOUR_AMADEUS_API_SECRET")
      .build();

    HotelOfferSearch[] offers = amadeus.shopping.hotelOffersSearch.get(
      Params.with("hotelIds", "RTPAR001")
        .and("adults", 2)
    );

    if (offers[0].getResponse().getStatusCode() != 200) {
      System.out.println("Wrong status code: " + offers[0].getResponse().getStatusCode());
      System.exit(-1);
    }

    System.out.println(offers[0]);
  }
}

By offer

# Install the Python library from https://pypi.org/project/amadeus
from amadeus import Client, ResponseError

amadeus = Client(
    client_id='YOUR_AMADEUS_API_KEY',
    client_secret='YOUR_AMADEUS_API_SECRET'
)

try:
    # Get list of Hotels by city code
    hotels_by_city = amadeus.shopping.hotel_offer_search('63A93695B58821ABB0EC2B33FE9FAB24D72BF34B1BD7D707293763D8D9378FC3').get()
except ResponseError as error:
    raise error
const Amadeus = require("amadeus");

const amadeus = new Amadeus({
  clientId: "YOUR_API_KEY",
  clientSecret: "YOUR_API_SECRET",
});

async function main() {
  try {
    // Check offer conditions of a specific offer id
    const response = await amadeus.shopping
      .hotelOfferSearch(
        "63A93695B58821ABB0EC2B33FE9FAB24D72BF34B1BD7D707293763D8D9378FC3"
      )
      .get();

    console.log(response);
  } catch (error) {
    console.error(error);
  }
}

main();
// How to install the library at https://github.com/amadeus4dev/amadeus-java

import com.amadeus.Amadeus;
import com.amadeus.exceptions.ResponseException;
import com.amadeus.resources.HotelOfferSearch;

public class HotelSearch {

  public static void main(String[] args) throws ResponseException {
    Amadeus amadeus = Amadeus
      .builder("YOUR_AMADEUS_API_KEY", "YOUR_AMADEUS_API_SECRET")
      .build();

    HotelOfferSearch offer = amadeus.shopping.hotelOfferSearch(
        "0W7UU1NT9B")
      .get();

    if (offer.getResponse().getStatusCode() != 200) {
      System.out.println("Wrong status code: " + offer.getResponse().getStatusCode());
      System.exit(-1);
    }

    System.out.println(offer);
  }
}

Hotel Booking

# Install the Python library from https://pypi.org/project/amadeus
from amadeus import Client, ResponseError

amadeus = Client(
    client_id='YOUR_AMADEUS_API_KEY',
    client_secret='YOUR_AMADEUS_API_SECRET'
)

try:
    # Hotel List API to get list of Hotels by city code
    hotels_by_city = amadeus.reference_data.locations.hotels.by_city.get(cityCode='DEL')
    hotelIds = [hotel.get('hotelId') for hotel in hotels_by_city.data[:5]]

    # Hotel Search API to get list of offers for a specific hotel
    hotel_offers = amadeus.shopping.hotel_offers_search.get(
        hotelIds=hotelIds, adults='2', checkInDate='2023-10-01', checkOutDate='2023-10-04')
    offerId = hotel_offers.data[0]['offers'][0]['id']

    guests = [{'id': 1, 'name': {'title': 'MR', 'firstName': 'BOB', 'lastName': 'SMITH'},
               'contact': {'phone': '+33679278416', 'email': 'bob.smith@email.com'}}]
    payments = {'id': 1, 'method': 'creditCard', 'card': {
        'vendorCode': 'VI', 'cardNumber': '4151289722471370', 'expiryDate': '2027-08'}}

    # Hotel booking API to book the offer 
    hotel_booking = amadeus.booking.hotel_bookings.post(
        offerId, guests, payments)
    print(hotel_booking.data)
except ResponseError as error:
    raise error
const Amadeus = require("amadeus");
const amadeus = new Amadeus({
  clientId: "YOUR_API_KEY",
  clientSecret: "YOUR_API_SECRET",
});

async function main() {
  try {
    // Book a hotel in DEL for 2023-10-10 to 2023-10-12

    // 1. Hotel List API to get the list of hotels
    const hotelsList = await amadeus.referenceData.locations.hotels.byCity.get({
      cityCode: "LON",
    });

    // 2. Hotel Search API to get the price and offer id
    const pricingResponse = await amadeus.shopping.hotelOffersSearch.get({
      hotelIds: hotelsList.data[0].hotelId,
      adults: 1,
      checkInDate: "2023-10-10",
      checkOutDate: "2023-10-12",
    });

    // Finally, Hotel Booking API to book the offer
    const response = await amadeus.booking.hotelBookings.post({
      data: {
        offerId: pricingResponse.data[0].offers[0].id,
        guests: [
          {
            id: 1,
            name: {
              title: "MR",
              firstName: "BOB",
              lastName: "SMITH",
            },
            contact: {
              phone: "+33679278416",
              email: "bob.smith@email.com",
            },
          },
        ],
        payments: [
          {
            id: 1,
            method: "creditCard",
            card: {
              vendorCode: "VI",
              cardNumber: "4151289722471370",
              expiryDate: "2022-08",
            },
          },
        ],
      },
    });
    console.log(response);
  } catch (error) {
    console.error(error);
  }
}

main();
// How to install the library at https://github.com/amadeus4dev/amadeus-java

import com.amadeus.Amadeus;
import com.amadeus.exceptions.ResponseException;
import com.amadeus.resources.HotelBooking;

public class HotelBookings {

  public static void main(String[] args) throws ResponseException {

    Amadeus amadeus = Amadeus
        .builder("YOUR_AMADEUS_API_KEY","YOUR_AMAEUS_API_SECRET")
        .build();

    String body = "{\"data\""
        + ":{\"offerId\":\"2F5B1C3B215FA11FD5A44BE210315B18FF91BDA2FEDDD879907A3798F41D1C28\""
        + ",\"guests\":[{\"id\":1,\"name\":{\"title\":\"MR\",\"firstName\":\"BOB\","
        + "\"lastName\" :\"SMITH\"},\"contact\":{\"phone\":\"+33679278416\",\""
        + "email\":\"bob.smith@email.com\"}}],\""
        + "payments\":[{\"id\":1,\"method\":\"creditCard\",\""
        + "card\":{\"vendorCode\":\"VI\",\"cardNumber\""
        + ":\"4151289722471370\",\"expiryDate\":\"2022-08\"}}]}}";

    HotelBooking[] hotel = amadeus.booking.hotelBookings.post(body);

    if (hotel[0].getResponse().getStatusCode() != 200) {
        System.out.println("Wrong status code: " + hotel[0].getResponse().getStatusCode());

        System.exit(-1);
    }

    System.out.println(hotel[0]);
  }
}

Hotel Ratings

# Install the Python library from https://pypi.org/project/amadeus
from amadeus import Client, ResponseError

amadeus = Client(
    client_id='YOUR_AMADEUS_API_KEY',
    client_secret='YOUR_AMADEUS_API_SECRET'
)

try:
    '''
    What travelers think about this hotel?
    '''
    response = amadeus.e_reputation.hotel_sentiments.get(hotelIds = 'ADNYCCTB')
    print(response.data)
except ResponseError as error:
    raise error
const Amadeus = require("amadeus");

const amadeus = new Amadeus({
  clientId: "YOUR_API_KEY",
  clientSecret: "YOUR_API_SECRET",
});

async function main() {
  try {
    // What travelers think about this hotel?
    const response = await amadeus.eReputation.hotelSentiments.get({
      hotelIds: "ADNYCCTB",
    });

    console.log(response);
  } catch (error) {
    console.error(error);
  }
}

main();
// How to install the library at https://github.com/amadeus4dev/amadeus-java

import com.amadeus.Amadeus;
import com.amadeus.Params;
import com.amadeus.exceptions.ResponseException;
import com.amadeus.resources.HotelSentiment;

public class HotelRatings {

  public static void main(String[] args) throws ResponseException {

    Amadeus amadeus = Amadeus
        .builder("YOUR_AMADEUS_API_KEY","YOUR_AMAEUS_API_SECRET")
        .build();

    // Hotel Ratings / Sentiments
    HotelSentiment[] hotelSentiments = amadeus.ereputation.hotelSentiments.get(Params.with("hotelIds", "ADNYCCTB"));

    if (hotelSentiments[0].getResponse().getStatusCode() != 200) {
        System.out.println("Wrong status code: " + hotelSentiments[0].getResponse().getStatusCode());
        System.exit(-1);
    }

    System.out.println(hotelSentiments[0]);
  }
}

Hotel Name Autocomplete

# Install the Python library from https://pypi.org/project/amadeus
from ast import keyword
from amadeus import Client, ResponseError

amadeus = Client(
    client_id='YOUR_AMADEUS_API_KEY',
    client_secret='YOUR_AMADEUS_API_SECRET'
)

try:
    '''
    Hotel name autocomplete for keyword 'PARI' using HOTEL_GDS category of search
    '''
    response = amadeus.reference_data.locations.hotel.get(keyword='PARI', subType=[Hotel.HOTEL_GDS])
    print(response.data)
except ResponseError as error:
    raise error
const Amadeus = require("amadeus");

const amadeus = new Amadeus({
  clientId: "YOUR_API_KEY",
  clientSecret: "YOUR_API_SECRET",
});
// Or `const amadeus = new Amadeus()` if the environment variables are set

async function main() {
  try {
    // Hotel name autocomplete for keyword 'PARI' using  HOTEL_GDS category of search
    const response = await amadeus.referenceData.locations.hotel.get({
      keyword: "PARI",
      subType: "HOTEL_GDS",
    });

    console.log(response);
  } catch (error) {
    console.error(error);
  }
}

main();
// How to install the library at https://github.com/amadeus4dev/amadeus-java
import com.amadeus.Amadeus;
import com.amadeus.exceptions.ResponseException;
import com.amadeus.resources.TripDetail;

// Hotel name autocomplete for keyword 'PARI' using  HOTEL_GDS category of search
public class HotelNameAutocomplete {
  public static void main(String[] args) throws ResponseException {

    Amadeus amadeus = Amadeus
        .builder("YOUR_AMADEUS_API_KEY", "YOUR_AMADEUS_API_SECRET")
        .build();

    // Set query parameters
    Params params = Params
        .with("keyword", "PARI")
        .and("subType", "HOTEL_GDS");

    // Run the query
    Hotel[] hotels = amadeus.referenceData.locations.hotel.get(params);

    if (hotels.getResponse().getStatusCode() != 200) {
      System.out.println("Wrong status code: " + hotels.getResponse().getStatusCode());
      System.exit(-1);
    }

    Arrays.stream(hotels)
        .map(Hotel::getName)
        .forEach(System.out::println);
  }
}

Destination Content

Points of Interest

By geolocation

# Install the Python library from https://pypi.org/project/amadeus
from amadeus import Client, ResponseError

amadeus = Client(
    client_id='YOUR_AMADEUS_API_KEY',
    client_secret='YOUR_AMADEUS_API_SECRET'
)

try:
    '''
    What are the popular places in Barcelona (based on a geo location and a radius)
    '''
    response = amadeus.reference_data.locations.points_of_interest.get(latitude=41.397158, longitude=2.160873)
    print(response.data)
except ResponseError as error:
    raise error
const Amadeus = require("amadeus");

const amadeus = new Amadeus({
  clientId: "YOUR_API_KEY",
  clientSecret: "YOUR_API_SECRET",
});

async function main() {
  try {
    // What are the popular places in Barcelona (based on a geo location and a radius)
    const response = await amadeus.referenceData.locations.pointsOfInterest.get(
      {
        latitude: 41.397158,
        longitude: 2.160873,
      }
    );

    console.log(response);
  } catch (error) {
    console.error(error);
  }
}

main();
// How to install the library at https://github.com/amadeus4dev/amadeus-java

import com.amadeus.Amadeus;
import com.amadeus.Params;
import com.amadeus.exceptions.ResponseException;
import com.amadeus.resources.PointOfInterest;

public class PointsOfInterest {

  public static void main(String[] args) throws ResponseException {

    Amadeus amadeus = Amadeus
        .builder("YOUR_API_ID","YOUR_API_SECRET")
        .build();

    // What are the popular places in Barcelona (based on a geolocation)
    PointOfInterest[] pointsOfInterest = amadeus.referenceData.locations.pointsOfInterest.get(Params
       .with("latitude", "41.39715")
       .and("longitude", "2.160873"));

    if (pointsOfInterest[0].getResponse().getStatusCode() != 200) {
        System.out.println("Wrong status code: " + pointsOfInterest[0].getResponse().getStatusCode());
        System.exit(-1);
    }

    System.out.println(pointsOfInterest[0]);
  }
}

By square

# Install the Python library from https://pypi.org/project/amadeus
from amadeus import Client, ResponseError

amadeus = Client(
    client_id='YOUR_AMADEUS_API_KEY',
    client_secret='YOUR_AMADEUS_API_SECRET'
)

try:
    '''
    What are the popular places in Barcelona? (based on a square)
    '''
    response = amadeus.reference_data.locations.points_of_interest.by_square.get(north=41.397158,
                                                                                 west=2.160873,
                                                                                 south=41.394582,
                                                                                 east=2.177181)
    print(response.data)
except ResponseError as error:
    raise error
const Amadeus = require("amadeus");

const amadeus = new Amadeus({
  clientId: "YOUR_API_KEY",
  clientSecret: "YOUR_API_SECRET",
});

async function main() {
  try {
    // What are the popular places in Barcelona? (based on a square)
    const response =
      await amadeus.referenceData.locations.pointsOfInterest.bySquare.get({
        north: 41.397158,
        west: 2.160873,
        south: 41.394582,
        east: 2.177181,
      });

    console.log(response);
  } catch (error) {
    console.error(error);
  }
}

main();
// How to install the library at https://github.com/amadeus4dev/amadeus-java

import com.amadeus.Amadeus;
import com.amadeus.Params;
import com.amadeus.exceptions.ResponseException;
import com.amadeus.resources.PointOfInterest;

public class PointsOfInterest {

  public static void main(String[] args) throws ResponseException {

    Amadeus amadeus = Amadeus
        .builder("YOUR_AMADEUS_API_KEY","YOUR_AMADEUS_API_SECRET")
        .build();

    // 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"));

    if (pointsOfInterest[0].getResponse().getStatusCode() != 200) {
        System.out.println("Wrong status code: " + pointsOfInterest[0].getResponse().getStatusCode());
        System.exit(-1);
    }

    System.out.println(pointsOfInterest[0]);

  }
}

By Id

# Install the Python library from https://pypi.org/project/amadeus
from amadeus import Client, ResponseError

amadeus = Client(
    client_id='YOUR_AMADEUS_API_KEY',
    client_secret='YOUR_AMADEUS_API_SECRET'
)

try:
    '''
    Give me information about a place based on it's ID
    '''
    response = amadeus.reference_data.locations.point_of_interest('9CB40CB5D0').get()
    print(response.data)
except ResponseError as error:
    raise error
const Amadeus = require("amadeus");

const amadeus = new Amadeus({
  clientId: "YOUR_API_KEY",
  clientSecret: "YOUR_API_SECRET",
});

async function main() {
  try {
    // Extract the information about point of interest with ID '9CB40CB5D0'
    const response = await amadeus.referenceData.locations
      .pointOfInterest("9CB40CB5D0")
      .get();

    console.log(response);
  } catch (error) {
    console.error(error);
  }
}

main();
// How to install the library at https://github.com/amadeus4dev/amadeus-java

import com.amadeus.Amadeus;
import com.amadeus.Params;
import com.amadeus.exceptions.ResponseException;
import com.amadeus.resources.PointOfInterest;

public class PointsOfInterest {

  public static void main(String[] args) throws ResponseException {

    Amadeus amadeus = Amadeus
        .builder("YOUR_AMADEUS_API_KEY","YOUR_AMADEUS_API_SECRET")
        .build();

    // Returns a single Point of Interest from a given id
    PointOfInterest pointOfInterest = amadeus.referenceData.locations.pointOfInterest("9CB40CB5D0").get();

   if (pointsOfInterest[0].getResponse().getStatusCode() != 200) {
        System.out.println("Wrong status code: " + pointsOfInterest[0].getResponse().getStatusCode());
        System.exit(-1);
    }

    System.out.println(pointsOfInterest[0]);
  }
}

Tours and Activities

By geolocation

# Install the Python library from https://pypi.org/project/amadeus
from amadeus import ResponseError, Client

amadeus = Client(
    client_id='YOUR_AMADEUS_API_KEY',
    client_secret='YOUR_AMADEUS_API_SECRET'
)

try:
    '''
    Returns activities for a location in Barcelona based on geolocation coordinates
    '''
    response = amadeus.shopping.activities.get(latitude=40.41436995, longitude=-3.69170868)
    print(response.data)
except ResponseError as error:
    raise error
const Amadeus = require("amadeus");

const amadeus = new Amadeus({
  clientId: "YOUR_API_KEY",
  clientSecret: "YOUR_API_SECRET",
});

async function main() {
  try {
    // Returns activities for a location in Barcelona based on geolocation coordinates
    const response = await amadeus.shopping.activities.get({
      latitude: 41.397158,
      longitude: 2.160873,
    });

    console.log(response);
  } catch (error) {
    console.error(error);
  }
}

main();
// How to install the library at https://github.com/amadeus4dev/amadeus-java

import com.amadeus.Amadeus;
import com.amadeus.Params;
import com.amadeus.exceptions.ResponseException;
import com.amadeus.resources.Activity;


public class ToursActivities {
    public static void main(String[] args) throws ResponseException {
      Amadeus amadeus = Amadeus
              .builder("YOUR_AMADEUS_API_KEY","YOUR_AMADEUS_API_SECRET")
              .build();

      Activity[] activities = amadeus.shopping.activities.get(Params
        .with("latitude", "41.39715")
        .and("longitude", "2.160873"));

       if(activities[0].getResponse().getStatusCode() != 200) {
               System.out.println("Wrong status code: " + activities[0].getResponse().getStatusCode());
               System.exit(-1);
    }
      System.out.println(activities[0]);
    }
}

By square

# Install the Python library from https://pypi.org/project/amadeus
from amadeus import ResponseError, Client

amadeus = Client(
    client_id='YOUR_AMADEUS_API_KEY',
    client_secret='YOUR_AMADEUS_API_SECRET'
)

try:
    '''
    Returns activities in Barcelona within a designated area
    '''
    response = amadeus.shopping.activities.by_square.get(north=41.397158,
                                                         west=2.160873,
                                                         south=41.394582,
                                                         east=2.177181)
    print(response.data)
except ResponseError as error:
    raise error
const Amadeus = require("amadeus");

const amadeus = new Amadeus({
  clientId: "YOUR_API_KEY",
  clientSecret: "YOUR_API_SECRET",
});

async function main() {
  try {
    // What are the best tours and activities in Barcelona? (based on a Square)
    const response = await amadeus.shopping.activities.bySquare.get({
      north: 41.397158,
      west: 2.160873,
      south: 41.394582,
      east: 2.177181,
    });

    console.log(response);
  } catch (error) {
    console.error(error);
  }
}

main();
// How to install the library at https://github.com/amadeus4dev/amadeus-java

import com.amadeus.Amadeus;
import com.amadeus.Params;
import com.amadeus.exceptions.ResponseException;
import com.amadeus.resources.Activity;


public class ToursActivities {
    public static void main(String[] args) throws ResponseException {
      Amadeus amadeus = Amadeus
              .builder("YOUR_AMADEUS_API_KEY","YOUR_AMADEUS_API_SECRET")
              .build();

      Activity[] activities = amadeus.shopping.activities.get(Params
        .with("north", "41.397158")
        .and("west", "2.160873")
        .and("south", "41.394582")
        .and("east", "2.177181"));

       if(activities[0].getResponse().getStatusCode() != 200) {
               System.out.println("Wrong status code: " + activities[0].getResponse().getStatusCode());
               System.exit(-1);
    }
      System.out.println(activities[0]);
    }
}

By Id

# Install the Python library from https://pypi.org/project/amadeus
from amadeus import ResponseError, Client

amadeus = Client(
    client_id='YOUR_AMADEUS_API_KEY',
    client_secret='YOUR_AMADEUS_API_SECRET'
)

try:
    '''
    Returns information of an activity from a given Id
    '''
    response = amadeus.shopping.activity('3216547684').get()
    print(response.data)
except ResponseError as error:
    raise error
const Amadeus = require("amadeus");

const amadeus = new Amadeus({
  clientId: "YOUR_API_KEY",
  clientSecret: "YOUR_API_SECRET",
});

async function main() {
  try {
    // Extract the information about an activity with ID '56777'
    const response = await amadeus.shopping.activity("56777").get({
      north: 41.397158,
      west: 2.160873,
      south: 41.394582,
      east: 2.177181,
    });

    console.log(response);
  } catch (error) {
    console.error(error);
  }
}

main();
// How to install the library at https://github.com/amadeus4dev/amadeus-java

import com.amadeus.Amadeus;
import com.amadeus.Params;
import com.amadeus.exceptions.ResponseException;
import com.amadeus.resources.Activity;


public class ToursActivities {
    public static void main(String[] args) throws ResponseException {
      Amadeus amadeus = Amadeus
              .builder("YOUR_AMADEUS_API_KEY","YOUR_AMADEUS_API_SECRET")
              .build();

      Activity tour = amadeus.shopping.activity("3216547684").get();

       if(tour.getResponse().getStatusCode() != 200) {
               System.out.println("Wrong status code: " + tour.getResponse().getStatusCode());
               System.exit(-1);
       }
       System.out.println(tour);
    }
}

Location Score

# Install the Python library from https://pypi.org/project/amadeus
from ast import keyword
from amadeus import Client, ResponseError

amadeus = Client(
)

try:
    '''
    What are the location scores for the given coordinates?
    '''
    response = amadeus.location.analytics.category_rated_areas.get(latitude=41.397158, longitude=2.160873)
    print(response.data)
except ResponseError as error:
    raise error
const Amadeus = require("amadeus");

const amadeus = new Amadeus();

async function main() {
  try {
    //What are the location scores for the given coordinates?
    const response = await amadeus.location.analytics.categoryRatedAreas.get({
      latitude: 41.397158,
      longitude: 2.160873,
    });

    console.log(response);
  } catch (error) {
    console.error(error);
  }
}

main();
// How to install the library at https://github.com/amadeus4dev/amadeus-java
import com.amadeus.Amadeus;
import com.amadeus.Params;
import com.amadeus.exceptions.ResponseException;
import com.amadeus.resources.ScoredLocation;
import java.util.Arrays;

//Get the score for a given location using its coordinates
public class LocationScore {
    public static void main(String[] args) throws ResponseException {

      Amadeus amadeus = Amadeus
              .builder("YOUR_AMADEUS_API_KEY","YOUR_AMADEUS_API_SECRET")
              .build();

      //Set query parameters
      Params params = Params.with("latitude", 41.397158).and("longitude", 2.160873); 

      //What are the location scores for the given coordinates?
      ScoredLocation[] scoredLocations = amadeus.location.analytics.categoryRatedAreas.get(params);

      if (scoredLocations[0] && scoredLocations[0].getResponse().getStatusCode() != 200) {
        System.out.println("Wrong status code: " + scoredLocations[0].getResponse().getStatusCode());
        System.exit(-1);
      }

      Arrays.stream(scoredLocations)
          .map(ScoredLocation::getCategoryScores)
          .forEach(System.out::println);
    }
}

Trip

# Install the Python library from https://pypi.org/project/amadeus
from amadeus import Client, ResponseError

amadeus = Client(
    client_id='YOUR_AMADEUS_API_KEY',
    client_secret='YOUR_AMADEUS_API_SECRET'
)

try:
    '''
    What are the cities matched with keyword 'Paris' ?
    '''
    response = amadeus.reference_data.locations.cities.get(keyword='Paris')
    print(response.data)
except ResponseError as error:
    raise error
const Amadeus = require("amadeus");

const amadeus = new Amadeus({
  clientId: "YOUR_API_KEY",
  clientSecret: "YOUR_API_SECRET",
});

async function main() {
  try {
    // Finds cities that match a specific word or string of letters.
    // Return a list of cities matching a keyword 'Paris'
    const response = await amadeus.referenceData.locations.cities.get({
      keyword: "Paris",
    });

    console.log(response);
  } catch (error) {
    console.error(error);
  }
}

main();
// How to install the library at https://github.com/amadeus4dev/amadeus-java

import com.amadeus.Amadeus;
import com.amadeus.exceptions.ResponseException;
import com.amadeus.resources.City;

public class CitySearch {

  public static void main(String[] args) throws ResponseException {
    Amadeus amadeus = Amadeus
      .builder("YOUR_AMADEUS_API_KEY", "YOUR_AMADEUS_API_SECRET")
      .build();

    City[] cities = amadeus.referenceData.locations.cities.get(
      Params.with("keyword","PARIS")
    );

    if (cities[0].getResponse().getStatusCode() != 200) {
      System.out.println("Wrong status code: " + cities[0].getResponse().getStatusCode());
      System.exit(-1);
    }

    System.out.println(cities[0]);
  }
}

Trip Purpose Prediction

# Install the Python library from https://pypi.org/project/amadeus
from amadeus import Client, ResponseError

amadeus = Client(
    client_id='YOUR_AMADEUS_API_KEY',
    client_secret='YOUR_AMADEUS_API_SECRET'
)

try:
    '''
    The passenger is traveling for leisure or business?
    '''
    response = amadeus.travel.predictions.trip_purpose.get(originLocationCode='NYC', destinationLocationCode='MAD',
                                                           departureDate='2022-08-01', returnDate='2022-08-12',
                                                           searchDate='2022-06-11')
    print(response.data)
except ResponseError as error:
    raise error
const Amadeus = require("amadeus");

const amadeus = new Amadeus({
  clientId: "YOUR_API_KEY",
  clientSecret: "YOUR_API_SECRET",
});

async function main() {
  try {
    // The passenger is traveling for leisure or business?
    const response = await amadeus.travel.predictions.tripPurpose.get({
      originLocationCode: "NYC",
      destinationLocationCode: "MAD",
      departureDate: "2022-08-01",
      returnDate: "2022-08-12",
    });

    console.log(response);
  } catch (error) {
    console.error(error);
  }
}

main();
// How to install the library at https://github.com/amadeus4dev/amadeus-java

import com.amadeus.Amadeus;
import com.amadeus.Params;
import com.amadeus.exceptions.ResponseException;
import com.amadeus.resources.Prediction;

public class TripPurposePrediction {

  public static void main(String[] args) throws ResponseException {

    Amadeus amadeus = Amadeus
        .builder("YOUR_AMADEUS_API_KEY","YOUR_AMADEUS_API_SECRET")
        .build();

    // Predict the purpose of the trip: business or leisure
    Prediction tripPurpose = amadeus.travel.predictions.tripPurpose.get(Params
        .with("originLocationCode", "NYC")
        .and("destinationLocationCode", "MAD")
        .and("departureDate", "2022-08-01")
        .and("returnDate", "2022-08-12"));

    if(tripPurpose.getResponse().getStatusCode() != 200) {
        System.out.println("Wrong status code" + tripPurpose.getResponse().getStatusCode());
        System.exit(-1);
    }

    System.out.println(tripPurpose);
  }
}

Travel Recommendations

from amadeus import Client, ResponseError

amadeus = Client(
    client_id='YOUR_AMADEUS_API_KEY',
    client_secret='YOUR_AMADEUS_API_SECRET'
)

try:
    '''
    Recommends travel destinations similar to Paris for travelers in France
    '''
    response = amadeus.reference_data.recommended_locations.get(cityCodes='PAR', travelerCountryCode='FR')
    print(response.data)
except ResponseError as error:
    raise error
const Amadeus = require("amadeus");

const amadeus = new Amadeus({
  clientId: "YOUR_API_KEY",
  clientSecret: "YOUR_API_SECRET",
});

async function main() {
  try {
    // Recommended locations similar to PAR
    const response = await amadeus.referenceData.recommendedLocations.get({
      cityCodes: "PAR",
      travelerCountryCode: "FR",
    });

    console.log(response);
  } catch (error) {
    console.log(error);
  }
}

main();
// How to install the library at https://github.com/amadeus4dev/amadeus-java

import com.amadeus.Amadeus;
import com.amadeus.Params;
import com.amadeus.exceptions.ResponseException;
import com.amadeus.resources.Location;

public class TravelRecommendations {
    public static void main(String[] args) throws ResponseException {
      Amadeus amadeus = Amadeus
              .builder("YOUR_AMADEUS_API_KEY","YOUR_AMADEUS_API_SECRET")
              .build();

        Location[] destinations = amadeus.referenceData.recommendedLocations.get(Params
                .with("cityCodes", "PAR")
                .and("travelerCountryCode", "FR"));

        if (destinations.length != 0) {
          if (destinations[0].getResponse().getStatusCode() != 200) {
            System.out.println("Wrong status code: " + destinations[0].getResponse().getStatusCode());
            System.exit(-1);
          }
          System.out.println(destinations[0]);
        }
        else {
          System.out.println("No recommendations found");
          System.exit(-1);
        }
     }
}

Cars and Transfers

import json
from amadeus import Client, ResponseError

amadeus = Client(
    client_id='YOUR_AMADEUS_API_KEY',
    client_secret='YOUR_AMADEUS_API_SECRET'
)

json_string = '{ "startLocationCode": "CDG", "endAddressLine": "Avenue Anatole France, 5", "endCityName": "Paris", "endZipCode": "75007", "endCountryCode": "FR", \
"endName": "Souvenirs De La Tour", "endGeoCode": "48.859466,2.2976965", "transferType": "PRIVATE", "startDateTime": "2023-11-10T10:30:00", "providerCodes": "TXO", \
"passengers": 2, "stopOvers": [ { "duration": "PT2H30M", "sequenceNumber": 1, "addressLine": "Avenue de la Bourdonnais, 19", "countryCode": "FR", "cityName": "Paris", \
"zipCode": "75007", "name": "De La Tours", "geoCode": "48.859477,2.2976985", "stateCode": "FR" } ], "startConnectedSegment": \
{ "transportationType": "FLIGHT", "transportationNumber": "AF380", "departure": { "localDateTime": "2023-11-10T09:00:00", "iataCode": "NCE" }, \
"arrival": { "localDateTime": "2023-11-10T10:00:00", "iataCode": "CDG" } }, "passengerCharacteristics": [ { "passengerTypeCode": "ADT", "age": 20 }, \
{ "passengerTypeCode": "CHD", "age": 10 } ] }'

body = json.loads(json_string)
try:
    response = amadeus.shopping.transfer_offers.post(body)
    print(response.data)
except ResponseError as error:
    raise error
const Amadeus = require("amadeus");

const amadeus = new Amadeus({
  clientId: "YOUR_AMADEUS_API_KEY",
  clientSecret: "YOUR_AMADEUS_API_SECRET",
});

async function main() {
  try {
    const response = await amadeus.shopping.transferOffers.post({
      startLocationCode: "CDG",
      endAddressLine: "Avenue Anatole France, 5",
      endCityName: "Paris",
      endZipCode: "75007",
      endCountryCode: "FR",
      endName: "Souvenirs De La Tour",
      endGeoCode: "48.859466,2.2976965",
      transferType: "PRIVATE",
      startDateTime: "2023-11-10T10:30:00",
      providerCodes: "TXO",
      passengers: 2,
      stopOvers: [
        {
          duration: "PT2H30M",
          sequenceNumber: 1,
          addressLine: "Avenue de la Bourdonnais, 19",
          countryCode: "FR",
          cityName: "Paris",
          zipCode: "75007",
          name: "De La Tours",
          geoCode: "48.859477,2.2976985",
          stateCode: "FR",
        },
      ],
      startConnectedSegment: {
        transportationType: "FLIGHT",
        transportationNumber: "AF380",
        departure: {
          localDateTime: "2023-11-10T09:00:00",
          iataCode: "NCE",
        },
        arrival: {
          localDateTime: "2023-11-10T10:00:00",
          iataCode: "CDG",
        },
      },
      passengerCharacteristics: [
        {
          passengerTypeCode: "ADT",
          age: 20,
        },
        {
          passengerTypeCode: "CHD",
          age: 10,
        },
      ],
    });

    console.log(response);
  } catch (error) {
    console.error(error);
  }
}

main();
// How to install the library at https://github.com/amadeus4dev/amadeus-java
import com.amadeus.Amadeus;
import com.amadeus.exceptions.ResponseException;
import com.amadeus.resources.TransferOffersPost;

public class TransferSearch {

  public static void main(String[] args) throws ResponseException {

    Amadeus amadeus = Amadeus
        .builder("YOUR_AMADEUS_API_KEY", "YOUR_AMADEUS_API_SECRET")
        .build();

    String body = "{\"startLocationCode\":\"CDG\",\"endAddressLine\":\"AvenueAnatoleFrance,5\",\"endCityName\":\"Paris\",\"endZipCode\":\"75007\",\"endCountryCode\":\"FR\",\"endName\":\"SouvenirsDeLaTour\",\"endGeoCode\":\"48.859466,2.2976965\",\"transferType\":\"PRIVATE\",\"startDateTime\":\"2023-11-10T10:30:00\",\"providerCodes\":\"TXO\",\"passengers\":2,\"stopOvers\":[{\"duration\":\"PT2H30M\",\"sequenceNumber\":1,\"addressLine\":\"AvenuedelaBourdonnais,19\",\"countryCode\":\"FR\",\"cityName\":\"Paris\",\"zipCode\":\"75007\",\"name\":\"DeLaTours\",\"geoCode\":\"48.859477,2.2976985\",\"stateCode\":\"FR\"}],\"startConnectedSegment\":{\"transportationType\":\"FLIGHT\",\"transportationNumber\":\"AF380\",\"departure\":{\"localDateTime\":\"2023-11-10T09:00:00\",\"iataCode\":\"NCE\"},\"arrival\":{\"localDateTime\":\"2023-11-10T10:00:00\",\"iataCode\":\"CDG\"}},\"passengerCharacteristics\":[{\"passengerTypeCode\":\"ADT\",\"age\":20},{\"passengerTypeCode\":\"CHD\",\"age\":10}]}";

    TransferOffersPost[] transfers = amadeus.shopping.transferOffers.post(body);

    if (transfers[0].getResponse().getStatusCode() != 200) {
      System.out.println("Wrong status code: " + transfers[0].getResponse().getStatusCode());
      System.exit(-1);
    }

    System.out.println(transfers[0]);
  }
}

Transfer Booking

import json
from amadeus import Client, ResponseError

amadeus = Client(
    client_id='YOUR_AMADEUS_API_KEY',
    client_secret='YOUR_AMADEUS_API_SECRET'
)

searchBody = '{ "startLocationCode": "CDG", "endAddressLine": "Avenue Anatole France, 5", "endCityName": "Paris", \
    "endZipCode": "75007", "endCountryCode": "FR", "endName": "Souvenirs De La Tour", "endGeoCode": "48.859466,2.2976965", \
    "transferType": "PRIVATE", "startDateTime": "2023-11-10T10:30:00", "providerCodes": "TXO", "passengers": 2, \
    "stopOvers": [ { "duration": "PT2H30M", "sequenceNumber": 1, "addressLine": "Avenue de la Bourdonnais, 19", \
    "countryCode": "FR", "cityName": "Paris", "zipCode": "75007", "name": "De La Tours", "geoCode": "48.859477,2.2976985", \
    "stateCode": "FR" } ], "startConnectedSegment": { "transportationType": "FLIGHT", "transportationNumber": "AF380", \
    "departure": { "localDateTime": "2023-11-10T09:00:00", "iataCode": "NCE" }, \
    "arrival": { "localDateTime": "2023-11-10T10:00:00", "iataCode": "CDG" } }, \
    "passengerCharacteristics": [ { "passengerTypeCode": "ADT", "age": 20 }, { "passengerTypeCode": "CHD", "age": 10 } ] }'

# Search list of transfers from Transfer Search API
searchResponse = amadeus.shopping.transfer_offers.post(json.loads(searchBody))
offerId = searchResponse.data[0]['id']


offerBody = '{ "data": { "note": "Note to driver", "passengers": [ { "firstName": "John", "lastName": "Doe", "title": "MR", \
    "contacts": { "phoneNumber": "+33123456789", "email": "user@email.com" }, \
    "billingAddress": { "line": "Avenue de la Bourdonnais, 19", "zip": "75007", "countryCode": "FR", "cityName": "Paris" } } ], \
    "agency": { "contacts": [ { "email": { "address": "abc@test.com" } } ] }, \
    "payment": { "methodOfPayment": "CREDIT_CARD", "creditCard": \
    { "number": "4111111111111111", "holderName": "JOHN DOE", "vendorCode": "VI", "expiryDate": "0928", "cvv": "111" } }, \
    "extraServices": [ { "code": "EWT", "itemId": "EWT0291" } ], "equipment": [ { "code": "BBS" } ], \
    "corporation": { "address": { "line": "5 Avenue Anatole France", "zip": "75007", "countryCode": "FR", "cityName": "Paris" }, "info": { "AU": "FHOWMD024", "CE": "280421GH" } }, \
    "startConnectedSegment": { "transportationType": "FLIGHT", "transportationNumber": "AF380", \
    "departure": { "uicCode": "7400001", "iataCode": "CDG", "localDateTime": "2023-03-27T20:03:00" }, \
    "arrival": { "uicCode": "7400001", "iataCode": "CDG", "localDateTime": "2023-03-27T20:03:00" } }, \
    "endConnectedSegment": { "transportationType": "FLIGHT", "transportationNumber": "AF380", \
    "departure": { "uicCode": "7400001", "iataCode": "CDG", "localDateTime": "2023-03-27T20:03:00" }, \
    "arrival": { "uicCode": "7400001", "iataCode": "CDG", "localDateTime": "2023-03-27T20:03:00" } } } }'

# Book the first transfer from Transfer Search API via Transfer Booking API
try:
    response = amadeus.ordering.transfer_orders.post(json.loads(offerBody), offerId=offerId)
    print(response.data)
except ResponseError as error:
    raise error
const Amadeus = require("amadeus");

const amadeus = new Amadeus({
  clientId: "YOUR_AMADEUS_API_KEY",
  clientSecret: "YOUR_AMADEUS_API_SECRET",
});

async function main() {
  try {
    // Search list of transfers from Transfer Search API
    const searchResponse = await amadeus.shopping.transferOffers.post({
      startLocationCode: "CDG",
      endAddressLine: "Avenue Anatole France, 5",
      endCityName: "Paris",
      endZipCode: "75007",
      endCountryCode: "FR",
      endName: "Souvenirs De La Tour",
      endGeoCode: "48.859466,2.2976965",
      transferType: "PRIVATE",
      startDateTime: "2023-11-10T10:30:00",
      providerCodes: "TXO",
      passengers: 2,
      stopOvers: [
        {
          duration: "PT2H30M",
          sequenceNumber: 1,
          addressLine: "Avenue de la Bourdonnais, 19",
          countryCode: "FR",
          cityName: "Paris",
          zipCode: "75007",
          name: "De La Tours",
          geoCode: "48.859477,2.2976985",
          stateCode: "FR",
        },
      ],
      startConnectedSegment: {
        transportationType: "FLIGHT",
        transportationNumber: "AF380",
        departure: {
          localDateTime: "2023-11-10T09:00:00",
          iataCode: "NCE",
        },
        arrival: {
          localDateTime: "2023-11-10T10:00:00",
          iataCode: "CDG",
        },
      },
      passengerCharacteristics: [
        {
          passengerTypeCode: "ADT",
          age: 20,
        },
        {
          passengerTypeCode: "CHD",
          age: 10,
        },
      ],
    });

    // Retrieve offer ID from the response of the first endpoint (Transfer Search API)
    const offerId = searchResponse.data[0].id;
    // Book the first transfer from Transfer Search API via Transfer Booking API
    const orderResponse = await amadeus.ordering.transferOrders.post(
      {
        data: {
          note: "Note to driver",
          passengers: [
            {
              firstName: "John",
              lastName: "Doe",
              title: "MR",
              contacts: {
                phoneNumber: "+33123456789",
                email: "user@email.com",
              },
              billingAddress: {
                line: "Avenue de la Bourdonnais, 19",
                zip: "75007",
                countryCode: "FR",
                cityName: "Paris",
              },
            },
          ],
          agency: {
            contacts: [
              {
                email: {
                  address: "abc@test.com",
                },
              },
            ],
          },
          payment: {
            methodOfPayment: "CREDIT_CARD",
            creditCard: {
              number: "4111111111111111",
              holderName: "JOHN DOE",
              vendorCode: "VI",
              expiryDate: "0928",
              cvv: "111",
            },
          },
          extraServices: [
            {
              code: "EWT",
              itemId: "EWT0291",
            },
          ],
          equipment: [
            {
              code: "BBS",
            },
          ],
          corporation: {
            address: {
              line: "5 Avenue Anatole France",
              zip: "75007",
              countryCode: "FR",
              cityName: "Paris",
            },
            info: {
              AU: "FHOWMD024",
              CE: "280421GH",
            },
          },
          startConnectedSegment: {
            transportationType: "FLIGHT",
            transportationNumber: "AF380",
            departure: {
              uicCode: "7400001",
              iataCode: "CDG",
              localDateTime: "2023-03-27T20:03:00",
            },
            arrival: {
              uicCode: "7400001",
              iataCode: "CDG",
              localDateTime: "2023-03-27T20:03:00",
            },
          },
          endConnectedSegment: {
            transportationType: "FLIGHT",
            transportationNumber: "AF380",
            departure: {
              uicCode: "7400001",
              iataCode: "CDG",
              localDateTime: "2023-03-27T20:03:00",
            },
            arrival: {
              uicCode: "7400001",
              iataCode: "CDG",
              localDateTime: "2023-03-27T20:03:00",
            },
          },
        },
      },
      offerId
    );

    console.log(orderResponse);
  } catch (error) {
    console.error(error);
  }
}

main();
// How to install the library at https://github.com/amadeus4dev/amadeus-java
import com.amadeus.Amadeus;
import com.amadeus.Params;
import com.amadeus.exceptions.ResponseException;
import com.amadeus.resources.TransferOrder;

public class TransferOrders {

    public static void main(String[] args) throws ResponseException {

        Amadeus amadeus = Amadeus
                .builder("YOUR_AMADEUS_API_KEY", "YOUR_AMADEUS_API_SECRET")
                .build();
        Params params = Params.with("offerId", "5976726751");

        String body = "{\n  \"data\": {\n    \"note\": \"Note to driver\",\n    \"passengers\": [\n      {\n        \"firstName\": \"John\",\n        \"lastName\": \"Doe\",\n        \"title\": \"MR\",\n        \"contacts\": {\n          \"phoneNumber\": \"+33123456789\",\n          \"email\": \"user@email.com\"\n        },\n        \"billingAddress\": {\n          \"line\": \"Avenue de la Bourdonnais, 19\",\n          \"zip\": \"75007\",\n          \"countryCode\": \"FR\",\n          \"cityName\": \"Paris\"\n        }\n      }\n    ],\n    \"agency\": {\n      \"contacts\": [\n        {\n          \"email\": {\n            \"address\": \"abc@test.com\"\n          }\n        }\n      ]\n    },\n    \"payment\": {\n      \"methodOfPayment\": \"CREDIT_CARD\",\n      \"creditCard\": {\n        \"number\": \"4111111111111111\",\n        \"holderName\": \"JOHN DOE\",\n        \"vendorCode\": \"VI\",\n        \"expiryDate\": \"0928\",\n        \"cvv\": \"111\"\n      }\n    },\n    \"extraServices\": [\n      {\n        \"code\": \"EWT\",\n        \"itemId\": \"EWT0291\"\n      }\n    ],\n    \"equipment\": [\n      {\n        \"code\": \"BBS\"\n      }\n    ],\n    \"corporation\": {\n      \"address\": {\n        \"line\": \"5 Avenue Anatole France\",\n        \"zip\": \"75007\",\n        \"countryCode\": \"FR\",\n        \"cityName\": \"Paris\"\n      },\n      \"info\": {\n        \"AU\": \"FHOWMD024\",\n        \"CE\": \"280421GH\"\n      }\n    },\n    \"startConnectedSegment\": {\n      \"transportationType\": \"FLIGHT\",\n      \"transportationNumber\": \"AF380\",\n      \"departure\": {\n        \"uicCode\": \"7400001\",\n        \"iataCode\": \"CDG\",\n        \"localDateTime\": \"2023-03-27T20:03:00\"\n      },\n      \"arrival\": {\n        \"uicCode\": \"7400001\",\n        \"iataCode\": \"CDG\",\n        \"localDateTime\": \"2023-03-27T20:03:00\"\n      }\n    },\n    \"endConnectedSegment\": {\n      \"transportationType\": \"FLIGHT\",\n      \"transportationNumber\": \"AF380\",\n      \"departure\": {\n        \"uicCode\": \"7400001\",\n        \"iataCode\": \"CDG\",\n        \"localDateTime\": \"2023-03-27T20:03:00\"\n      },\n      \"arrival\": {\n        \"uicCode\": \"7400001\",\n        \"iataCode\": \"CDG\",\n        \"localDateTime\": \"2023-03-27T20:03:00\"\n      }\n    }\n  }\n}";

        TransferOrder transfers = amadeus.ordering.transferOrders.post(body, params);
        if (transfers.getResponse().getStatusCode() != 200) {
            System.out.println("Wrong status code: " + transfers.getResponse().getStatusCode());
            System.exit(-1);
        }

        System.out.println(transfers);
    }
}

Transfer Management

import json
from amadeus import Client, ResponseError

amadeus = Client(
    client_id='YOUR_AMADEUS_API_KEY',
    client_secret='YOUR_AMADEUS_API_SECRET'
)
searchBody = '{ "startLocationCode": "CDG", "endAddressLine": "Avenue Anatole France, 5", "endCityName": "Paris", \
    "endZipCode": "75007", "endCountryCode": "FR", "endName": "Souvenirs De La Tour", "endGeoCode": "48.859466,2.2976965", \
    "transferType": "PRIVATE", "startDateTime": "2023-11-10T10:30:00", "providerCodes": "TXO", "passengers": 2, \
    "stopOvers": [ { "duration": "PT2H30M", "sequenceNumber": 1, "addressLine": "Avenue de la Bourdonnais, 19", \
    "countryCode": "FR", "cityName": "Paris", "zipCode": "75007", "name": "De La Tours", "geoCode": "48.859477,2.2976985", \
    "stateCode": "FR" } ], "startConnectedSegment": { "transportationType": "FLIGHT", "transportationNumber": "AF380", \
    "departure": { "localDateTime": "2023-11-10T09:00:00", "iataCode": "NCE" }, \
    "arrival": { "localDateTime": "2023-11-10T10:00:00", "iataCode": "CDG" } }, \
    "passengerCharacteristics": [ { "passengerTypeCode": "ADT", "age": 20 }, { "passengerTypeCode": "CHD", "age": 10 } ] }'

# Search list of transfers from Transfer Search API
searchResponse = amadeus.shopping.transfer_offers.post(json.loads(searchBody))
offerId = searchResponse.data[0]['id']


offerBody = '{ "data": { "note": "Note to driver", "passengers": [ { "firstName": "John", "lastName": "Doe", "title": "MR", \
    "contacts": { "phoneNumber": "+33123456789", "email": "user@email.com" }, \
    "billingAddress": { "line": "Avenue de la Bourdonnais, 19", "zip": "75007", "countryCode": "FR", "cityName": "Paris" } } ], \
    "agency": { "contacts": [ { "email": { "address": "abc@test.com" } } ] }, \
    "payment": { "methodOfPayment": "CREDIT_CARD", "creditCard": \
    { "number": "4111111111111111", "holderName": "JOHN DOE", "vendorCode": "VI", "expiryDate": "0928", "cvv": "111" } }, \
    "extraServices": [ { "code": "EWT", "itemId": "EWT0291" } ], "equipment": [ { "code": "BBS" } ], \
    "corporation": { "address": { "line": "5 Avenue Anatole France", "zip": "75007", "countryCode": "FR", "cityName": "Paris" }, "info": { "AU": "FHOWMD024", "CE": "280421GH" } }, \
    "startConnectedSegment": { "transportationType": "FLIGHT", "transportationNumber": "AF380", \
    "departure": { "uicCode": "7400001", "iataCode": "CDG", "localDateTime": "2023-03-27T20:03:00" }, \
    "arrival": { "uicCode": "7400001", "iataCode": "CDG", "localDateTime": "2023-03-27T20:03:00" } }, \
    "endConnectedSegment": { "transportationType": "FLIGHT", "transportationNumber": "AF380", \
    "departure": { "uicCode": "7400001", "iataCode": "CDG", "localDateTime": "2023-03-27T20:03:00" }, \
    "arrival": { "uicCode": "7400001", "iataCode": "CDG", "localDateTime": "2023-03-27T20:03:00" } } } }'

# Book the first transfer from Transfer Search API via Transfer Booking API
orderResponse =  amadeus.ordering.transfer_orders.post(json.loads(offerBody), offerId=offerId)
orderId = orderResponse.data['id']
confirmNbr = orderResponse.data['transfers'][0]['confirmNbr'] 

# Book the first transfer from Transfer Search API via Transfer Booking API
try:
    amadeus.ordering.transfer_order(orderId).transfers.cancellation.post('', confirmNbr=confirmNbr)
except ResponseError as error:
    raise error
const Amadeus = require("amadeus");

const amadeus = new Amadeus({
  clientId: "YOUR_AMADEUS_API_KEY",
  clientSecret: "YOUR_AMADEUS_API_SECRET",
});

async function main() {
  try {
    const searchResponse = await amadeus.shopping.transferOffers.post({
      startLocationCode: "CDG",
      endAddressLine: "Avenue Anatole France, 5",
      endCityName: "Paris",
      endZipCode: "75007",
      endCountryCode: "FR",
      endName: "Souvenirs De La Tour",
      endGeoCode: "48.859466,2.2976965",
      transferType: "PRIVATE",
      startDateTime: "2023-11-10T10:30:00",
      providerCodes: "TXO",
      passengers: 2,
      stopOvers: [
        {
          duration: "PT2H30M",
          sequenceNumber: 1,
          addressLine: "Avenue de la Bourdonnais, 19",
          countryCode: "FR",
          cityName: "Paris",
          zipCode: "75007",
          name: "De La Tours",
          geoCode: "48.859477,2.2976985",
          stateCode: "FR",
        },
      ],
      startConnectedSegment: {
        transportationType: "FLIGHT",
        transportationNumber: "AF380",
        departure: {
          localDateTime: "2023-11-10T09:00:00",
          iataCode: "NCE",
        },
        arrival: {
          localDateTime: "2023-11-10T10:00:00",
          iataCode: "CDG",
        },
      },
      passengerCharacteristics: [
        {
          passengerTypeCode: "ADT",
          age: 20,
        },
        {
          passengerTypeCode: "CHD",
          age: 10,
        },
      ],
    });

    // Retrieve offer ID from the response of the first endpoint (Transfer search API)
    const offerId = searchResponse.data[0].id;
    const orderResponse = await amadeus.ordering.transferOrders.post(
      {
        data: {
          note: "Note to driver",
          passengers: [
            {
              firstName: "John",
              lastName: "Doe",
              title: "MR",
              contacts: {
                phoneNumber: "+33123456789",
                email: "user@email.com",
              },
              billingAddress: {
                line: "Avenue de la Bourdonnais, 19",
                zip: "75007",
                countryCode: "FR",
                cityName: "Paris",
              },
            },
          ],
          agency: {
            contacts: [
              {
                email: {
                  address: "abc@test.com",
                },
              },
            ],
          },
          payment: {
            methodOfPayment: "CREDIT_CARD",
            creditCard: {
              number: "4111111111111111",
              holderName: "JOHN DOE",
              vendorCode: "VI",
              expiryDate: "0928",
              cvv: "111",
            },
          },
          extraServices: [
            {
              code: "EWT",
              itemId: "EWT0291",
            },
          ],
          equipment: [
            {
              code: "BBS",
            },
          ],
          corporation: {
            address: {
              line: "5 Avenue Anatole France",
              zip: "75007",
              countryCode: "FR",
              cityName: "Paris",
            },
            info: {
              AU: "FHOWMD024",
              CE: "280421GH",
            },
          },
          startConnectedSegment: {
            transportationType: "FLIGHT",
            transportationNumber: "AF380",
            departure: {
              uicCode: "7400001",
              iataCode: "CDG",
              localDateTime: "2023-03-27T20:03:00",
            },
            arrival: {
              uicCode: "7400001",
              iataCode: "CDG",
              localDateTime: "2023-03-27T20:03:00",
            },
          },
          endConnectedSegment: {
            transportationType: "FLIGHT",
            transportationNumber: "AF380",
            departure: {
              uicCode: "7400001",
              iataCode: "CDG",
              localDateTime: "2023-03-27T20:03:00",
            },
            arrival: {
              uicCode: "7400001",
              iataCode: "CDG",
              localDateTime: "2023-03-27T20:03:00",
            },
          },
        },
      },
      offerId
    );

    // Retrieve order ID from the response of the second endpoint (Transfer Order API)
    const orderId = orderResponse.data.id;
    // Retrieve confirmation number from the response of the second endpoint (Transfer Order API)
    const confirmNbr = orderResponse.data.transfers[0].confirmNbr;

    // Transfer Management API to cancel the transfer order.
    const response = await amadeus.ordering
      .transferOrder(orderId)
      .transfers.cancellation.post({}, confirmNbr);

    console.log(response);
  } catch (error) {
    console.error(error);
  }
}

main();
// How to install the library at https://github.com/amadeus4dev/amadeus-java
import com.amadeus.Amadeus;
import com.amadeus.Params;
import com.amadeus.exceptions.ResponseException;
import com.amadeus.resources.TransferCancellation;

public class TransferManagement {

  public static void main(String[] args) throws ResponseException {

    Amadeus amadeus = Amadeus
        .builder("YOUR_AMADEUS_API_KEY", "YOUR_AMADEUS_API_SECRET")
        .build();
    Params params = Params.with("confirmNbr", "12029761");

    TransferCancellation transfers = amadeus.ordering
        .transferOrder("VEg0Wk43fERPRXwyMDIzLTA2LTE1VDE1OjUwOjE4").transfers.cancellation.post(params);
    if (transfers.getResponse().getStatusCode() != 200) {
      System.out.println("Wrong status code: " + transfers.getResponse().getStatusCode());
      System.exit(-1);
    }

    System.out.println(transfers);
  }
}

Last update: September 30, 2024