Oxylabs Documentation
English
Search
K

Travel: Hotels

The google_travel_hotels data source is designed to retrieve Google Travel service's hotel search results.
To ensure optimal utilization of this service, include the "render": "html" parameter in your request.

Query parameters

Parameter
Description
Default Value
source
Data source. More info.
google_travel_hotels
domain
Domain localization for Google. The full list of available domains can be found here.
com
query
UTF-encoded keyword. "query": "hotels" will result list hotels in a given geo_location; "query": "hotels in <Location>" will result in a list hotels for <Location>. Eg hotels in Paris will list hotels in Paris, no matter what geo_location is given.
-
start_page
Starting page number
1
locale
Accept-Language header value which changes your Google search page web interface language. More info.
-
geo_location
The geographical location that the result should be adapted for. Using this parameter correctly is extremely important to get the right data. Please note that this source can accept a limited number of geo_location values - please check this section to see geo_location values that don't yield accurate results.
-
user_agent_type
Device type and browser. The full list can be found here.
desktop
render
Enables JavaScript rendering. More info.
-
callback_url
URL to your callback endpoint. More info.
-
context: hotel_occupancy
Number of guests
2
context: hotel_classes
Filter results by # of hotel stars. You may specify one or more values between 2 and 5. Example: [3,4]
-
context: hotel_dates
Dates for staying at the hotel, from - to. Example: 2023-07-12,2023-07-13
-
- required parameter
NOTE: "geo_location": "United States" and other wide-area locations are not supported. Use city-level geo_location, e.g., Seattle,Washington,United States

Code examples

In this example, we make a request to retrieve the 2nd results page for hotel availability for 2 guests between 2023-10-01 and 2023-10-10 for 2 to 4-star hotels in Paris from google.com.
JSON
cURL
Python
PHP
HTTP
{
"source": "google_travel_hotels",
"domain": "com",
"start_page": 2,
"query": "hotels in Paris",
"render": "html",
"context": [
{
"key": "hotel_occupancy",
"value": 2
},
{
"key": "hotel_dates",
"value": "2023-10-01,2023-10-10"
},
{
"key": "hotel_classes",
"value": [2,3,4]
}]
}
curl --user "user:pass1" 'https://realtime.oxylabs.io/v1/queries' -H "Content-Type: application/json" -d '{"source": "google_travel_hotels", "domain": "com", "start_page": 2, "query": "hotels in Paris", "render": "html", "context": [{"key": "hotel_occupancy", "value": 2}, {"key": "hotel_dates", "value": "2023-10-01,2023-10-10"}, {"key": "hotel_classes", "value": [2,3,4]}]}'
import requests
from pprint import pprint
# Structure payload.
payload = {
'source': 'google_travel_hotels',
'domain': 'com',
'query': 'hotels in Paris',
'start_page': 2,
'render': 'html',
'context': [
{'key': 'hotel_occupancy', 'value': 1},
{'key': 'hotel_dates', 'value': '2023-10-01,2023-10-10'},
{'key': 'hotel_classes', 'value': [2,3,4]},
],
}
# Get response.
response = requests.request(
'POST',
'https://realtime.oxylabs.io/v1/queries',
auth=('user', 'pass1'),
json=payload,
)
# Print prettified response to stdout.
pprint(response.json())
$params = [
'source' => 'google_travel_hotels',
'domain' => 'com',
'query' => 'hotels in Paris',
'start_page' => 2,
'render' => 'html',
'context' => [
[
'key' => 'hotel_occupancy',
'value' => 1,
],
[
'key' => 'hotel_dates',
'value' => '2023-10-01,2023-10-10',
],
[
'key' => 'hotel_classes',
'value' => [2,3,4],
]
]
];
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "https://realtime.oxylabs.io/v1/queries");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($params));
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_USERPWD, "user" . ":" . "pass1");
$headers = [];
$headers[] = "Content-Type: application/json";
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
$result = curl_exec($ch);
echo $result;
if (curl_errno($ch)) {
echo 'Error:' . curl_error($ch);
}
curl_close ($ch);
https://realtime.oxylabs.io/v1/queries?source=google_travel_hotels&domain=com&query=hotels+in+Paris&start_page=3&render=html&context[0][key]=hotel_occupancy&context[0][value]=1&context[1][key]=hotel_dates&context[1][value]=2023-10-01,2023-10-10&context[2][key]=hotel_classes&context[2][value]=[2,3,4]&access_token=12345abcde
The example above uses the Realtime integration method. If you would like to use some other integration method in your query (e.g. Push-Pull or Proxy Endpoint), refer to the integration methods section.

HTML example

Last modified 29d ago