Docs

Build a storefront & SDK

Generate a typed client from OpenAPI and wire activity, availability and checkout flows.

Early access. Use the API base, channel key and allowed origins supplied by Buchung before running examples. Interactive API requests are disabled here.

How do I generate a TypeScript SDK?

Download the OpenAPI document as buchung-openapi.json in your project. A generated client is optional: plain fetch works too.

The API base is https://api.buchungapp.com/v1. Guide paths are relative to that base; never prepend /v1 twice. For plain fetch, normalize a trailing slash once (const apiBase = suppliedApiBase.replace(/\/+$/, '') + '/') and call new URL('activities', apiBase) without a leading slash.

Create openapi-ts.config.ts:

export default {
  input: './buchung-openapi.json',
  output: 'src/generated/buchung',
  plugins: [
    '@hey-api/typescript',
    '@hey-api/client-fetch',
    {
      name: '@hey-api/sdk',
      operations: {
        strategy: 'single',
        containerName: 'StorefrontClient',
        nesting: 'operationId',
      },
    },
  ],
};

Run the generator:

npx @hey-api/openapi-ts@0.99.0 -f openapi-ts.config.ts

Because the OpenAPI paths already include /v1, set the generated client's transport base URL to https://api.buchungapp.com (without /v1). Keep generated types separate from UI components and pin the OpenAPI file you generated from.

Open vocabularies generate known string literals alongside string, so switch statements should always include a fallback:

import type { CheckoutHandoff } from './generated/buchung/types.gen.js';

export function warningMessage(
  code: CheckoutHandoff['warnings'][number]['code'],
): string {
  switch (code) {
    case 'sold_out_at_handoff':
      return 'This selection has sold out.';
    default:
      return 'Check this selection before continuing to checkout.';
  }
}

See How the contract grows for which response vocabularies are open versus closed.

How should I structure the integration?

  1. Bootstrap site metadata: Call site.get to read branding, supported locales, currency, timeZone, locations and operator-wide trustSignals. See locales, dates & pagination and site metadata, locations & trust.
  2. Browse activities or dates: Query GET /activities (or POST /activities/query) for activity cards, or GET /availabilities (or POST /availabilities/query) for date-first browsing. Resolve direct links by handle via /activities/by-handle/{handle}, then retain the UUID.
    • To browse a configured collection, pass its UUID as collectionId. A collection returns the activities it selects without exposing its selection criteria. Treat 404 not_found as an unavailable collection and check the configuration before retrying.
  3. Render headline prices from BookingOptions.priceSummary:
    • kind is single, lead or range (null means no headline price).
    • single means one form exists among the selected availabilities.
    • lead names the primary open form via publicTitle (preferring localized link override, then variation meta title, then label), while options[].variationTitle stays the option's display title. Show otherFormsMinimum only when non-null and cheaper than the lead minimum.
    • range appears when multiple open forms have no ordering weight.
    • Show a "from" prefix when the lead minimum and maximum differ; rentals always show "from" with overallMinimum. Advertised prices already include compulsory upsells (unless excluded by the operator) and automatic promotions.
  4. Render activity content, media and PDFs:
    • Activity.description, Activity.html and Activity.usps project platform presentation definitions _bg:meta, _bg:content and _bg:usps, respectively. An operator may leave any unused, and a frontend may ignore any of them. html is sanitized rich text (scripts, event handlers, embeds and images removed) and may be null; usps may be empty. title remains activity identity.
    • Activity.media may be empty; render a clean placeholder or text-only layout. Never modify signed image URLs or invent widths; build srcset solely from returned srcSet entries. See how to render media.
    • Public PDFs appear as pdf entries in Activity.customFacts; link directly to their returned storefront document URLs.
  5. Render places, timezones and trust:
    • Use Activity.trustSignals for activity-relevant evidence and Site.trustSignals for operator-wide evidence; preserve position order and prefer logo over interim logoUrl.
    • Render start times in the departure location's timezone and end times in the arrival location's timezone when set, falling back independently to the availability's operator-default timeZone. Never guess a venue from Site.locations when an itinerary is empty. See site metadata, locations & trust.
  6. Choose options and hand off to checkout:
    • Grouping availabilities by event or week is presentation only. Use /activities/{id}/booking-options (following cursors if needed) so the chooser has complete options, and never sum remaining across availabilities.
    • Submit returned opaque sku values and quantities to POST /checkout/handoff, display any warnings and listedTotal, then navigate to handoff.url unchanged.
  7. Handle states explicitly: Render loading, empty, validation-error, sold-out and retryable count_timeout states. Use supportedMatches on facet controls and check optionsTruncated before claiming a facet list is complete. Refresh options after each selection and start from the first page when filters change.

Where should configuration live?

Store the API base and publishable channel key (bg_st_...) in your frontend configuration and call the Storefront API directly from the browser on an allowed origin. A server proxy is optional; authentication explains the rate-limit trade-off. Keep Management API credentials (bg_it_...) strictly server-side. Give Buchung every production and preview origin your site runs on.

Pre-launch verification checklist

Test against your sandbox operator from an actual allowed origin before going live:

  • Site bootstrap, locale switching and fallback headers (Content-Language, Buchung-Locale-Fallback)
  • Activity list, handle resolution, unlisted direct access, typed filters and facet counts
  • Pagination cursors and retry behavior on 503 count_timeout
  • CORS preflight and responses from your production and preview origins
  • Checkout handoff warnings (sold_out_at_handoff) and end-to-end test-mode checkout completion (see sandbox & testing)