PHP code example of flairuk / laravel-booking-com
1. Go to this page and download the library: Download flairuk/laravel-booking-com library . Choose the download type require .
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
flairuk / laravel-booking-com example snippets
use FLAIRUK\BookingCom\Facades\BookingCom;
$response->data(); // the "data" array
$response->metadata(); // the "metadata" array
$response->requestId(); // quote this to Booking.com support
$response->total(); // metadata.total_results
$response->toArray(); // the whole body
foreach ($response as $item) { /* items in data */ }
count($response);
$response[0]['id'];
$results = BookingCom::accommodations()->search([
'city' => -2140479, // Amsterdam: see Locations below
'checkin' => now()->addMonth(),
'checkout' => now()->addMonth()->addDays(2),
'guests' => ['number_of_adults' => 2, 'number_of_rooms' => 1],
'booker' => ['country' => 'gb', 'platform' => 'desktop'],
'currency' => 'GBP',
'extras' => ['extra_charges', 'products'],
'rows' => 20,
]);
$results->total(); // e.g. 122
foreach ($results->lazy() as $property) { // walks every page on demand
// ...
}
BookingCom::accommodations()->availability([
'accommodations' => [10507360],
'checkin' => '2026-11-01',
'checkout' => '2026-11-03',
'guests' => ['number_of_adults' => 2, 'number_of_rooms' => 1],
]);
BookingCom::accommodations()->find(10507360, extras: ['description', 'facilities', 'photos', 'policies', 'rooms']);
BookingCom::accommodations()->details(['city' => -2140479, 'rows' => 100])->lazy();
BookingCom::accommodations()->reviews(['accommodations' => [10507360], 'languages' => ['en-gb']]);
BookingCom::accommodations()->reviewScores(['accommodations' => [10507360]]);
BookingCom::accommodations()->constants(); // facility, room type, meal plan ids… (cached)
BookingCom::accommodations()->chains(); // hotel chains and brands (cached)
foreach (BookingCom::accommodations()->changesSince($lastSync, ['countries' => ['gb']]) as $batch) {
$batch['changed']; // ids to re-fetch with find()
$batch['opened']; // new properties
$batch['closed']; // properties to hide
$lastSync = $batch['next'] ?? $batch['from'];
}
BookingCom::locations()->cities(['country' => 'nl', 'languages' => ['en-gb']])->lazy();
BookingCom::locations()->countries();
BookingCom::locations()->regions(['country' => 'gb']);
BookingCom::locations()->districts(['city' => -2140479]);
BookingCom::locations()->landmarks(['city' => -2140479]);
BookingCom::locations()->airports(['country' => 'gb']);
BookingCom::common()->languages(); // cached
BookingCom::common()->currencies(); // cached
BookingCom::common()->cards(); // cached
BookingCom::cars()->search([
'route' => [
'pickup' => ['datetime' => '2026-11-01T10:00:00', 'location' => ['airport' => 'AMS']],
'dropoff' => ['datetime' => '2026-11-03T10:00:00', 'location' => ['airport' => 'AMS']],
],
'driver' => ['age' => 35],
'currency' => 'EUR',
]);
BookingCom::cars()->details();
BookingCom::cars()->depots();
BookingCom::cars()->suppliers(); // cached
BookingCom::cars()->constants(); // cached
BookingCom::post('attractions/search', ['city' => -2140479]);
BookingCom::post('orders/modify/preview', $body, retry: false); // pass retry: false for anything that changes state
$preview = BookingCom::orders()->preview([
'accommodation' => [
'id' => 10507360,
'checkin' => '2026-11-01',
'checkout' => '2026-11-03',
'products' => [['id' => $productId, 'allocation' => ['number_of_adults' => 2]]],
],
'currency' => 'GBP',
]);
$order = BookingCom::orders()->create([
'order_token' => $preview->data()['order_token'],
'booker' => [
'name' => ['first_name' => 'Jane', 'last_name' => 'Doe'],
'email' => '[email protected] ',
'telephone' => '+441234567890',
'address' => ['address_line' => '1 High Street', 'city' => 'London', 'country' => 'gb', 'post_code' => 'SW1A 1AA'],
],
'payment' => ['timing' => 'pay_at_the_property'],
]);
BookingCom::orders()->find($orderId);
BookingCom::orders()->details(['created' => ['from' => '2026-10-01', 'to' => '2026-10-07']])->lazy(); // max 7-day range
BookingCom::orders()->accommodations(['orders' => [$orderId]]);
BookingCom::orders()->modify(['order' => $orderId, 'modification' => [/* ... */]]);
BookingCom::orders()->cancelAccommodation($reservationId, 'Guest changed plans');
$messages = BookingCom::version('3.1')->messages();
$messages->latest();
$messages->confirm(['message-id']);
$messages->conversation(['accommodation' => 10507360, 'reservation' => $reservationId]);
$messages->send(['accommodation' => 10507360, 'conversation' => $conversationId, 'content' => 'What time is check-in?']);
use FLAIRUK\BookingCom\Exceptions\AuthenticationException;
use FLAIRUK\BookingCom\Exceptions\BookingComException;
use FLAIRUK\BookingCom\Exceptions\RateLimitException;
try {
BookingCom::accommodations()->search($query);
} catch (RateLimitException $e) {
// per-minute quota exceeded: wait $e->retryAfter() seconds (usually 60)
} catch (AuthenticationException $e) {
// missing or rejected API key / affiliate ID
} catch (BookingComException $e) {
$e->errorIds(); // e.g. ['invalid_request']
$e->errors; // [['id' => ..., 'message' => ...]]
$e->requestId; // quote this to Booking.com support
$e->response?->json(); // the full response
}
catch (RateLimitException $e) {
$this->release($e->retryAfter());
}
BookingCom::sandbox()->accommodations()->search($query);
BookingCom::version('3.1')->accommodations()->bulkAvailability($query);
BookingCom::forAffiliate($otherAffiliateId, $otherToken)->orders()->find($orderId);
Http::fake([
'demandapi*.booking.com/*/accommodations/search' => Http::response(['request_id' => 'test', 'data' => []]),
]);
bash
php artisan booking-com:status