JavaScript & TypeScript SDK
Install
npm install @bundleport/connect-hotels-client @bundleport/connect-hotels-js
# or
yarn add @bundleport/connect-hotels-client @bundleport/connect-hotels-js
The package provides a TypeScript client for the Bundleport Connect Hotels service. The @bundleport/connect-hotels-js package contains the protobuf type definitions.
Initialize the client
import { IntegrationClient } from '@bundleport/connect-hotels-client';
const client = new IntegrationClient({
baseUrl: 'https://api.connect.bundleport.com',
timeoutMs: 5000,
headers: {
Authorization: 'ApiKey <your-bundleport-key>',
},
debug: false, // Set to true to send/receive JSON instead of protobuf
});
Service calls
Each RPC method is directly available on the client instance and returns typed promises.
import { hotels } from '@bundleport/connect-hotels-js';
// Search for hotels
const searchRequest = hotels.request.search.SearchRequest.create({
stay: {
checkIn: '2025-02-10',
checkOut: '2025-02-12',
},
occupancies: [{ paxes: [{ age: 30 }] }],
settings: {
accessIds: ['YOUR_ACCESS_ID'],
},
});
const searchResponse = await client.search(searchRequest);
// Get a quote for a selected option
const quoteRequest = hotels.request.quote.QuoteRequest.create({
optionRefId: searchResponse.options?.[0]?.optionRefId ?? '',
settings: {
accessIds: ['YOUR_ACCESS_ID'],
},
});
const quoteResponse = await client.quote(quoteRequest);
// Book the hotel
const bookRequest = hotels.request.book.BookRequest.create({
optionRefId: quoteResponse.optionQuote?.optionRefId ?? '',
holder: {
name: 'Alice',
surname: 'Doe',
},
settings: {
accessIds: ['YOUR_ACCESS_ID'],
},
});
const bookResponse = await client.book(bookRequest);
// Cancel a booking
const cancelRequest = hotels.request.cancel.CancelRequest.create({
bookingReference: bookResponse.booking?.reference?.bookingID ?? '',
settings: {
accessIds: ['YOUR_ACCESS_ID'],
},
});
await client.cancel(cancelRequest);
// Get booking details
const detailRequest = hotels.request.bookingDetail.BookingDetailRequest.create({
bookingReference: bookResponse.booking?.reference?.bookingID ?? '',
settings: {
accessIds: ['YOUR_ACCESS_ID'],
},
});
await client.bookingDetail(detailRequest);
// List bookings
const listRequest = hotels.request.bookingList.BookingListRequest.create({
filters: {
pageSize: 25,
},
settings: {
accessIds: ['YOUR_ACCESS_ID'],
},
});
await client.bookingList(listRequest);
Other available methods:
getBoards(request)getCategories(request)getHotels(request)getRooms(request)getDestinations(request)getMetadata(request)searchDestinations(request)
All methods resolve to the generated TypeScript models. See the REST API reference for field-level documentation.