All Projects β†’ amadeus4dev β†’ amadeus-python

amadeus4dev / amadeus-python

Licence: MIT license
Python library for the Amadeus Self-Service travel APIs

Programming Languages

python
139335 projects - #7 most used programming language
Makefile
30231 projects

Projects that are alternatives of or similar to amadeus-python

amadeus-android
Android (Kotlin) library for the Amadeus Self-Service travel APIs
Stars: ✭ 15 (-88.37%)
Mutual labels:  travel, amadeus
Roundtrip
πŸ πŸ›«πŸ›¬πŸ™οΈπŸ›«πŸ›¬πŸ™οΈπŸ›«πŸ›¬πŸ™οΈπŸ›«πŸ›¬ 🏠, minimizeπŸ’°of your🌴
Stars: ✭ 80 (-37.98%)
Mutual labels:  travel, flights
developer-guides
Developer Guides
Stars: ✭ 25 (-80.62%)
Mutual labels:  travel, amadeus
skyscanner-php
Unofficial PHP SDK for Skyscanner's API.
Stars: ✭ 40 (-68.99%)
Mutual labels:  travel, flights
transport-management-system
Transport Management System for Odoo
Stars: ✭ 105 (-18.6%)
Mutual labels:  travel
ForeignIpsum
Generate text for your mockups in multiple languages Β―\_(ツ)_/Β―
Stars: ✭ 43 (-66.67%)
Mutual labels:  travel
Travel website-NextJS
Travel Site built with NextJS and Tailwindcss
Stars: ✭ 23 (-82.17%)
Mutual labels:  travel
Online Travel Reservation
A replica of online travel booking site KAYAK(www.kayak.com) for cmpe-273. Visit ->
Stars: ✭ 37 (-71.32%)
Mutual labels:  travel
FlightBookingFlutter
Recreating a Flight Booking application for Flutter Study Jam BBSR DAY 2
Stars: ✭ 22 (-82.95%)
Mutual labels:  flights
bcplus
BoardComputer+ for E:D
Stars: ✭ 15 (-88.37%)
Mutual labels:  travel
leaflet.TravelNotes
A complete mapping application. With this, you prepare a complete travel, adding itineraries and personnal notes to the map. When you travel is complete, you can save it to a file, export the itineraries to a gpx files, print the itineraries and a roadbook with the notes and itineraries description.
Stars: ✭ 31 (-75.97%)
Mutual labels:  travel
deck
DECK is a powerful and high performant local web development studio unlike any other.
Stars: ✭ 1,414 (+996.12%)
Mutual labels:  flights
travel
Visualization of Sourabh's adventures
Stars: ✭ 16 (-87.6%)
Mutual labels:  travel
european-transport-operators
NOT UP-TO-DATE ANYMORE, UNMAINTAINED. CHECK european-transport-feeds INSTEAD. List of european long-distance transport operators, available API endpoints, GTFS feeds and client modules.
Stars: ✭ 47 (-63.57%)
Mutual labels:  travel
waldur-homeport
Waldur HomePort is web-based client for the Waldur MasterMind.
Stars: ✭ 22 (-82.95%)
Mutual labels:  self-service
sdk
πŸ”§ TypeScript SDK for Entur APIs
Stars: ✭ 36 (-72.09%)
Mutual labels:  travel
life log
A React-Native application implementing Firebase, Shoutem ui, Airbnb's react-native-maps, and Google Places API.
Stars: ✭ 18 (-86.05%)
Mutual labels:  travel
waldur-mastermind
Waldur MasterMind is a hybrid cloud orchestrator.
Stars: ✭ 37 (-71.32%)
Mutual labels:  self-service
Yoloo
Yoloo is a social travel app that lets travelers plan their trips, find travelmates, and share their experiences.
Stars: ✭ 20 (-84.5%)
Mutual labels:  travel
tabtrekker
Explore the world one tab at a time (Firefox addon).
Stars: ✭ 42 (-67.44%)
Mutual labels:  travel

Amadeus Python SDK

Module Version Build Status Maintainability Dependencies Discord

Amadeus provides a rich set of APIs for the travel industry. For more details, check out the Amadeus for Developers Portal or the SDK class reference.

Installation

This SDK requires Python 3.4+ (Python 2+ is no longer supported). You can install it directly with pip:

pip install amadeus

OR, add it to your requirements.txt file and install using:

pip install -r requirements.txt

Getting Started

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

from amadeus import Client, ResponseError

amadeus = Client(
    client_id='REPLACE_BY_YOUR_API_KEY',
    client_secret='REPLACE_BY_YOUR_API_SECRET'
)

try:
    response = amadeus.shopping.flight_offers_search.get(
        originLocationCode='MAD',
        destinationLocationCode='ATH',
        departureDate='2022-11-01',
        adults=1)
    print(response.data)
except ResponseError as error:
    print(error)

Examples

You can find all the endpoints in self-contained code examples.

Initialization

The client can be initialized directly.

# Initialize using parameters
amadeus = Client(client_id='REPLACE_BY_YOUR_API_KEY', client_secret='REPLACE_BY_YOUR_API_SECRET')

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

amadeus = Client()

Your credentials can be found on the Amadeus dashboard.

By default, the SDK environment is set to test environment. To switch to a production (pay-as-you-go) environment, please switch the hostname as follows:

amadeus = Client(hostname='production')

Documentation

Amadeus has a large set of APIs, and our documentation is here to get you started today. Head over to our reference documentation for in-depth information about every SDK method, as well as its arguments and return types.

Making API calls

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

For example, GET /v2/reference-data/urls/checkin-links?airlineCode=BA would be:

amadeus.reference_data.urls.checkin_links.get(airlineCode='BA')

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

For example, GET /v2/shopping/hotel-offers/XZY would be:

amadeus.shopping.hotel_offer('XYZ').get()

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

amadeus.get('/v2/reference-data/urls/checkin-links', airlineCode='BA')

Or, with POST method:

amadeus.post('/v1/shopping/flight-offers/pricing', body)

Response

Every API call returns a Response object. 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. The raw body of the response is always available as the .body attribute.

from amadeus import Location

response = amadeus.reference_data.locations.get(
    keyword='LON',
    subType=Location.ANY
)

print(response.body) #=> The raw response, as a string
print(response.result) #=> The body parsed as JSON, if the result was parsable
print(response.data) #=> The list of locations, extracted from the JSON

Pagination

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

from amadeus import Location

response = amadeus.reference_data.locations.get(
    keyword='LON',
    subType=Location.ANY
)

amadeus.next(response) #=> returns a new response for the next page

If a page is not available, the method will return None.

Logging & Debugging

The SDK makes it easy to add your own logger.

import logging

logger = logging.getLogger('your_logger')
logger.setLevel(logging.DEBUG)

amadeus = Client(
    client_id='REPLACE_BY_YOUR_API_KEY',
    client_secret='REPLACE_BY_YOUR_API_SECRET',
    logger=logger
)

Additionally, to enable more verbose logging, you can set the appropriate level on your own logger. The easiest way would be to enable debugging via a parameter during initialization, or using the AMADEUS_LOG_LEVEL environment variable.

amadeus = Client(
    client_id='REPLACE_BY_YOUR_API_KEY',
    client_secret='REPLACE_BY_YOUR_API_SECRET',
    log_level='debug'
)

List of supported endpoints

# Flight Inspiration Search
amadeus.shopping.flight_destinations.get(origin='MAD')

# Flight Cheapest Date Search
amadeus.shopping.flight_dates.get(origin='MAD', destination='MUC')

# Flight Offers Search GET
amadeus.shopping.flight_offers_search.get(originLocationCode='SYD', destinationLocationCode='BKK', departureDate='2022-11-01', adults=1)
# Flight Offers Search POST
amadeus.shopping.flight_offers_search.post(body)

# Flight Offers Price
flights = amadeus.shopping.flight_offers_search.get(originLocationCode='SYD', destinationLocationCode='BKK', departureDate='2022-11-01', adults=1).data
amadeus.shopping.flight_offers.pricing.post(flights[0])
amadeus.shopping.flight_offers.pricing.post(flights[0:2], include='credit-card-fees,other-services')

# Flight Create Orders
amadeus.booking.flight_orders.post(flights[0], traveler)

# Flight Order Management
# The flight ID comes from the Flight Create Orders (in test environment it's temporary)
# Retrieve the order based on it's ID
flight_booking = amadeus.booking.flight_orders.post(body).data
amadeus.booking.flight_order(flight_booking['id']).get()
# Delete the order based on it's ID
amadeus.booking.flight_order(flight_booking['id']).delete()

# Flight SeatMap Display GET
amadeus.shopping.seatmaps.get(**{"flight-orderId": "orderid"})
# Flight SeatMap Display POST
amadeus.shopping.seatmaps.post(body)

# Flight Availabilities POST
amadeus.shopping.availability.flight_availabilities.post(body)

# Branded Fares Upsell
amadeus.shopping.flight_offers.upselling.post(body)

# Flight Choice Prediction
body = amadeus.shopping.flight_offers_search.get(
        originLocationCode='MAD',
        destinationLocationCode='NYC',
        departureDate='2022-11-01',
        adults=1).result
amadeus.shopping.flight_offers.prediction.post(body)

# Flight Checkin Links
amadeus.reference_data.urls.checkin_links.get(airlineCode='BA')

# Airline Code Lookup
amadeus.reference_data.airlines.get(airlineCodes='U2')

# Airport and City Search (autocomplete)
# Find all the cities and airports starting by 'LON'
amadeus.reference_data.locations.get(keyword='LON', subType=Location.ANY)
# Get a specific city or airport based on its id
amadeus.reference_data.location('ALHR').get()

# City Search
amadeus.reference_data.locations.cities.get(keyword='PAR')

# Airport Nearest Relevant Airport (for London)
amadeus.reference_data.locations.airports.get(longitude=0.1278, latitude=51.5074)

# Flight Most Booked Destinations
amadeus.travel.analytics.air_traffic.booked.get(originCityCode='MAD', period='2017-08')

# Flight Most Traveled Destinations
amadeus.travel.analytics.air_traffic.traveled.get(originCityCode='MAD', period='2017-01')

# Flight Busiest Travel Period
amadeus.travel.analytics.air_traffic.busiest_period.get(cityCode='MAD', period='2017', direction='ARRIVING')

# Hotel Search
# Get list of Hotels by city code
amadeus.shopping.hotel_offers.get(cityCode='LON')
# Get list of offers for a specific hotel
amadeus.shopping.hotel_offers_by_hotel.get(hotelId='BGLONBGB')
# Confirm the availability of a specific offer
offerId = amadeus.shopping.hotel_offer('8123DD9DE5102DADF5DA3B55C8C575F54114336EE718578753888747FE0652FC').get()

# Hotel Search v3
# Get list of available offers by hotel ids
amadeus.shopping.hotel_offers_search.get(hotelIds='RTPAR001', adults='2')
# Check conditions of a specific offer
amadeus.shopping.hotel_offer_search('XXX').get()

# Hotel List
# Get list of hotels by hotel id
amadeus.reference_data.locations.hotels.by_hotels.get(hotelIds='ADPAR001')
# Get list of hotels by city code
amadeus.reference_data.locations.hotels.by_city.get(cityCode='PAR')
# Get list of hotels by a geocode
amadeus.reference_data.locations.hotels.by_geocode.get(longitude=2.160873,latitude=41.397158)

# Hotel Name Autocomplete
amadeus.reference_data.locations.hotel.get(keyword='PARI', subType=[Hotel.HOTEL_GDS, Hotel.HOTEL_LEISURE])

# Hotel Booking
# The offerId comes from the hotel_offer above
amadeus.booking.hotel_bookings.post(offerId, guests, payments)

# Hotel Ratings
# What travelers think about this hotel?
amadeus.e_reputation.hotel_sentiments.get(hotelIds = 'ADNYCCTB')

# Points of Interest
# What are the popular places in Barcelona (based a geo location and a radius)
amadeus.reference_data.locations.points_of_interest.get(latitude=41.397158, longitude=2.160873)
# What are the popular places in Barcelona? (based on a square)
amadeus.reference_data.locations.points_of_interest.by_square.get(north=41.397158, west=2.160873,
                                                                  south=41.394582, east=2.177181)
# Returns a single Point of Interest from a given id
amadeus.reference_data.locations.point_of_interest('9CB40CB5D0').get()

# Location Score
amadeus.location.analytics.category_rated_areas.get(latitude=41.397158, longitude=2.160873)

# Safe Place
# How safe is Barcelona? (based a geo location and a radius)
amadeus.safety.safety_rated_locations.get(latitude=41.397158, longitude=2.160873)
# How safe is Barcelona? (based on a square)
amadeus.safety.safety_rated_locations.by_square.get(north=41.397158, west=2.160873,
                                                    south=41.394582, east=2.177181)
# What is the safety information of a location based on it's Id?
amadeus.safety.safety_rated_location('Q930400801').get()

# Trip Purpose Prediction
amadeus.travel.predictions.trip_purpose.get(originLocationCode='ATH', destinationLocationCode='MAD', departureDate='2022-11-01', returnDate='2022-11-08')

# Flight Delay Prediction
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')

# Airport On-Time Performance
amadeus.airport.predictions.on_time.get(airportCode='JFK', date='2022-11-01')

# Airport Routes
amadeus.airport.direct_destinations.get(departureAirportCode='BLR')

# Trip Parser
# Encode to Base64 your booking confirmation file (.html, .eml, .pdf supported)
response = amadeus.travel.trip_parser.post(amadeus.travel.from_file(path_to_file))
# Alternatively you can use a Base64 encoded content directly
response = amadeus.travel.trip_parser.post(amadeus.travel.from_base64(base64))
# Or you can call the API with the JSON directly
response = amadeus.travel.trip_parser.post(body)

# Travel Recommendations
amadeus.reference_data.recommended_locations.get(cityCodes='PAR', travelerCountryCode='FR')

# Retrieve status of a given flight
amadeus.schedule.flights.get(carrierCode='AZ', flightNumber='319', scheduledDepartureDate='2022-09-13')

# Tours and Activities
# What are the popular activities in Madrid (based a geo location and a radius)
amadeus.shopping.activities.get(latitude=40.41436995, longitude=-3.69170868)
# What are the popular activities in Barcelona? (based on a square)
amadeus.shopping.activities.by_square.get(north=41.397158, west=2.160873,
                                          south=41.394582, east=2.177181)
# Returns a single activity from a given id
amadeus.shopping.activity('4615').get()

# Returns itinerary price metrics
amadeus.analytics.itinerary_price_metrics.get(originIataCode='MAD', destinationIataCode='CDG',
                                            departureDate='2021-03-21')

# Travel Restrictions v1
amadeus.duty_of_care.diseases.covid19_area_report.get(countryCode="US")
# Travel Restrictions v2
amadeus.duty_of_care.diseases.covid19_report.get(countryCode='US')

# Airline Routes
amadeus.airline.destinations.get(airlineCode='BA')

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

You can find us on StackOverflow or join our developer community on Discord.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].