Looking for assistance in identifying hotel IDs for reviews
I’ve been using the RapidAPI for the Booking.com API and I’m trying to pull in customer reviews for hotels. The issue I’m encountering is that I need the hotel_id parameter to access the reviews, but I’m unsure how to find this ID for specific hotels.
Here’s the code I’ve been working with:
import requests
api_url = "https://booking-com.p.rapidapi.com/v1/hotels/reviews"
params = {
"hotel_id": "1234567",
"locale": "en-us",
"sort_type": "SORT_MOST_RELEVANT",
"customer_type": "family,solo_traveller",
"language_filter": "en-gb,fr,de"
}
api_headers = {
'x-rapidapi-host': "booking-com.p.rapidapi.com",
'x-rapidapi-key': "your-unique-api-key"
}
response = requests.get(api_url, headers=api_headers, params=params)
print(response.text)
Any suggestions on how to find the hotel ID for the locations I’m interested in? Is there a particular endpoint that allows searching for hotels and retrieving their IDs?
Had the same issue when I started using Booking.com’s API through RapidAPI. You can’t just guess hotel IDs or grab them from regular Booking URLs - doesn’t work that way. Here’s what I do: use the search endpoints first. There’s usually a hotels search that takes location, city, or coordinates. Search results give you hotel details plus the unique IDs you need for the reviews endpoint. My workflow: search the area I want, pull the hotel_ids from those results, then hit the reviews endpoint with those IDs. Bonus - the search also returns hotel names and locations so you can double-check you’ve got the right properties before grabbing reviews.
yeah, there’s a hotels/search endpoint in that rapidapi package. you can find hotel ids by location or name - just pass your city/coordinates and it’ll return all properties with their booking ids. then loop through the results and grab reviews for each hotel.
You can’t extract hotel_id from regular Booking.com URLs. I’ve worked with their API for a while - the /v1/hotels/locations endpoint works great for this. Just pass in a destination name or coordinates and you’ll get back all the properties with their hotel_ids. I do two calls: first grab the hotel listings for my area, then use those IDs to pull reviews. Heads up though - some properties won’t have review data even with a valid hotel_id, so throw in some error handling. The search results also give you basic stuff like star ratings and amenities to double-check you’re getting reviews for the right places.
This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.