Skip to content

Node library for the Amadeus travel APIs written in TypeScript

License

Notifications You must be signed in to change notification settings

amadeus4dev-examples/amadeus-ts

 
 

Repository files navigation

Amadeus Node SDK Written In TypeScript

Amadeus provides a rich set of APIs for the travel industry. For more details, check out the Amadeus for Developers portal.

Important

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

Key Features

  • ✅ Full TypeScript support.
  • 🚀 Smaller package size.
  • ✨ Eliminates the need for manual JSON.stringify usage.

Installation

This module has been tested using Node LTS versions (16.x, 18.x, 20.x). You can install it using npm, pnpm or yarn.

npm install amadeus-ts

Getting Started

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

Usage

import Amadeus, { ResponseError } from "amadeus-ts";

const amadeus = new Amadeus({
  clientId: process.env.AMADEUS_CLIENT_ID,
  clientSecret: process.env.AMADEUS_CLIENT_SECRET,
});

async function getFlightOffers() {
  try {
    const response = await amadeus.shopping.flightOffersSearch.get({
      originLocationCode: "SYD",
      destinationLocationCode: "BKK",
      departureDate: "2024-12-01",
      adults: 2,
    });
    console.log(response.data);
  } catch (error: unknown) {
    if (error instanceof ResponseError) {
      console.log(error.code);
    }
  }
}

getFlightOffers();

Types

You can import the types of each endpoint to define the structure of your objects.

import Amadeus, { FlightOffersSearchGetParams } from "amadeus-ts";

const amadeus = new Amadeus({
  clientId: process.env.AMADEUS_CLIENT_ID,
  clientSecret: process.env.AMADEUS_CLIENT_SECRET,
});

// Define the object's type using the FlightOffersSearchGetParams type
const flightOffersSearch: FlightOffersSearchGetParams = {
  originLocationCode: "SYD",
  destinationLocationCode: "BKK",
  departureDate: "2024-12-01",
  adults: 2,
};

amadeus.shopping.flightOffersSearch.get(flightOffersSearch);

Documentation

See the official amadeus-node documentation.

About

Node library for the Amadeus travel APIs written in TypeScript

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • TypeScript 100.0%