Search by URL API
Search for hotels using a Booking.com search results URL directly from your browser.
Overview
Simplest Search Method
Copy any Booking.com search URL from your browser and use it directly to get hotel results via the API.
The Search by URL endpoint allows you to use any Booking.com search results URL directly. This is perfect when you want to replicate a search you've already configured on Booking.com's website without manually extracting all the parameters.
Endpoint URL
Query Parameters
Parameter | Type | Required | Description |
---|---|---|---|
url | string | Required | Booking.com search results URL to parse and execute |
debug | boolean | Optional | Return parsed parameters without executing search (default: false) |
How It Works
Step 1: Get Your URL
- Go to Booking.com
- Search for hotels with your desired criteria
- Copy the URL from your browser's address bar
Step 2: Use the API
Pass the copied URL to this endpoint:
Supported URL Parameters
The API automatically extracts and uses:
- Destination (city, region, hotel)
- Check-in and check-out dates
- Number of adults, children, and rooms
- Property types and filters
- Price ranges and sort preferences
- Any other search criteria from the URL
Debug Mode
Testing Parameters
Use debug=true to see what parameters are extracted from your URL without running the actual search.
When debug=true
, the API returns the parsed parameters instead of search results. This is useful for:
- Verifying the URL is parsed correctly
- Understanding what parameters are being used
- Debugging search issues
curl -X GET "https://api.stayapi.com/v1/booking/search_by_url?url=https%3A%2F%2Fwww.booking.com%2Fsearchresults.html%3Fdest_id%3D-3233180%26checkin%3D2024-06-01%26checkout%3D2024-06-07" \ -H "x-api-key: YOUR_API_KEY"
// Example Booking.com URL const bookingUrl = "https://www.booking.com/searchresults.html?dest_id=-3233180&checkin=2024-06-01&checkout=2024-06-07&group_adults=2&group_rooms=1"; // Encode the URL properly const encodedUrl = encodeURIComponent(bookingUrl); const response = await fetch( `https://api.stayapi.com/v1/booking/search_by_url?url=${encodedUrl}`, { headers: { "x-api-key": "YOUR_API_KEY" } } ); const data = await response.json(); console.log(`Found ${data.data.length} hotels`); // Debug mode example const debugResponse = await fetch( `https://api.stayapi.com/v1/booking/search_by_url?url=${encodedUrl}&debug=true`, { headers: { "x-api-key": "YOUR_API_KEY" } } ); const debugData = await debugResponse.json(); console.log("Parsed parameters:", debugData.parsed_params);
import requests from urllib.parse import quote # Example Booking.com URL booking_url = "https://www.booking.com/searchresults.html?dest_id=-3233180&checkin=2024-06-01&checkout=2024-06-07&group_adults=2&group_rooms=1" url = "https://api.stayapi.com/v1/booking/search_by_url" headers = {"x-api-key": "YOUR_API_KEY"} params = { "url": booking_url # requests will handle URL encoding } response = requests.get(url, headers=headers, params=params) data = response.json() print(f"Found {len(data['data'])} hotels") for hotel in data["data"][:3]: print(f"- {hotel['hotel_name']} - ${hotel['min_total_price']}") # Debug mode to see parsed parameters params["debug"] = True debug_response = requests.get(url, headers=headers, params=params) debug_data = debug_response.json() print("\nParsed parameters:") for key, value in debug_data["parsed_params"].items(): print(f" {key}: {value}")
{ "success": true, "data": [ { "hotel_id": 302297, "hotel_name": "Banyan Tree Phuket", "url": "https://www.booking.com/hotel/th/banyan-tree-phuket.html", "image_url": "https://cf.bstatic.com/xdata/images/hotel/square60/495123456.jpg", "star_rating": 5, "review_score": 8.7, "review_count": 1234, "review_score_word": "Fabulous", "address": "33, 33/27 Moo 4, Srisoonthorn Road Cherngtalay, Amphur Talang, 83110 Bang Tao Beach, Thailand", "distance_from_center": 18.2, "unit_configuration_label": "Entire villa", "min_total_price": 450.50, "currency_code": "USD", "is_free_cancellable": 1, "is_no_prepayment_block": 1, "checkin": "2024-06-01", "checkout": "2024-06-07" } ], "pagination": { "rows_per_page": 25, "current_offset": 0, "total_count_with_filters": 247 }, "search_metadata": { "original_url": "https://www.booking.com/searchresults.html?dest_id=-3233180&checkin=2024-06-01&checkout=2024-06-07", "dest_id": "-3233180", "dest_type": "CITY", "search_type": "regular" }, "message": "Successfully retrieved search results from URL", "retrieved_at": "2024-01-15T10:30:00Z" }
{ "success": true, "parsed_params": { "dest_id": "-3233180", "dest_type": "city", "checkin": "2024-06-01", "checkout": "2024-06-07", "group_adults": "2", "no_rooms": "1", "group_children": "0", "sb_price_type": "total", "search_type": "regular" }, "original_url": "https://www.booking.com/searchresults.html?dest_id=-3233180&checkin=2024-06-01&checkout=2024-06-07&group_adults=2&no_rooms=1", "message": "URL parsed successfully (debug mode)" }