This is DEMO site for Car-Booker.eu -
online booking solution for car rental services & vehicle sellers.
Learn more Module "REST API"
The "REST API" module enables authorized communication between the CarBooker application and third-party applications. An example could be receiving an order from an external partner website or loading statistics for a selected period - number and price of orders, activity logs, etc.
Example of sending a REST request
Every API request sent to the {booker} application must include an authentication key and must be sent using the correct method (POST, PUT, GET ..) with valid parameters. Otherwise, the server returns an error. Following example creates a new order by receiving the order data from an external website.:
// 1. step - prepare collected customer and order data
$postData = [
// required authentication API key
"xauth" => "Sd5f8_ERtT8-Po6E...",
// required customer data
"Customer" => [
"email" => "john.doe@gmail.com",
"phone" => "0905 123456",
"firstname" => "John",
"lastname" => "Doe",
"street_num" => "Toryská 123/a",
"zip" => "04011",
"city" => "Košice",
],
// required order data
"Order" => [
"car_pickup_datetime" => "2025-12-24",
"select_pickup_time" => "10:00",
"car_return_datetime" => "2025-12-28",
"select_return_time" => "16:00",
"select_pickup_place" => "address",
"car_pickup_city" => "Košice",
"car_pickup_street_num" => "Moldavská 123",
"car_pickup_zip" => "04011",
"select_return_place" => "same_as_pick",
"notes_by_customer" => "Prosím prezvoniť pred príchodom.",
],
// vehicle data .. if missing, a "Request for quote" will be created
"Car" => [
...
],
];
// 2. step - we send data to the API interface of the CarBooker application (in PHP)
$options = [
"http" => [
"method" => "POST",
"timeout" => 5, // if necessary, adjust the settings, e.g. timeout 5 seconds
"content" => http_build_query($postData), // order data
"header" => [
"Content-type: application/x-www-form-urlencoded; charset=utf-8",
],
],
];
// URL of the site where our CarBooker runs, to which we are sending the order
$url = "https://my-rent-car.site/api/order/create";
$errorMsg = $successMsg = "";
try {
// the order data
$ctx = stream_context_create($options);
$response = file_get_contents($url, false, $ctx);
// processing response - we have either the new order number, or list of errors
if (!empty($response["errors"])) {
$errorMsg = implode(" ", $response["errors"]);
} elseif (!empty($response["orderId"])){
$successMsg = "OK - create dnew order ID={$response["orderId"]}.";
} else {
$errorMsg = "Unknown error.";
}
} catch (\Exception $e) {
$errorMsg = $e->getMessage();
}
if (!empty($errorMsg)) {
exit("Error - order not created - cause: ".$errorMsg);
}