Developer docs

JavaScript quickstart

Put a working booking widget on a web page, then switch to the headless client when you want your own form — both with a publishable key, no build step.

You will put the BookDinePlay booking widget on a web page and, if you prefer your own form, make the same booking from code with the headless client. You need a page you control, a venue slug and a publishable key.

1. Get a publishable key

In the console open Venue → API keys and create a key of type Publishable. List every origin your page is served from, exactly as the browser writes it, and http://localhost:* for development:

https://www.your-venue.example
http://localhost:*

A publishable key is safe in HTML: the origin list protects it, not secrecy. Never put a secret key (bdp_sk_…) in a page; the SDK refuses to start with one.

2. Add the widget

Anywhere in the page:

<div id="bookdineplay-widget"></div>
<script src="https://cdn.bookdineplay.com/sdk/v1/bookdineplay.js"></script>
<script>
  window.BookDinePlay.renderBookingWidget({
    container: '#bookdineplay-widget',
    venueSlug: 'your-venue',
    apiBaseUrl: 'https://api.bookdineplay.com',
    publishableKey: 'bdp_pk_your_publishable_key',
    resourceTypes: ['RestaurantTable', 'BilliardTable', 'DartBoard']
  });
</script>

Serve the page from an origin you allowed — not from file://, whose Origin: null can never be on a list — and open it. The widget asks for party size, date and time, lists the free slots, collects contact details and confirms with a reference such as BDP-7Q2M4K. JavaScript SDK lists every option and Theming restyles it.

3. Or keep your own form

The widget runs on a headless client you can use directly. Load the same script, then make the two calls a booking needs: look up free slots, book one.

const client = window.BookDinePlay.createClient({
  apiBaseUrl: 'https://api.bookdineplay.com',
  publishableKey: 'bdp_pk_your_publishable_key',
  venueSlug: 'your-venue'
});

// Which times are free for four people tomorrow?
const tomorrow = new Date(Date.now() + 24 * 60 * 60 * 1000).toISOString().slice(0, 10);
const availability = await client.availability({
  date: tomorrow,
  partySize: 4,
  resourceType: 'RestaurantTable'
});
const slot = availability.slots.find((s) => s.available);

// Book it. One idempotency key per attempt makes a retry safe.
const reservation = await client.reserve(
  {
    resourceType: 'RestaurantTable',
    resourceId: slot.resourceId,
    date: availability.date,
    start: slot.start,
    partySize: 4,
    customerName: 'Jana Berger',
    email: 'jana@example.com'
  },
  { idempotencyKey: crypto.randomUUID() }
);
console.log(reservation.reference, reservation.status);

Run it in a <script type="module"> (for top-level await) or inside an async function. reservation.status is Confirmed, or Pending when the venue asks for a deposit (Deposits). The guest receives the confirmation e-mail.

Check that it worked

Open the console at app.bookdineplay.com: the booking is in the reservation list with the reference you logged. Cancel it there to free the slot.

If it does not work

  • Nothing renders and the browser console names the key. publishableKey is required; the widget refuses to call the API without one.
  • 403 origin-not-allowed. The page's origin is not on the key's list. Create a new key that lists every origin, deploy it and revoke the old one (Rotating a key).
  • 401 invalid-api-key. The key was mistyped or revoked.
  • 409 when booking. The slot was taken after you looked: ask for availability again and offer the next one.

Next steps