Display events on your website
Beta — this example targets the Events API beta.
Keep the key on your server. Retrieve the default event listing, select display fields and render those fields on your website. Do not send the original authenticated response or secret to the browser.
Server-side JavaScript
This example requires a server runtime with fetch, such as a Next.js server component or backend job. The page cap bounds the work of a single request; large integrations should synchronize in a background job.
const baseUrl = 'https://api.stello.no/v1';
async function stelloGet(url) {
const key = process.env.STELLO_API_KEY;
if (!key) throw new Error('STELLO_API_KEY is missing');
const response = await fetch(url, {
headers: { Authorization: `Bearer ${key}` },
cache: 'no-store',
signal: AbortSignal.timeout(10_000),
});
if (!response.ok) {
// Record status/request ID, never the request headers or secret.
const requestId = response.headers.get('X-Request-Id');
throw new Error(`Stello returned ${response.status}; request ${requestId}`);
}
return response.json();
}
export async function loadEventCards() {
const cards = new Map();
let cursor;
for (let page = 0; page < 100; page++) {
const url = new URL(`${baseUrl}/events`);
url.searchParams.set('limit', '100');
if (cursor) url.searchParams.set('cursor', cursor);
const result = await stelloGet(url);
for (const event of result.data) {
// Recheck public eligibility before creating the browser projection.
if (event.status !== 'published' || Date.parse(event.ends_at) <= Date.now()) {
continue;
}
cards.set(event.id, {
id: event.id,
title: event.title,
description: event.description,
imageUrl: event.image_url,
startsAt: event.starts_at,
endsAt: event.ends_at,
venue: event.location.name,
bookingUrl: event.url,
pricing: event.pricing,
});
}
if (!result.pagination.has_more) return [...cards.values()];
cursor = result.pagination.next_cursor;
if (!cursor) throw new Error('Missing Stello continuation cursor');
}
throw new Error('Event synchronization exceeded its page budget');
}The example throws on errors instead of silently replacing a failed fetch with an empty event list. Production synchronization should handle 429 and temporary server failures as described in operations, keep a last successful public projection when appropriate, and alert after repeated failures.
Titles, descriptions, images and dates
Escape titles and plain descriptions using your framework’s normal text rendering. description_html is sanitized by Stello, but apply your own HTML policy if inserting it into another environment. Prefer plain text if you do not need formatting.
Display image_url as an image, with title-based alt text and a fallback when absent. Do not attach the bearer key to image requests. Convert UTC dates to your display timezone; for Norwegian events, Europe/Oslo handles daylight-saving transitions. Do not assume UTC+01:00 year-round.
Prices and member tickets
The event’s pricing summary covers publicly listed ticket types only. It selects the type with the lowest indicative total, including the standard service fee. from_amount is the ticket price and from_total_amount includes the standard service fee for that same ticket type. Subtract the two amounts to find the fee. A member-restricted ticket can be cheapest: check requires_membership before presenting a price as open to everyone.
For a full breakdown, follow ticket_types_url and paginate through ticket types. Render only types with publicly_listed: true on a public website. Types may be listed before sales start; check their availability before saying tickets are on sale. Member pricing is represented by separate ticket types with membership requirements, rather than a universal member discount.
Prices are per ticket, in integer øre (NOK). An indicative total can exclude payment-method-dependent additions and discounts. Do not present it as a guaranteed checkout quote. An external ticket link may have an unknown price; null is not free. A free_entry event needs no ticket unless ticket types say otherwise.
Booking and availability
Link to the event’s Stello url for booking. An external ticket type can also provide an external_url. Do not construct checkout links from event IDs or request buyer details through this API.
Availability is a point-in-time display value, affected by shared capacity, holds, sale windows, paused sales and membership eligibility. Never promise a seat based on an API response. remaining: null means an exact count is unavailable or not applicable; it does not mean zero.
Webhooks alongside reads
The read API retrieves current event state. Existing webhooks notify you when supported changes occur. They use separate credentials and an occurrence envelope; API responses are resource objects. An integration may use webhooks to schedule a fresh read, but still needs periodic refreshes for time and inventory changes. The first release does not promise a webhook for every availability or price change.