How hotel search works
Search a place and dates, read the search as it fills in, then fetch one hotel's rooms and rates before you quote a price.
The Hotels Search API finds hotels with prices for a place and a stay, and gives each hotel links that open it on travel sites with the dates and guests filled in. It is read-only: it never books, holds or charges.
The flow
Search a place and dates
Send where to look, check_in, check_out and the guests to GET /v1/hotels/search, or send the same fields as a JSON body with POST. The answer carries a search_id and, once the supplier has answered, the hotels.
Read the search until it is complete
If data.status is running, read the search again by its search_id, with wait_ms to hold the request until it ends. Reading a search again never runs it again, so it is also how you page through the answer and sort it another way.
Fetch one hotel's rooms and rates
A search carries one price per hotel. Before you quote a price or cancellation terms, call GET /v1/hotels/rates/{hotel_id} for every room and rate the hotel has for the stay, cheapest first.
Send the traveller to book
Show the hotel's booking_links. The traveller opens one in their browser and books on that site.
A search as it fills in
Every search has a search_id, such as hs_0a29ce33d3a646fe9660. Both states below answer with HTTP 200.
status | What it means | What to do |
|---|---|---|
running | The supplier has not answered yet. hotels is empty, pricing is null, and retry_after_ms is set. | Read the search by search_id with wait_ms, or again after retry_after_ms. |
complete | The answer is in. counts.found is the number of hotels in the whole answer. | Page through it, sort it, or read one hotel's rates. |
A search can also end without an answer. Then the search, and every later read of it, answers with an error instead: supplier_error (502), supplier_timeout (504) or search_capacity (503). That search is over; search again. Errors lists every code.
How long things take:
- A new search takes about 6 seconds.
- The same stay (the same place, dates, guests, currency and nationality) searched in the last 15 minutes answers at once from the stored answer, with the same
search_id.max_age_ssets the oldest stored answer you accept. - A search is kept for 24 hours. After that, reading it answers
search_not_found. - Reading a search again never refreshes its prices.
pricing.age_ssays how old they are. Past 900 seconds, search again before you quote a price.
What one result is
Each item in data.hotels has three parts:
hotel: the hotel'sidandname, and, where known,stars,rating(guest rating out of 10),review_count,address,city,country,latitude,longitudeandphoto. Every field butidandnamecan benull.offers: in a search, one offer, the first price the supplier found in time. It is close to the hotel's cheapest and not promised to be it. From rooms and rates, every offer, cheapest first.booking_links: where the stay can be booked, best first. See Send travellers to book.
An offer is one price for the whole stay:
{
"rooms": [
{
"name": "1 King Bed | Non-Smoking",
"room_id": 1321822334,
"adults": 2,
"child_ages": [7]
}
],
"board_code": "RO",
"board": "Room Only",
"total": 223.54,
"currency": "USD",
"per_night": 74.51,
"taxes_included": 28.95,
"due_at_property": [],
"refundable": false,
"free_cancellation_until": null,
"cancellation": []
}Prop
Type
To tell a traveller what a stay costs, add due_at_property to total.
Live and test keys
A vl_live_ key searches live prices. A vl_test_ key costs nothing and never reaches the supplier: every search answers with the same saved San Francisco hotels, whatever place, dates or guests you send, and every rates call answers with one saved hotel, The Westin St. Francis San Francisco on Union Square (lp19b5e), whatever hotel_id you send. The query in the answer and the booking links follow your request. The prices, rooms and guests in the offers come from the sample, a stay of 9 to 12 February 2027 for two adults and a child of 7, so they only add up when you search that stay. meta.mode says which kind of key answered. See Test mode.
Which endpoint to use
| You want to | Call |
|---|---|
| List hotels for a place and a stay | GET /v1/hotels/search, or POST /v1/hotels/search with a JSON body |
| Wait for a running search, get the next page or sort it another way | GET /v1/hotels/search/{search_id} |
| See every room and rate of one hotel before you quote a price or its cancellation terms | GET /v1/hotels/rates/{hotel_id} |
| Check your key's limits and what it has used today | GET /v1/hotels/usage |
Access
A key reaches only the products its partner account has. If your account does not have the Hotels Search API, every hotel call, /v1/hotels/usage included, answers 403 with the code forbidden:
{
"error": {
"code": "forbidden",
"message": "This request is not permitted by your partner policy or key status.",
"retry": "never",
"request_id": "req_54f44b10243c"
}
}The same answer comes back for a revoked or expired key, a suspended account, and a live key on an account that is not yet cleared for live prices. If your account lists the networks its keys may be used from, a request from anywhere else also answers 403 forbidden, with a message that says so.