Python SDK
The Bundleport Python SDK provides a simple, type-safe client for the Connect Hotels REST API.
Install
pip install bundleport-connect-hotels
Initialize the Client
from bundleport import BundleportClient
client = BundleportClient(
api_key='YOUR_API_KEY_HERE',
base_url='https://api.bundleport.com', # Optional, defaults to production
timeout=30, # Optional, request timeout in seconds
)
Booking Operations
Search for Hotels
search_result = client.hotels.search(
stay={
'checkIn': '2025-06-15',
'checkOut': '2025-06-17',
},
destination={'code': 'BCN'},
occupancies=[
{
'adults': 2,
'children': 1,
'childrenAges': [8],
}
],
filters={
'currency': 'EUR',
'minPrice': 100,
'maxPrice': 300,
},
settings={
'accessIds': ['ACCESS_1'],
},
)
print(f"Found {len(search_result['options'])} options")
Quote an Option
quote_result = client.hotels.quote(
optionRefId=search_result['options'][0]['optionRefId'],
settings={'accessIds': ['ACCESS_1']},
)
# Check for price changes
warnings = quote_result.get('warnings', [])
if any(w.get('code') == 'PRICE_CHANGED' for w in warnings):
print('Price has changed:', quote_result['price'])
Create a Booking
booking = client.hotels.book(
optionRefId=quote_result['optionQuote']['optionRefId'],
holder={
'name': 'John',
'surname': 'Doe',
'email': 'john.doe@example.com',
'phone': '+34600123456',
},
rooms=[
{
'occupancyRefId': 1,
'paxes': [
{'name': 'John', 'surname': 'Doe', 'age': 35},
{'name': 'Jane', 'surname': 'Doe', 'age': 33},
],
}
],
paymentCard={
'type': 'VI',
'number': '4111111111111111',
'expire': {'month': 12, 'year': 2027},
'holder': {'name': 'John', 'surname': 'Doe'},
},
clientReference='BOOKING-2025-001',
)
print(f"Booking confirmed: {booking['booking']['id']}")
Retrieve Booking
booking_details = client.hotels.get_booking('BK-987654321')
print(f"Booking status: {booking_details['booking']['status']}")
List Bookings
bookings = client.hotels.list_bookings(
filters={
'status': ['CONFIRMED'],
'dateRange': {
'from': '2025-06-01',
'to': '2025-06-30',
},
},
pagination={
'page': 1,
'pageSize': 20,
},
)
print(f"Found {len(bookings['bookings'])} bookings")
Cancel Booking
cancel_result = client.hotels.cancel(
'BK-987654321',
reason='Customer request',
cancelPenalty={'apply': True},
)
penalty = cancel_result['booking']['cancelInfo'].get('penalty')
if penalty:
print(f"Cancellation penalty: {penalty['amount']} {penalty['currency']}")
Content Operations
Get Hotels
hotels = client.content.get_hotels(
query={
'destinationCodes': ['BCN'],
'maxSize': 100,
},
)
print(f"Found {len(hotels['hotels']['hotels'])} hotels")
Get Rooms
rooms = client.content.get_rooms(
query={
'connectionCode': 'CONN_1',
'maxSize': 50,
},
)
Get Destinations
destinations = client.content.get_destinations(
query={'maxSize': 100},
)
Error Handling
from bundleport.exceptions import BundleportError, UnauthorizedError, RateLimitError
try:
result = client.hotels.search({...})
except UnauthorizedError:
print('Invalid API key')
except RateLimitError as e:
print(f'Rate limit exceeded, retry after: {e.retry_after} seconds')
except BundleportError as e:
print(f'API error: {e.message}')
Next Steps
- REST API Reference - Complete endpoint documentation
- Content API Reference - Content catalog endpoints
- Error Handling Guide - Learn how to handle errors