This guide will walk you through the steps required to request hotel pricing using the Tripadvisor Hotel Pricing API. The expected audience for this guide is a developer with a basic understanding of REST APIs. This guide details the request and response formats for the API and provides examples for common uses.
The Tripadvisor Hotel Pricing API V3 is a service that allows site publishers to request hotel pricing information. This API allows for hotel pricing search by hotel ids or by location id. Upon a successful search, the response containing the hotel id, availability, and offer including the best price, logo, URL to Tripadvisor /HotelHighlight page, etc are provided to the client for display on the page.
The following steps outline the process for integrating with the Tripadvisor Hotel Pricing API on your site:
Obtain API Access Keys
Before accessing the API, please contact your Tripadvisor account manager for the relevant access API keys. These will be used as part of the Request API.
Pass Required Parameters
Refer to the Request API for all required parameters to make a successful request.
All API requests must be made over https. Note: The partner will need to set a user agent and use api.tripadvisor.com for the API calls to ensure that all requests are sent through.
Please safeguard your access key. To include it with each request, set it as the value of the X-Tripadvisor-API-Key header. If you need to make API calls from client code, be aware this may expose your key to other scripts and browser extensions on the client.
Tripadvisor reserves the right to revoke an access key at any time and issue a new one, if a key has leaked or is being misused.
Tripadvisor sets daily and per-second call limits on each key used to access the Partner API. Talk with your Account Manager to evaluate what kind of traffic you will be expecting to web pages containing Tripadvisor content. The rate limit measures on a 24 hour rolling window. The window starts with the first call made and resets 24 hours later. There is no fixed time of day when the window resets. If the window resets and no calls are made for a given key, a new window is not opened until the next call is make for a given key. The calls per second work similarly.
The partner API returns an HTTP status code of 429, “too many requests”, when either the per-second or per-day limits are reached. The two cases are distinguished by the error code in the response body. The response body will contain an error message in a JSON object. For the per-second limit, the response body will be like:
{
"error": {
"message": "Maximum number of requests per second exceeded: (Max: 50 per sec)",
"code": "150",
"type": "TooManyRequestsException"
}
}
For the daily limit, the response body will be like:
{
"error": {
"message": "Maximum number of daily requests exceeded: (Max: 100000 per day)",
"code": "151",
"type": "TooManyRequestsException"
}
}
Tripadvisor recommends that partners cache the content from API responses for up to one hour. This allows your application to show content more quickly if it has been requested before.
Caching also reduces the load on Tripadvisor’s content servers. Do not use the API to pre-fetch content for your entire inventory. Request only the content you need, at the moment you need it.