SDKs & Code Examples

Ready-to-use code examples for integrating with the BOOQR API in your preferred language.

Node.js / TypeScript

booqr-client.tstypescript
const BOOQR_API_URL = process.env.BOOQR_API_URL!;
const BOOQR_API_KEY = process.env.BOOQR_API_KEY!;
const TENANT_ID = process.env.BOOQR_TENANT_ID!;

async function booqrFetch(path: string, options?: RequestInit) {
  const res = await fetch(`${BOOQR_API_URL}/tenants/${TENANT_ID}${path}`, {
    ...options,
    headers: {
      "Authorization": `Bearer ${BOOQR_API_KEY}`,
      "Content-Type": "application/json",
      ...options?.headers,
    },
  });

  if (!res.ok) {
    const error = await res.json();
    throw new Error(`BOOQR API Error ${res.status}: ${error.error}`);
  }

  return res.json();
}

// List confirmed bookings
const { bookings } = await booqrFetch("/bookings?status=CONFIRMED");

// Create a booking
const { booking } = await booqrFetch("/bookings", {
  method: "POST",
  body: JSON.stringify({
    objectId: "uuid",
    guestName: "Jan de Vries",
    guestEmail: "jan@example.com",
    startTime: "2026-02-18T10:00:00Z",
    endTime: "2026-02-18T11:00:00Z",
  }),
});

// Check availability
const { objects } = await booqrFetch(
  "/objects/availability?date=2026-02-18"
);

Python

booqr_client.pypython
import os
import requests

BOOQR_API_URL = os.environ["BOOQR_API_URL"]
BOOQR_API_KEY = os.environ["BOOQR_API_KEY"]
TENANT_ID = os.environ["BOOQR_TENANT_ID"]

def booqr_request(method, path, data=None):
    url = f"{BOOQR_API_URL}/tenants/{TENANT_ID}{path}"
    headers = {
        "Authorization": f"Bearer {BOOQR_API_KEY}",
        "Content-Type": "application/json",
    }

    response = requests.request(method, url, json=data, headers=headers)
    response.raise_for_status()
    return response.json()


# List confirmed bookings
data = booqr_request("GET", "/bookings?status=CONFIRMED")
for booking in data["bookings"]:
    print(f"{booking['guestName']} - {booking['startTime']}")

# Create a booking
result = booqr_request("POST", "/bookings", {
    "objectId": "uuid",
    "guestName": "Jan de Vries",
    "guestEmail": "jan@example.com",
    "startTime": "2026-02-18T10:00:00Z",
    "endTime": "2026-02-18T11:00:00Z",
})
print(f"Created: {result['booking']['id']}")

# Check availability
avail = booqr_request("GET", "/objects/availability?date=2026-02-18")
for obj in avail["objects"]:
    available = sum(1 for s in obj["slots"] if s["available"])
    print(f"{obj['objectName']}: {available} slots available")

PHP

BooqrClient.phpphp
<?php

class BooqrClient {
    private string $apiUrl;
    private string $apiKey;
    private string $tenantId;

    public function __construct(
        string $apiUrl,
        string $apiKey,
        string $tenantId
    ) {
        $this->apiUrl = $apiUrl;
        $this->apiKey = $apiKey;
        $this->tenantId = $tenantId;
    }

    public function request(string $method, string $path, ?array $data = null): array {
        $url = "{$this->apiUrl}/tenants/{$this->tenantId}{$path}";

        $ch = curl_init($url);
        curl_setopt_array($ch, [
            CURLOPT_RETURNTRANSFER => true,
            CURLOPT_CUSTOMREQUEST => $method,
            CURLOPT_HTTPHEADER => [
                "Authorization: Bearer {$this->apiKey}",
                "Content-Type: application/json",
            ],
        ]);

        if ($data !== null) {
            curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($data));
        }

        $response = curl_exec($ch);
        $statusCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
        curl_close($ch);

        if ($statusCode >= 400) {
            throw new Exception("BOOQR API Error {$statusCode}: {$response}");
        }

        return json_decode($response, true);
    }
}

// Usage
$client = new BooqrClient(
    getenv('BOOQR_API_URL'),
    getenv('BOOQR_API_KEY'),
    getenv('BOOQR_TENANT_ID')
);

$bookings = $client->request('GET', '/bookings?status=CONFIRMED');