1

I am using API from RapidAPI for booking.com. I would like to get reviews of a hotel but I do not know how I can find hotel_id (required parameter) for a particular hotel?

import requests

url = "https://booking-com.p.rapidapi.com/v1/hotels/reviews"

querystring = {"hotel_id":"1676161","locale":"en-gb","sort_type":"SORT_MOST_RELEVANT","customer_type":"solo_traveller,review_category_group_of_friends","language_filter":"en-gb,de,fr"}

headers = {
    'x-rapidapi-host': "booking-com.p.rapidapi.com",
    'x-rapidapi-key': "1bed4aac31mshcd4d969233d7d7dp129f0bjsn58eea903e6c2"
    }

response = requests.request("GET", url, headers=headers, params=querystring)

print(response.text)
Erik
  • 59
  • 1
  • 8
  • if you're querying for a particular hotel_id, then I'm not able to understand where you want to find it? the output from `requests` would be a string of dict that can be loaded as json using `json.loads(response)` – samkart Jan 05 '22 at 10:47
  • 1
    You may have accidentally leaked an API key in your question, please revoke this key to stop your account being compromised. Its not enough just to edit the question removing the key. – Matt Seymour Jan 12 '22 at 10:47

1 Answers1

2

You can find hotel_id using the below RapidAPI.

Get available hotels by the filter. Indicate the destination_id and dest_type -> use @Search locations endpoint, check-in and check-out date, number of adults and children. For possible filters use @Filters for search

import requests

url = "https://booking-com.p.rapidapi.com/v1/hotels/search"

querystring = {"room_number":"1","order_by":"popularity","filter_by_currency":"AED","checkout_date":"2022-07-02","checkin_date":"2022-07-01","units":"metric","adults_number":"2","dest_id":"-553173","dest_type":"city","locale":"en-gb","children_number":"2","children_ages":"5,0","page_number":"0","include_adjacency":"true","categories_filter_ids":"class::2,class::4,free_cancellation::1"}

headers = {
    'x-rapidapi-host': "booking-com.p.rapidapi.com",
    'x-rapidapi-key': "0195db92d0msh8afac0130adb2c4p1087e9jsn2aeab9e0aa0f"
    }

response = requests.request("GET", url, headers=headers, params=querystring)

print(response.text)

The result is like below.

"result": [
    {
      "id": "property_card_791664",
      "hotel_name": "Cheval Thorney Court at Hyde Park",
      "class_is_estimated": 0,
      "hotel_has_vb_boost": 0,
      "district": "Kensington and Chelsea",
      "cant_book": null,
      "distance_to_cc": "4.00",
      "mobile_discount_percentage": 0,
      "is_mobile_deal": 0,
      "is_free_cancellable": 0,
      "countrycode": "gb",
      "latitude": 51.5011118011927,
      "districts": "1545,29,44,333,2280",
      "city_name_en": "London",
      "min_total_price": 379.24,
      "hotel_id": 791664,
      ...

You can get hotel_id from the result.

Visit https://rapidapi.com/tipsters/api/booking-com/tutorials/booking-api-tutorial-1

Thanks.

  • 1
    Thank you, Nikita. Is there a different way of getting the hotel_id? – Erik Jan 05 '22 at 12:02
  • Hello, how can you put a name of city in the search api ? we have a dest_id but if you want put "Paris" or "London" how can you search it ? – artSx Mar 09 '23 at 20:49