This guide helps developers transition from LiteAPI V2 to V3 by outlining the breaking changes and providing updated examples.
Overall changes in LiteAPI v3
Developers transitioning from LiteAPI v2 to v3 will need to adapt to significant changes in endpoint structures and request parameters. The removal of the minimum rate API (GET /v2.0/hotels
) simplifies the API offerings but requires adjustments in how rates are queried. The full rate API has shifted from a GET
to a POST
request, now supporting multi-room bookings through an array of occupancies
objects, each detailing the number of adults and children per room. Responses now include an offerId
used for subsequent steps.
Additionally, the prebook endpoint (POST /v3.0/rates/prebook
) now mandates the use of offerId
and introduces a usePaymentSdk
flag for client-side payment handling, returning a transactionId
. The booking completion endpoint (POST /v3.0/rates/book
) has been updated to accept a transactionId
when the method
is set to TRANSACTION_ID
, ensuring seamless payment confirmation and customer charging. Additionally, a new required field remarks
has been added. These changes enhance the API’s flexibility and functionality, necessitating updates to existing integration logic.
Walkthrough of the breaking changes
1. Removal of Minimum Rate API
- The minimum rate API (
GET /v2.0/hotels
) is no longer available. This endpoint has been deprecated to streamline the API offerings and focus on more comprehensive rate searches.
2. Full Rate API Changes
The full rate API is now a POST
request instead of GET
.
The request body now supports booking multiple rooms at once by requiring an array of occupancies
objects. Each object must specify the number of adults
and the ages of children
for each room requested. The response includes an offerId
to be used in the prebook step.
- Endpoint:
POST /v3.0/hotels/rates
- Body Parameters: Now requires an array of
occupancies
objects to support booking multiple rooms.- Each
occupancies
object includes:adults
: Number of adults.children
: Ages of children.
- Each
- Response: Includes an
offerId
for use in the prebook step.
Example Request:
const apiKey = 'YOUR_API_KEY';
async function getHotelRates(hotelId, checkinDate, checkoutDate, occupancies) {
const response = await fetch(`https://api.liteapi.travel/v3.0/hotels/rates`, {
method: 'POST',
headers: {
'X-API-Key': apiKey,
'Content-Type': 'application/json'
},
body: JSON.stringify({
hotelIds: [hotelId],
checkin: checkinDate,
checkout: checkoutDate,
occupancies: occupancies,
currency: 'USD',
guestNationality: 'US'
})
});
const data = await response.json();
console.log(data);
return data.roomTypes;
}
const occupancies = [
{ adults: 2, childrenAges: [5, 7] },
{ adults: 1, childrenAges: [] }
];
getHotelRates('hotel_123', '2024-06-01', '2024-06-05', occupancies);
3. Prebook Endpoint Changes
The prebook endpoint now requires an offerId
from the full rate API. The payWithStripe
parameter has become usePaymentSdk
, which must be set to true
when the payment is handled by the client-side payment SDK. This generates and returns a transactionId
and an occupancy number.
- Endpoint:
POST /v3.0/rates/prebook
- Parameters: Requires an
offerId
from the full rate API and an optionalusePaymentSdk
flag. - Response: Returns a
transactionId
.
Example Request:
async function prebookRate(offerId, usePaymentSdk) {
const response = await fetch('https://api.liteapi.travel/v3.0/rates/prebook', {
method: 'POST',
headers: {
'X-API-Key': apiKey,
'Content-Type': 'application/json'
},
body: JSON.stringify({
offerId: offerId,
usePaymentSdk: usePaymentSdk
})
});
const data = await response.json();
console.log(data);
return data.transactionId;
}
prebookRate('offer_123', true);
4. Booking Completion Endpoint Changes
The endpoint for completing a booking now accepts a transactionId
when the method in the request body is set to TRANSACTION_ID
. This confirms the payment and charges the customer. Additionally, the guestInfo
parameter has been renamed to guests
and it supports an array of objects. A new required field remarks
has also been added.
- Endpoint:
POST /v3.0/rates/book
- Parameters: Accepts a
transactionId
whenmethod
is set toTRANSACTION_ID
. TheguestInfo
parameter has also been renamed toguests
and it supports an array of objects.
Example Request:
async function completeBooking(transactionId) {
const response = await fetch('https://api.liteapi.travel/v3.0/rates/book', {
method: 'POST',
headers: {
'X-API-Key': apiKey,
'Content-Type': 'application/json'
},
body: JSON.stringify({
prebookId: 'prebook_123',
holder: { firstName: 'John', lastName: 'Doe', email: '[email protected]' },
payment: {
method: 'TRANSACTION_ID',
transactionId: transactionId
},
guests: [
{
occupancyNumber: 1,
firstName: 'John',
lastName: 'Doe',
remarks: 'quiet room please'
}
],
remarks: 'Please provide a baby cot.'
})
});
const data = await response.json();
console.log(data);
}
completeBooking('transaction_123');
5. Removal of 3DS Endpoint
The 3DS endpoint has been removed. Any logic involving this endpoint should be updated accordingly.
6. List Bookings Changes
The list bookings endpoint now uses clientReference
instead of guestId
.
Recap
Transitioning from LiteAPI v2 to v3 involves significant changes to the endpoints and request structures. The main differences include the removal of the minimum rate API, changes to the full rate API, and updates to the prebook and booking endpoints to accommodate new parameters and processes. Additionally, the 3DS endpoint has been removed, and the list bookings endpoint now uses clientReference
instead of guestId
. Use this guide to update your code and ensure a smooth migration to LiteAPI v3.
Please get in touch with our team if you need more assistance in migrating your application to this new version of the API.