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.tsBecause 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?
- Bootstrap site metadata: Call
site.getto read branding, supportedlocales,currency,timeZone,locationsand operator-widetrustSignals. See locales, dates & pagination and site metadata, locations & trust. - Browse activities or dates: Query
GET /activities(orPOST /activities/query) for activity cards, orGET /availabilities(orPOST /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. Treat404 not_foundas an unavailable collection and check the configuration before retrying.
- To browse a configured collection, pass its UUID as
- Render headline prices from
BookingOptions.priceSummary:kindissingle,leadorrange(nullmeans no headline price).singlemeans one form exists among the selected availabilities.leadnames the primary open form viapublicTitle(preferring localized link override, then variation meta title, then label), whileoptions[].variationTitlestays the option's display title. ShowotherFormsMinimumonly when non-null and cheaper than the lead minimum.rangeappears 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.
- Render activity content, media and PDFs:
Activity.description,Activity.htmlandActivity.uspsproject platform presentation definitions_bg:meta,_bg:contentand_bg:usps, respectively. An operator may leave any unused, and a frontend may ignore any of them.htmlis sanitized rich text (scripts, event handlers, embeds and images removed) and may benull;uspsmay be empty.titleremains activity identity.Activity.mediamay be empty; render a clean placeholder or text-only layout. Never modify signed image URLs or invent widths; buildsrcsetsolely from returnedsrcSetentries. See how to render media.- Public PDFs appear as
pdfentries inActivity.customFacts; link directly to their returned storefront document URLs.
- Render places, timezones and trust:
- Use
Activity.trustSignalsfor activity-relevant evidence andSite.trustSignalsfor operator-wide evidence; preserve position order and preferlogoover interimlogoUrl. - Render start times in the departure location's
timezoneand end times in the arrival location'stimezonewhen set, falling back independently to the availability's operator-defaulttimeZone. Never guess a venue fromSite.locationswhen an itinerary is empty. See site metadata, locations & trust.
- Use
- 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 sumremainingacross availabilities. - Submit returned opaque
skuvalues and quantities toPOST /checkout/handoff, display any warnings andlistedTotal, then navigate tohandoff.urlunchanged.
- Grouping availabilities by event or week is presentation only. Use
- Handle states explicitly: Render loading, empty, validation-error, sold-out and retryable
count_timeoutstates. UsesupportedMatcheson facet controls and checkoptionsTruncatedbefore 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)