Integrating with the API
Sending Data
There are several messages at your disposal to query and update the data at Despegar.com. Each message has its own documentation page plus examples, and for some messages, there's also a warning/error codes page.
← You can access all documentation pages through the links at the left.
The First Test Message
Let's try the API by sending a test message. We'll use the Get Hotel Information API to discover general information like name and rooms about hotel ${hotel-id}.
First, you need to make note of the development credentials that have been generated for you (see FAQ for credentials) and create your authorization expression. You should get something like this:
Channel-User api-key="${api-key}", username="${username}", password="${password}", hotel="${hotel-id}"
Then, you can send your first message using curl or any other HTTP test tool you prefer.
curl -iX POST ${environment-dev}hotel-info/get \
-H 'Content-Type: application/xml' \
-H 'Authorization: Channel-User api-key="${api-key}", username="${username}", password="${password}", hotel="${hotel-id}"' \
-d '<OTA_HotelDescriptiveInfoRQ xmlns="http://www.despegar.com/hotels/ota/v1/" Version="1.0">
<HotelDescriptiveInfos LangRequested="en">
<HotelDescriptiveInfo HotelCode="${hotel-id}"/>
</HotelDescriptiveInfos>
</OTA_HotelDescriptiveInfoRQ>'
Notice the URL. This is the sandbox environment where you can play freely. Below you will find more details about this environment.
Remember that each service has its own examples page. All examples can be run from the browser directly, except reservation pushes.
Hotel Outlook
For an overview of the hotel, you need the Get Hotel Information API. From this message you will get:
- The hotel name.
- Hotel room names and IDs.
- Occupancy bounds.
- Whether hotel rates include taxes or not.
This one is particularly important. The Get Rates and Update Rates APIs use different attributes to emphasize the selection between the two models.
- The hotel commission policy.
- The default maximum length-of-stay policy.
- Supported meal-plans.
PAR Discovery
This is a quick rundown of which messages to use to gather PAR information about a hotel:
- Use List Rate Plans to retrieve all rate plans created for a hotel, including:
- Rate plan names and IDs.
- Currency.
- Charge type.
This one is important. The Get Rates and Update Rates APIs expect you to state the exact same charge type code you get here.
- If the rate plan is a child rate plan:
- The rate adjustment.
- Linked restrictions (restrictions inherited from the parent rate plan).
This is the only place so far where the Despegar.com API deviates from OTA since there is no concept of inherited restrictions in the OTA specification.
-
Use List RoomRates (Room + RatePlan) to get room and rate plan assignments.
-
Use Get Availability and Restrictions to retrieve:
- Flexible allotment.
See the meaning of the
@BookingLimitattribute. - Restrictions.
See the interpretation of CTA / CTD / Stop-Sell.
- Use Get Inventory to retrieve:
- Flexible allotment.
- Contract allotment (also known as guaranteed allotment).
- Booking count.
You need the flexible allotment and the booking count to calculate
@BookingLimitwhen updating allotment.
- Use Get Rates to retrieve the current rates for a hotel.
After following all these steps, you should have all the information you need to show the user the current state of the hotel in Despegar.com.
The next step after this is to Update Availability and Restrictions or Update Rates.
Getting Reservations
Despegar.com supports two reservation transfer methods: Pull and Push.
The Pull API allows you to query for reservation by several criteria, being "last update date" the most common. This API is the easiest to integrate with albeit it has its limitations.
The Push API works in the opposite direction, as it will reach out to an endpoint provided by you to send you updates about relevant reservations. See the notes about integrating with this API.
Processing Results
After any call, the response will include either a Success or an Errors element.
The presence of Errors means the message was rejected entirely and may not be
retried until the cause is determined and corrected.
The Success element may also include Warnings, which indicate the message was
partially processed. The warnings should be analyzed since, in most cases, reflect
situations that may not be retried like an invalid room or rate plan code.
The only exception to this rule is the response of a reservation push. In this case, the API will simply expect your endpoint to return a 200 HTTP status code. Any payload content is ignored, and any other status code will mark the event to be retried later.
Sandbox
As mentioned before, your development credentials were created to give you access to the sandbox environment where you can test your integration as needed.
The stub environment (at ${environment-dev}) has the same validations we enforce in production, and we offer a variety of examples trying to show all the different situations you may face while coding.
What is not currently possible is to alter the information, so even if you receive a Success
response you will not see any changes in the hotel.
We have set up two hotels that you can use with two rooms in order to explore and test against all the possible scenarios we support.
The stub environment will behave differently depending upon the hotel / room / date being accessed. The behavior is summarized in the following table:
| Service | January | Febrary | March | July |
|---|---|---|---|---|
| Get restrictions | -- | Empty data | stop-sell | Timeout |
| Get stop-sell | -- | Empty data | -- | Timeout |
| Get allotment | No availability | Empty data | -- | Timeout |
| Update allotment | -- | -- | -- | Timeout |
| Get rates per room | -- | Empty data | -- | Timeout |
| Get rates per person | -- | Empty data | -- | Timeout |
| Update rates | -- | -- | -- | Timeout |
- For other months the response contains information.
- If you want a response for a missing room, try with room ID
1.
Regarding reservations, the stub environment has two reservations:
- Hotel
638049→ Reservation ID1. - Hotel
282445→ Reservation ID2.
Preventing HTTP 429 Errors
Even though the sandbox environment is unrestricted, the certification and production environments restrict the number of requests / operations that you can perform.
These restrictions are tolerant enough to allow for all the operations you would normally need for a hotel, but if you don't follow certain steps, your may see your traffic being limited.
Shaping the traffic within API limits is your responsibility.
To avoid getting HTTP 429 errors, please follow these guidelines:
-
Send as much information as possible in a single message. The limits affect primarily the number of HTTP requests you can send.
-
Avoid unnecessary updates. Blindly re-syncing data will get your quota exhausted.
-
Don't ignore errors or warnings. Only
HTTP 500responses andHTTP 429responses can be retried, eventually. Any otherHTTP 200orHTTP 400response, including anErrorsorWarningselement may not be retried. If you just keep on retrying these cases, you will get your quota exhausted. -
Pay attention if your system re-syncs information too often, or too much at a time. If you re-sync an entire year every time a user makes a minor change, you will get your quota exhausted. This is particularly important for PMS or other revenue management tools, or if any of those piggyback on your channel manager.
-
Come up with an initial load strategy. In some cases, the channel manager doesn't care about allotment or rates loaded in Despegar.com since the channel manager always pushes this information from its own database. If this is your case, you will want to send all the data you have for a hotel at the moment the user enables the connection between your channel and Despegar.com. We expect you to shape the traffic so that you can completely sync the information to us without affecting normal operations.
Further Reading
Take a look at the FAQ.