Locating the hotel_id on Booking.com for API usage

Hey everyone! I’m trying to use the Booking.com API through RapidAPI. My goal is to fetch hotel reviews, but I’m stuck. The API needs a hotel_id parameter, and I can’t figure out how to find it for specific hotels. Anyone know a trick to get this info?

Here’s a bit of my code so far:

import requests

api_url = 'https://api.example.com/v1/hotel-reviews'

params = {
    'hotel_id': '????',  # This is what I'm missing!
    'language': 'en',
    'sort': 'recent',
    'traveler_type': 'solo,group'
}

headers = {
    'api-key': 'my_secret_key_here'
}

response = requests.get(api_url, headers=headers, params=params)
print(response.json())

Any help would be awesome! Thanks in advance.

hey zoestar42, i’ve dealt with this before! the hotel_id is actually hidden in the hotel’s url on booking.com. just go to the hotel page and look at the address bar. you’ll see something like ‘/hotel/us/hilton-garden-inn.html?aid=304142;label=gen173nr-1FCAEoggI46AdIM1gEaGyIAQGYAQm4ARfIAQzYAQHoAQH4AQuIAgGoAgO4At2IqqsGwAIB0gIkNGNhNzI3ZTUtNmRhMC00NmM5LWFmNmEtOGI5ZTg5ZDE5OTdi2AIG4AIB;sid=7374c3c9dc9e7d621fa1a7d5e40ccaff;dist=0&keep_landing=1&sb_price_type=total&type=total&’ the numbers after ‘aid=’ are what you need!

In my experience working with the Booking.com API, tracking down the hotel_id is seldom straightforward. I resolved this by opening the specific hotel’s page, then inspecting the page source (accessible with Ctrl+U in most browsers) and searching for a reference to ‘b_hotel_id’. When you find a line resembling b_hotel_id: ‘123456’, that number is the hotel_id you need. Although this method is a workaround and may break if Booking.com changes its layout, it has worked reliably for me so far.

I’ve encountered this issue before when working with the Booking.com API. One effective method I’ve found is to use the hotel’s URL slug. Navigate to the hotel’s page on Booking.com and look at the URL. You’ll see something like ‘https://www.booking.com/hotel/us/hilton-new-york.html’. The part after ‘/hotel/’ and before ‘.html’ (in this case, ‘us/hilton-new-york’) can often be used as the hotel_id. If this doesn’t work, you might need to make an initial API call to search for hotels, which usually returns hotel_ids along with other details. This approach has been reliable in my projects, though it may require a bit more code to implement.