How to Filter Activities by Duration in Hotelbeds API?
To filter activities by duration in Hotelbeds API, you can use the "activityFilter" parameter in the "GetActivities" API call. This parameter allows you to specify the minimum and maximum duration of the activities you want to retrieve.
Here's a step-by-step guide on how to use this parameter:
- First, you need to make sure you have the correct API credentials and are authenticated to make API calls. You can find more information on how to do this in the Hotelbeds API documentation.
- Once you have your API credentials, you can make a GET request to the "GetActivities" endpoint with the following query parameters:
- origin: The city code or name of the origin of the traveler.
- destination: The city code or name of the destination.
- checkInDate: The check-in date of the traveler in YYYY-MM-DD format.
- checkOutDate: The check-out date of the traveler in YYYY-MM-DD format.
- supplier: The supplier code or name of the activity provider.
- language: The language code of the response.
- currency: The currency code of the response.
- activityFilter: A JSON object containing the minimum and maximum duration of the activities you want to retrieve.
Here's an example of how to use the "activityFilter" parameter:
GET /api/v1/activities?origin=LON&destination=PAR&checkInDate=2023-03-01&checkOutDate=2023-03-05&supplier=HB&language=en¤cy=EUR&activityFilter={"minDuration":180,"maxDuration":360} HTTP/1.1
Host: api.hotelbeds.com
Authorization: Bearer <your_api_key>
In this example, we're requesting activities for travelers going from London (LON) to Paris (PAR) between March 1, 2023, and March 5, 2023. We're also filtering the activities to only show those with a duration between 180 and 360 minutes (3 hours and 0 minutes to 6 hours and 0 minutes).
- The response of the API call will contain a list of activities that match the filter criteria. Each activity will have a "duration" field that indicates its actual duration in minutes.
Here's an example of what the response might look like:
{
"activities": [
{
"activityId": "1234567890",
"supplierId": "HB",
"activityName": "Paris City Sightseeing Tour",
"description": "Discover the highlights of Paris on a guided bus tour.",
"duration": 180,
"price": {
"currency": "EUR",
"amount": 45.00
},
"imageUrl": "https://example.com/images/paris-tour.jpg"
},
{
"activityId": "2345678901",
"supplierId": "AB",
"activityName": "Versailles Palace Tour",
"description": "Explore the opulent Palace of Versailles with a guided tour.",
"duration": 300,
"price": {
"currency": "EUR",
"amount": 60.00
},
"imageUrl": "https://example.com/images/versailles-palace.jpg"
}
]
}
In this example, we've received a list of two activities that match the filter criteria. The first activity has a duration of 180 minutes (3 hours) and costs €45.00, while the second activity has a duration of 300 minutes (5 hours) and costs €60.00.
That's it! By using the "activityFilter" parameter in the "GetActivities" API call, you can easily filter activities by duration to find the ones that best fit your travelers' preferences and budget.