amadeusnode
v0.0.41
Published
A comprehensive TypeScript client for the Amadeus API, providing easy access to flight search, hotel booking, airport information, and travel-related data.
Readme
THIS README WAS WRITTEN BY CURSOR. TEXT @raamas70 on x.com if u need help thx
Amadeus API Client
A comprehensive TypeScript client for the Amadeus API, providing easy access to flight search, hotel booking, airport information, and travel-related data.
Features
- ✈️ Flight Search - Search for flights, get price metrics, and find cheapest dates
- 🏨 Hotel Search - Find hotels by city, geolocation, or specific IDs
- 🗺️ Airport & City Search - Search for airports and cities worldwide
- 📊 Price Analytics - Get pricing trends and fare analysis
- 🎯 Recommendations - Get personalized destination recommendations
- 📱 Real-time Status - Check flight status and operational details
- 🔐 Automatic Authentication - Handles OAuth 2.0 token management
- 🧪 Test & Production - Support for both sandbox and live environments
Installation
npm install amadeus-node-clientQuick Start
import { AmadeusClient } from "amadeus-node-client";
// Initialize the client
const amadeus = new AmadeusClient(
"your-api-key",
"your-api-secret",
"test" // or "production"
);
// Search for flights
const flights = await amadeus.getFlightOffers("LAX", "JFK", "2024-01-15");
// Search for hotels
const hotels = await amadeus.getHotelsByCity("LAX");API Key Setup
- Visit the Amadeus Developer Portal
- Create an account and register your application
- Get your API key and secret
- Use "test" mode for development, "production" for live data
Core Methods
Flight Search
Basic Flight Search
const flights = await amadeus.getFlightOffers("LAX", "JFK", "2024-01-15");Advanced Flight Search
const flights = await amadeus.getFlightOffers("LAX", "JFK", "2024-01-15", {
returnDate: "2024-01-22",
adults: 2,
travelClass: "ECONOMY",
nonStop: true,
currencyCode: "USD",
max: 20,
});Price Metrics
const metrics = await amadeus.flightPriceMetrics("LAX", "JFK", "2024-01-15", {
currencyCode: "USD",
oneWay: "true",
});Cheapest Flight Dates
const dates = await amadeus.cheapestFlightDate("LAX", "JFK", {
departureDate: "2024-01-15",
oneWay: "true",
maxPrice: 500,
currencyCode: "USD",
});Hotel Search
Search Hotels by City
const hotels = await amadeus.getHotelsByCity("LAX", {
radius: 10,
radiusUnit: "KM",
ratings: ["4", "5"],
amenities: "SPA",
});Search Hotels by Coordinates
const hotels = await amadeus.getHotelsByGeocode(34.0522, -118.2437, {
radius: 10,
radiusUnit: "KM",
ratings: ["4", "5"],
});Get Hotel Offers
const offers = await amadeus.getHotelOffers(["HOTEL1", "HOTEL2"], {
adults: 2,
checkInDate: "2024-01-15",
checkOutDate: "2024-01-18",
currency: "USD",
bestRateOnly: true,
});Airport & Location Search
Search Airports and Cities
// Search for cities
const cities = await amadeus.airportCitySearch("CITY", "Los Angeles", {
countryCode: "US",
view: "FULL",
});
// Search for airports
const airports = await amadeus.airportCitySearch("AIRPORT", "LAX");Get Airport Routes
const routes = await amadeus.getAirportRoutes("LAX", {
max: 20,
arrivalCountryCode: "US",
});Travel Insights
Cheap Flight Destinations
const destinations = await amadeus.cheapFlightDestinations("LAX", {
departureDate: "2024-01-15",
oneWay: "true",
maxPrice: 500,
currencyCode: "USD",
viewBy: "COUNTRY",
});Recommended Destinations
const recommendations = await amadeus.recommendedDestinations(["LAX", "JFK"], {
travelerCountryCode: "US",
destinationCountryCodes: "US,ES,UK",
});Flight Status
const status = await amadeus.getFlightStatus("AA", "100", "2024-01-15", {
operationalSuffix: "A",
});Error Handling
The client includes comprehensive error handling:
try {
const flights = await amadeus.getFlightOffers("LAX", "JFK", "2024-01-15");
console.log("Flights found:", flights.data?.length);
} catch (error) {
console.error("API Error:", error.message);
}Response Types
All methods return properly typed responses. Import types for better TypeScript support:
import {
getFlightOffersResponse,
getHotelsResponse,
AirportCitySearchResponse,
} from "./responseTypes";Environment Configuration
Test Environment (Recommended for Development)
const amadeus = new AmadeusClient("test-key", "test-secret", "test");Production Environment
const amadeus = new AmadeusClient("prod-key", "prod-secret", "production");Rate Limits
The Amadeus API has rate limits:
- Test Environment: 1000 calls per month
- Production Environment: Varies by subscription
Monitor your usage in the Amadeus Developer Portal.
Contributing
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
License
This project is licensed under the MIT License - see the LICENSE file for details.
Support
Changelog
v1.0.0
- Initial release
- Complete Amadeus API coverage
- TypeScript support
- Comprehensive documentation
- Error handling
- Test and production environment support
Note: This client is not officially affiliated with Amadeus. For official support, please contact Amadeus directly.
