Node
Node SDK
Amadeus Node SDK for Self-service APIs is available with npm
(node package manager) and Amadeus for Developers team is continuously updating with new APIs and features.
You can refer to the amadeus-node or Amadeus npm package for more details on the changelog.
Installation
This module has been tested using Node LTS versions. You can install it using Yarn or NPM.
Getting Started
To make your first API call, you will need to register for an Amadeus Developers Account and set up your first application.
Initialization
The client can be initialized directly as below. Your credentials client Id
and Client Secret
can be found on the Amadeus dashboard.
Warning
Remember that hardcoding your credentials is not the best practice due to the potential exposure to others. Read more about best practices for secure API key storage.
Alternatively, you can initialize by setting up environment variables. In Node, we like to use dotenv package.
Put your API credentials in .env
file:
Initialize using dotenv package:
Important
You will also want to add .env
to your .gitingore
so that your API credentials aren't included in your git repository.
If you don't want to use another package, you can also simply export your key in terminal directly to initalize.
Export your credentials in terminal:
Moving to Production
By default, the SDK environment is set to test
environment. To switch to production
(pay-as-you-go) environment, please change the hostname as follows:
Promises
Every API call returns a Promise
that either resolves or rejects.
Every resolved API call returns a Response
object containing a body
attribute with the raw response. If the API call contained a JSON response, it will parse the JSON into the result
attribute. If this data contains a data
key, that will be made available in data
attribute.
For a failed API call, it returns a ResponseError
object containing the (parsed or unparsed) response, the request, and an error code.
Pagination
If an API endpoint supports pagination, the other pages are available under the .next
, .previous
, .last
and .first
methods.
If a page is not available, the response will resolve to null
.
Video Tutorial
You can also check the video tutorial on how to get started with the Node SDK.
Managing API rate limits
Amadeus Self-Service APIs have rate limits in place to protect against abuse by third parties. You can find Rate limit example in Node using the Amadeus Node SDK here.