Try it out!
If you are a Booking.com Managed Affiliated Partner you can start trying our Demand API in your client application.
Quick guide
Follow this quick guide with a basic use case to learn how to use our /accommodation endpoints and how to integrate them with your client application so that a traveller can:
- Search for accommodations provided by Booking.com.
- Look at detailed information about an accommodation, including real-time room availability and pricing.
- Book their accommodation either via your website or directly through Booking.com.
You can handle the traveller bookings in one out of the two ways we offer, depending on the integration type you are implementing:
- The search and look integration redirects the traveller to Booking.com to make the booking.
- The search, look and book integration covers all the process, including the booking directly in your application by means of the /orders endpoints.
The Search, look and book integration enables you to complete customer transactions on your website. For this type of integration, you require approval, a sound business case and an appropriate partner agreement with Booking.com.
This diagram shows the endpoints that you must use for each integration type, depending on the traveller needs.
Before you start
Before start trying out our Demand API, make sure that:
Checklist | |
---|---|
☑ | You are a registered Booking.com Managed Affiliate Partner. |
☑ | Your dedicated Account Manager has granted you access to Partner Centre (after signing agreed contract). |
☑ | From the Partner Centre you have generated:
|
☑ | You have a suitable API testing tool, such as cURL or Postman. |
Use case
The given use case represent a typical Demand API scenario:
A traveller visits your website to find somewhere to stay in Amsterdam.
They want to book a 2-night stay, for 2 adults with no children, and they want 1 room.
The traveller is in the Netherlands and is using your website from their mobile phone.
To get familiar with the full booking process and the endpoints involved, take this use case as an example in every step of the guide.
Do not forget to authenticate every call that you make to a Demand API endpoint by using your generated API key - Token and your X-Affiliate-Id
parameter. For more information, see the Authentication and authorisation section.
Steps
Step 1: Search for matching accommodations
To find properties that match the use case search criteria:
→ Use the accommodations/search endpoint.
Create the search request body with the following fields:
city
: Specify the unique cityid
for the required destination.- Get your city
id
using the List cities endpoint. - In this case for the use case provided, use the one assigned to Amsterdam
-2140479
.
- Get your city
booker.country
: Specify the country from which the search request is made.- Get your two-letter country code using the List countries endpoint.
- In this case for the use case provided, use (
nl
). - This is required to ensure that the response complies with relevant laws on the display of taxes and fees.
NoteThe country code must always be in lowercase.
booker.platform
: Specify the platform from which thesearch
request is made.- In this case, for the use case provided, use (
mobile
). - This is required so that any platform-based prices and deals can be returned correctly.
- In this case, for the use case provided, use (
checkin
,checkout
: Specify the traveller's requested arrival and departure dates (use the YYYY-MM-DD format).guests.number_of_rooms
andguests.number_of_adults
: Specify the number of rooms the traveller needs (1
), and the number of adults for the stay (2
).
For the provided use case you should create a request body similar to this example:
{ "city": -2140479, "booker": { "country": "nl", "platform": "mobile" }, "checkin": "2023-11-06", "checkout": "2023-11-08", "guests": { "number_of_rooms": 1, "number_of_adults": 2 } }
Step 2: Get details of matching accommodations
Before you show the search results to the traveller you need to get some more information about each accommodation.→ Call /accommodations/details to get additional data about the properties returned in the previous search response.
To get details about a specific accommodation:
- Go to the accommodations/search response.
- Copy the returned accommodation’s unique identifier
id
. - Use it in your /accommodations/details request.
- The returned response provides all the details about the selected accommodation.
Your request body should look like this:
{ "accommodations": [ 10507360 ], "extras": [ "description", "facilities", "payment", "photos", "policies", "rooms" ], "languages": [ "en-gb" ] }
You can optionally remove or include categories from the extras
field to narrow down your response: description
, facilities
, payment
, photos
, policies
, rooms
.
Step 3: Display your search results page
You now have the necessary information to display the search results to the traveller.→ Select the data from the accommodations/search and /accommodations/details responses (Step 1 and Step 2) to provide the level of information that is needed for your particular business scenario.
Use the extras
field to retrieve more details about some or all of the given categories. For example, if you want to use a photograph in your search results, add the field "extras": ["photos"]
to your request.
... { "accommodations": [ 1466774 ], "extras": [ "photos" ], "languages": [ "en-gb" ] } ...
The traveller browses through the search results, looking for properties where they might like to stay.
They like the look of the "Demand API Sandbox Hotel Orion".
Now they want to see more details about the hotel and the full list of available rooms and prices.
Step 4: Get the accommodation's availability and prices
→ Use the Get the accommodation's availability endpoint to provide real-time information about the availability and prices of all rooms offered by the selected accommodation.
To retrieve the availability and prices of a specific accommodation:
- Go to the accommodations/search response (in step 1).
- And copy:
- The returned accommodation’s unique identifier
id
- The values used for
booker
,checkin
,checkout
, andguests
in your search request (Refer to step 1).
- Paste same values into your /accommodations/availability request.
Your request body should look like this:
{ "accommodation": 10507360, "booker": { "platform": "desktop", "country": "nl" }, "checkin": "2023-11-06", "checkout": "2023-11-08", "guests": { "number_of_rooms": 1, "number_of_adults": 2 } }
→ (Try it yourself)
Step 5: Display your product page
You can now show the traveller complete details of the accommodation they want to look at, including real-time product availability and prices.→ Select the data from your /accommodations/details and /accommodations/availability responses (in step 3 and 4) to provide the appropriate level of information for your particular business scenario.
After browsing the details of the "Demand API Sandbox Hotel Orion", the traveller decides to book the recommended product.
The booking
Follow different instructions depending on your integration type:
Search and look
If you are using a Search and look integration, you cannot process bookings directly.
However, you can still process and receive commission on bookings by redirecting travellers to the Booking.com website, so that they can make their booking there.
Redirect travellers to Booking.com
To do this when a traveller has chosen the product(s) that they want to book, redirect them to the url
returned in your /accommodations/availability response.
The url
contains your affiliate id (aid
), so that the booking can be attributed to you.
For example:
... "url": "https://www.booking.com/<SELECTED_ACCOMMODATION>.html?aid=956509&checkin=2023-11-06&checkout=2023-11-08&no_rooms=1&group_adults=2&mcid=10" ...
The Booking.com website displays the accommodation page for the traveller's chosen accommodation:
- The Search box shows the traveller's search criteria.
- In the Availability section, the details for the traveller's selected product are shown at the top of the list.
Search, look and book
To process bookings directly in your application you must use the Search, look and book integration type.
1. Preview the order
You can process the bookings directly in your application using the /orders API.
→ Call /orders/preview to get final details of the accommodation and products the traveller is about to book, what they will have to pay, when and how they can pay it, and the applicable cancellation terms.
Use the following fields to construct the request body for the preview order:
Go to the /accommodations/availability request (in step 4).
And copy the used values:
- The value used for
booker.platform
(in this case mobile). - The
booker.country
(nl) currency
: UseEUR
, because the traveller in the example is using your website from the Netherlands.- All prices in the response will be shown both in this currency (as
booker_currency
) and in the accommodation's local currency (asaccommodation_currency
.)
- All prices in the response will be shown both in this currency (as
- The accommodation’s unique identifier
id
- The used
checkin
andcheckout
dates.
- The value used for
Paste same values into your /orders/preview request.
Go to the /accommodations/availability response (in step 4)
Copy the following returned values:
recommendation.products.id
: This is theid
of the cheapest product that meets the search and availability criteria. In this case the value is1050736002_377311511_0_2_0
).accommodation.products.allocation.number_of_adults
: Specify the number of adults who will stay in the room used in the product.- In this case, use the
recommendation.products.number_of_adults
value (2
)
- In this case, use the
Paste the selected values into your /orders/preview request.
Your request body should look like this example.
{ "booker": { "platform": "mobile", "country": "nl" }, "currency": "EUR", "accommodation": { "id": 10507360, "checkin": "2023-11-06", "checkout": "2023-11-08", "products": [ { "id": "1050736002_377311511_0_2_0", "allocation": { "number_of_adults": 2 } }
2. Display your order preview page
You can now show the traveller final details of what they are booking, what they will have to pay, when and how they can pay it, and the cancellation terms that will apply. You should also gather any other information needed from the traveller to complete the order - for example, guest details for rooms, estimated arrival times or special requests.→ Select the data from your /orders/preview response to provide the appropriate information on your preview page.
After checking the details of the order, the traveller supplies their payment information and any other needed information, and proceeds with the booking.
3.Create the order
→ Call /orders/create to process the payment and make the reservation with the accommodation.
Use the following fields to construct the request body:
booker
: Specify theaddress
,email
,name
andtelephone
number details of the person who is making the booking (the traveller, in this example).order_token
: Use theorder_token
returned in the /orders/preview response.- Pass this token to the /orders/create request.
- Using this token reduces the risk of data mismatch errors between the endpoints and provides a more efficient booking experience.
In the payment object:
card
: Specify the card details provided by the traveller.include_receipt
: Set totrue
to generate a receipt that you can provide to the traveller.method
: Specify the payment method, in this case "card".timing
: Choosepay_online_now
, as this is the only supported option for the selected product.
Your request body should look like this example.
... "booker": { "address": { "address_line": "Road-1, house-2", "city": "Amsterdam", "country": "nl", "post_code": "12345" }, "email": "test.name@example.com", "name": { "first_name": "Test", "last_name": "Name" }, "telephone": "12345678" }, "order_token": "eyJhbGciOiJIUzI1NiJ9.eyJ....<truncated for display in this example>...QytoS0yU", "payment": { "card": { "cardholder": "Test Name", "cvc": "123", "expiry_date": "2030-10", "number": "1234123412341234" }, "include_receipt": true, "method": "card", "timing": "pay_online_now" }, }
- Check the Orders section for more tips on how to preview and create your order requests.
- Learn more about all Payment methods.
- For examples and instructions on different payment flows, refer to Payments quick guide.
- Refer to Payments - Use cases section for more details on how to set orders for different payment scenarios.