pythonamadeus

Tours and activities *prices* using Amadeus API


I am trying to collect the price of tours and activities using the Python API with Amadeus. I read a couple of papers collecting the price of German package holidays using Amadeus Germany GmbH (which I assume to have the same API and data availability). However, despite searching for many examples, I wasn't able to retrieve the price of tours and activities. While for airfares (or hotels), I run the following script:

import pandas as pd
from amadeus import Client

amadeus_api = 'MY_API'
amadeus_secret = 'SECRET_CODE'

amadeus = Client(client_id = amadeus_api,
                 client_secret = amadeus_secret)

flights = amadeus.shopping.flight_offers_search.get(originLocationCode = 'airport_departure', destinationLocationCode = 'airport_arrival',departureDate = '2024-07-01',
                                                            adults = 1).data

However, when it comes to tours and activities the only code I was able to find is the following (or similar variations):

amadeus.shopping.activity('56777').get().result

However, the above code retrieves only some info on the activity. I would like to extract the price and be able to set the dates. Ideally, I would like to know whether the tour is bundled with air tickets.

Do you know whether it is possible to retrieve such a piece of info on Amadeus? If so, does anyone know how to do this?


Solution

  • If you check the API reference for activities, you will see that no timing data is provided. So there's no way to extract that from the API results. You could probably parse the booking link site to get that, but that's complicated, and another topic.

    Let's assume you load the activities for Madrid into a dataframe, then you can easily extract price information as follows:

    import pandas as pd
    from amadeus import Client, ResponseError
    
    amadeus_api = 'KEY'
    amadeus_secret = 'SECRET'
    
    if __name__ == '__main__':
        amadeus = Client(client_id=amadeus_api,
                         client_secret=amadeus_secret)
    
        try:
            # this call is taken from the code examples
            activities = amadeus.shopping.activities.get(latitude=40.41436995, longitude=-3.69170868)
            df = pd.DataFrame(activities.data)
        except ResponseError as error:
            print(error)
            exit(1)
    
        excerpt = df[['name', 'price']].head()
        print(excerpt.to_string())
    

    To get price data for a specific activity, like in your example, you need to access result.data.price, like so: activity_price = amadeus.shopping.activity('56777').get().result['data']['price'].

    The resulting price dictionary is empty, which means no pricing information is available for this specific activity in your example.