Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

amadeus

Package Overview
Dependencies
Maintainers
2
Versions
37
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

amadeus

Node library for the Amadeus travel APIs

  • 1.0.0-beta2
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
1.6K
increased by4.58%
Maintainers
2
Weekly downloads
 
Created
Source

Amadeus Node SDK

Module Version Build Status Maintainability Dependencies Contact Support

Amadeus provides a set of APIs for the travel industry. Flights, Hotels, Locations and more.

For more details see the Node documentation on Amadeus.com.

Installation

This module has been tested using Node 6 and higher, though it should work with Node 4 and 5 as well. You can install install it using Yarn or NPM.

npm install amadeus@beta --save

Next: Get Started with the Node SDK.

Getting Started

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

var Amadeus = require('amadeus');

var amadeus = new Amadeus({
  clientId: '[YOUR_CLIENT_ID]',
  clientSecret: '[YOUR_CLIENT_SECRET]'
});

amadeus.referenceData.urls.checkinLinks.get({
  airline: '1X'
}).then(function(response){
  console.log(response.data[0].href);
  //=> https://www.onex.com/manage/check-in
}).catch(function(responseError){
  console.log(responseError.code);
});

Next: Learn more about checkin links with our Node SDK.

Initialization

The client can be initialized directly.

// Initialize using parameters
var amadeus = new Amadeus({
  clientId: '...',
  clientSecret: '...'
});

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

var amadeus = amadeus = new Amadeus();

Your credentials can be found on the Amadeus dashboard. Sign up for an account today.

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

var amadeus = new Amadeus({
  hostname: 'production'
});

Next: Learn more about our initializing the Node SDK in our documentation.

Documentation

Amadeus has a large set of APIs, and our documentation is here to get you started today.

Alternatively, head over to our Reference documentation for in-depth information about every SDK method, it's arguments and return types.

Additionally, this SDK has extensive documentation of itself available on GitHub.

Making API calls

This library conveniently maps every API path to a similar path.

For example, GET /v2/reference-data/urls/checkin-links?airline=1X would be:

amadeus.referenceData.urls.checkinLinks.get({ airline: '1X' });

Similarly, to select a resource by ID, you can pass in the ID to the singular path.

For example, GET /v1/shopping/hotel/123/offers/234 would be:

amadeus.shopping.hotel(123).offer(234).get(...);

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

amadeus.client.get('/v2/reference-data/urls/checkin-links', { airline: '1X' });

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 also contains a data key, it will make that available as the .data attribute.

For a failed API call it returns a ResponseError containing the (parsed or unparsed) response, the request, and an error code.

amadeus.referenceData.urls.checkinLinks.get({
  airline: '1X'
}).then(function(response){
  console.log(response.body);   //=> The raw body
  console.log(response.result); //=> The fully parsed result
  console.log(response.data);   //=> The data attribute taken from the result
}).catch(function(error){
  console.log(error.response); //=> The response object with (un)parsed data
  console.log(error.response.request); //=> The details of the request made
  console.log(error.code); //=> A unique error code to identify the type of error
});

Pagination

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

amadeus.referenceData.locations.get({
  keyword: 'LON',
  subType: 'AIRPORT,CITY'
}).then(function(response){
  console.log(response.data); // first page
  return amadeus.next(response);
}).then(function(nextReponse){
  console.log(nextReponse.data); // second page
});

If a page is not available, the response will resolve to null.

Logging & Debugging

The SDK makes it easy to add your own logger compatible with the default console.

var amadeus = new Amadeus({
  clientId: '...',
  clientSecret: '...',
  logger: new MyConsole()
});

Additionally, to enable more verbose logging, you can set the appropriate level on your own logger, though the easiest way would be to enable debugging via a parameter on initialization, or using the AMADEUS_LOG_LEVEL environment variable. The available options are warn (default), debug, and silent.

var amadeus = new Amadeus({
  clientId: '...',
  clientSecret: '...',
  logLevel: 'debug'
});

Development & Contributing

Want to contribute? Read our Contributors Guide for guidance on installing and running this code in a development environment.

License

This library is released under the MIT License.

Help

Our developer support team is here to help you. You can find us on Twitter, StackOverflow, and email.

Keywords

FAQs

Package last updated on 28 Mar 2018

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc