Skip to main content

Python module for the Amadeus travel APIs

Project description

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 Python documentation on Amadeus.com and the class reference here on GitHub.

Installation

This SDK requires Python 2.7+ or 3.3+. You can install install it directly with pip.

pip install amadeus==1.0.0b6

Next: Get Started with the Python SDK.

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='[YOUR_CLIENT_ID]',
    client_secret='[YOUR_CLIENT_SECRET]'
)

try:
    response = amadeus.reference_data.urls.checkin_links.get(airline='1X')
    print(response.data)
    # => [{'type': 'checkin-link', 'id': '1XEN-GBWeb', 'href': 'https://www....
except ResponseError as error:
    print(error)

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

Initialization

The client can be initialized directly.

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

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

amadeus = Client()

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:

amadeus = Client(hostname='production')

Next: Learn more about our initializing the Python 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.reference_data.urls.checkin_links.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/hotels/123/hotel-offers would be:

amadeus.hotel(123).hotel_offers.get(...)

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

amadeus.get('/v2/reference-data/urls/checkin-links', airline='1X')

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 avaulable as the .body attribute.

from amadeus import Location

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

print(reponse.body) #=> The raw response, as a string
print(reponse.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='...',
    client_secret='...',
    logger=logger
)

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.

amadeus = Client(
    client_id='...',
    client_secret='...',
    log_level='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.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

amadeus-1.0.0b7.tar.gz (16.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

amadeus-1.0.0b7-py2.py3-none-any.whl (31.1 kB view details)

Uploaded Python 2Python 3

File details

Details for the file amadeus-1.0.0b7.tar.gz.

File metadata

  • Download URL: amadeus-1.0.0b7.tar.gz
  • Upload date:
  • Size: 16.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for amadeus-1.0.0b7.tar.gz
Algorithm Hash digest
SHA256 3e78a5ce54d62b1c3849afb9afe3cd36721f58aa1f0c3a17d7619239bf04f834
MD5 d9c8bb47d3bc1dbf82c7de808e1cc12a
BLAKE2b-256 841ab3b577e46735609ba1f7e3aeb836db4d504d09ad5cd2f588c962f9865515

See more details on using hashes here.

File details

Details for the file amadeus-1.0.0b7-py2.py3-none-any.whl.

File metadata

File hashes

Hashes for amadeus-1.0.0b7-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 7928b318c1eec65d93b311d7430d88c77576ddc05f6b4abe886ec299bf208171
MD5 ea9a0ac3501b117f859da6b5635aec5e
BLAKE2b-256 6f94e859dda23241d9b80f680433cd1d19d5963e2954dcdb2d9c2d7c29dc3f6c

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page