Developers
Seat map
One script, no dependencies. The <seat-map> element is the quick way: it loads the chart, availability and prices and stays live. The SeatMap class is the same map with every option, for pages that load their own data.
The element
<script type="module" src="https://seatpublic.com/sdk/seatmap/v0/index.js"></script>
<seat-map api-base="https://api.seatpublic.com" event-id="ev_…"
api-key="pk_test_…" max-selectable="8" no-orphan
style="display:block; height:600px"></seat-map>
<script type="module">
const map = document.querySelector("seat-map");
map.addEventListener("seatSelect", e => console.log(e.detail.seat.id));
</script>Attributes
| Attribute | What it does |
|---|---|
api-base event-id api-key | Live mode: the event's chart, availability and prices from the API, then seat changes as they happen. Use the publishable key (pk_…). |
chart-url | A chart file to show, without an event (previews, venue pages). |
availability-url | With chart-url: which seats are taken. |
max-selectable | How many seats a buyer can pick. 0 = look only. |
no-orphan | Refuse picks that leave a single empty seat. |
hold-on-select hold-seconds | Hold each seat the moment it is picked; how long it stays held after the page closes. |
overlay | availability (default), category, rating or sellThrough. |
color-scheme | auto (default: the device's), light or dark. |
currency | ISO code for prices on the seat card, e.g. USD. |
price-colors="off" | Keep the chart's category colours instead of shading by price. |
view-3d | Start in the tilted view (venues with more than one level). |
orientation | auto, top or left: where the stage is. |
seat-list | The id of an element to fill with a list of the best seats, beside the map. |
The map object is on .map once loaded (and the live connection on .live), for the methods below.
Events
| Event | detail |
|---|---|
seatSelect | { seat, section }: a seat was picked. |
seatDeselect | { seat, section }: a seat was un-picked. |
seatTaken | { seat, section }: a picked seat was taken by someone else, so it was un-picked. The map says so too. |
ruleViolation | { code, seat, message }: a pick was refused. code is orphan, max, category or unavailable; the map shows message for a moment. |
holdCreated | The hold: { holdToken, expiresAt, until, seatIds }. The countdown runs to until while the page is open, or later if your server extended the hold. |
holdExpired | The hold that ran out. |
holdConfirmed | The hold that was sold: the countdown stops and the picks clear. |
holdError | A seat couldn't be held (hold as you pick). |
connection | { state }: the live connection's state. |
error | { message }: the map couldn't load. |
The SeatMap class
import { SeatMap } from "https://seatpublic.com/sdk/seatmap/v0/index.js";
const map = new SeatMap(document.getElementById("map"), { // the element needs a height
chart, // the venue chart
availability, // GET /v1/events/{id}/availability
pricing: { 1: 120, 2: 78 }, // this event's prices by category
maxSelectable: 8, rules: { noOrphanSeat: true }, currency: "USD",
onSelect: (seat, section) => {}, onDeselect: (seat, section) => {},
});
map.applyDelta([{ seatId: "orchestra-C-14", status: "held" }]);Options
| Option | Type | What it does |
|---|---|---|
chart required | Venue | The venue chart (JSON from the API or a chart file). |
availability | Availability | Which seats are sold, held or blocked for this event (GET /v1/events/{id}/availability). Without it every seat is available. |
pricing | Pricing | This event's prices by category id; shown on the seat card and passed to custom cards. |
priceColors | boolean | Colour categories by price when the event has two or more prices: cool for the cheapest, warm for the dearest (theme priceRamp), so buyers see where the deals are at a glance. Default on; host category colours still win. |
overlay | Overlay | What colours the seats: 'availability' (default), 'category', 'rating', 'sellThrough', or a function (seat, section, status) returning a colour. |
colorScheme | ColorScheme | 'auto' follows prefers-color-scheme. CSS custom properties (--sc-*) on the container override either palette. |
theme | Partial<Omit<SeatMapTheme, 'categoryOverride'>> | Colours and font in code (CSS custom properties on the container win over these). |
maxSelectable | number | How many seats a buyer can pick at once. 0 = look only (no picking). |
selectAny | boolean | Event managers: any seat can be selected whatever its status; category and orphan rules are skipped, and live changes never drop a seat from the selection. Buyers' maps leave this off. |
rules | { noOrphanSeat?: boolean; allowedCategories?: number[] } | What a buyer may pick: noOrphanSeat (never leave a single empty seat), allowedCategories. Checked here and again by the API. |
card | false | ((info: SeatInfo) => HTMLElement | string | null) | Seat card shown on hover/focus. Default: the buyer card (category, price, access, rating, photos, sell-through, tags). Return an element or an HTML string; return null to show nothing for that seat. false disables the card. |
currency | string | ISO 4217 code used to format prices on the default card. |
locale | string | BCP 47 locale for number/currency formatting. |
sectionFirst | boolean | 'auto' | Section-first navigation: when zoomed out, draw sections as shapes (their lowest price, or how many seats are left) and zoom in on click; seats fade in as you zoom. 'auto' turns it on for charts above 500 seats (3,000 with labels: 'detailed', where staff want seats sooner). |
filter | SeatFilter | What the buyer is looking for (the "2 tickets" and "Accessible" buttons): seats and sections that can't offer it are greyed. |
labels | 'auto' | 'detailed' | Row names (at both ends of each row) and seat numbers. 'auto' (default) shows them once zoomed in far enough to read; 'detailed' shows them from much further out, for editors and box-office staff. |
zoomControls | boolean | On-map zoom buttons (−, %, +, fit). Default true. |
decor | boolean | A livelier venue: a lit stage with footlights, warm light spilling into the room, and a soft tint of each section's category behind its seats. Default true; false draws a plain map. |
floor | number | Multi-level venues: the floor to show first, and whether to show the floor switcher (default true). By default every level shows at once (ALL_FLOORS): one plan from above with the upper levels around the lower ones ('top'; one level on its own keeps its place in that plan, so switching glides rather than jumps), or side by side ('side'); the switcher narrows to one. allLevels: false shows one level at a time (the editor, which edits real coordinates), starting with the chart's first. |
allLevels | boolean | 'top' | 'side' | Every level at once (true or 'top': one plan from above; 'side': side by side) or one at a time (false). |
view3d | boolean | Start in the tilted 3D view of all levels: each level raised on its slab, the room seen from the back at an angle. Buyers switch with the 3D button beside the zoom (shown for venues with more than one level). Default false. |
orientation | 'auto' | 'top' | 'left' | Where the stage is: 'auto' (default: whichever shows the venue bigger in the map's box, rechecked when the box changes shape), 'top', or 'left' (the hall running to the right, the way wide screens show a deep venue). A bird's-eye view either way; the tilted 3D view is stage-on-top only. Display only: seat ids and the chart don't change. |
floorSwitcher | boolean | The level tabs over the map on multi-level venues. Default true. |
filterBar | boolean | The buyer's filters as a row of chips over the map (quantity, price, seat types, accessible, level), shown when they mean something. Default true; false shows just the level tabs (the editor and the manager view). |
onFloorChange | (floorId: number) => void | The buyer switched level (or setFloor was called). |
onSelect | (seat: Seat, section: Section) => void | A seat was picked. |
onDeselect | (seat: Seat, section: Section) => void | A seat was un-picked (by the buyer, or because it sold or was held elsewhere). |
onHover | (seat: Seat | null, section: Section | null) => void | The pointer moved onto a seat, or off all seats (null). |
onRuleViolation | (code: RuleViolation, seat: Seat) => void | A pick was refused: 'unavailable', 'category', 'max' or 'orphan' (it would leave a single empty seat). |
onSeatTaken | (seat: Seat, section: Section) => void | A seat the buyer had picked was taken by someone else and unpicked (onDeselect fires too). The map says so on screen. |
onHoldCreated | (hold: HoldInfo) => void | A hold started (startHold, or hold as you pick). |
onHoldTick | (remainingMs: number) => void | Called every second while a hold is running. |
onHoldExpired | (hold: HoldInfo) => void | The hold ran out: its seats go back on sale. |
toasts | boolean | Short notes over the map for a moment: why a pick was refused ("That would leave a single empty seat…"), and a picked seat someone else just took. Default true. |
announce | boolean | Screen-reader announcements (picks, focus, zoom steps). Default true; see setAnnouncements() to pause them for a while. |
onViewChange | () => void | Called whenever the camera moves (pan, zoom, fit). |
ariaLabel | string | What screen readers hear for the canvas, in place of the buyer instructions (an editor's keys are different). |
insets | () => Partial<Insets> | Screen space the host covers with its own controls (a tool rail, a side panel, a bar along the bottom), in CSS pixels from each edge. Fitting and zooming to sections or seats centre the chart in what is left, and reveal() keeps things out from under them. Called each time, so it can follow panels that open and close. |
drawUnderlay | (ctx: CanvasRenderingContext2D) => void | Extra drawing under the stage and seats (used by the editor for a traced floor plan). Screen pixels; use map.toScreen(). |
drawExtras | (ctx: CanvasRenderingContext2D) => void | Extra drawing after seats (used by the editor). Coordinates are screen pixels; use map.toScreen(). |
onPointer | (phase: 'down' | 'move' | 'up' | 'cancel', e: PointerEvent, world: [number, number]) => boolean | First refusal on pointer input (used by the editor). world is the pointer in world units. Return true from 'down' to own the gesture: its 'move' and 'up' then come here and the map neither pans nor selects. Hover moves (no button) also come here first; return true to suppress the map's own hover. Wheel zoom always stays with the map. |
keyboard | boolean | Set false to let the host handle keys (the editor); the map then ignores arrows, Enter, +/-, 0 and Esc. |
Methods
| Method | What it does |
|---|---|
setChart(chart) getChart() | Show another chart, or read the current one. Pass new objects for whatever changed: sections it has seen before are reused as they are. |
setAvailability(a) applyDelta(changes) | All seat statuses at once, or a few changes ([{ seatId, status }]). |
setPricing(p) priceOf(seatId) | This event's prices by category; a seat's price. |
getCategories() | The ticket types with the colours the map uses, for your own price key. |
seatInfo(seatId) statusOf(seatId) | A seat's section, status, category and price; or just its status. |
select(id) deselect(id) setSelection(ids) | Pick seats from code (the rules apply). |
getSelection() clearSelection() | The picked seats; un-pick them all. |
setFilter(f) getFilter() showMatches() | What the buyer is looking for ({ quantity, accessible }): seats that can't offer it are greyed; zoom to the sections that can. |
offers() onOffersChange(fn) | The best seats that fit the filter, cheapest first; a callback when they may have changed. |
highlight(ids) zoomToSeats(ids) | Outline seats (null to clear); bring them into view. |
getFloors() getFloor() setFloor(id) | Levels of a multi-level venue. |
setView3d(on) setOrientation(o) setLabels(mode) | The tilted view; where the stage is; row names and seat numbers sooner (detailed). |
setOverlay(o) refresh() | What colours the seats; recolour after a custom overlay's inputs change. |
setColorScheme(s) refreshTheme() | Light, dark or auto; read the --sc-* colours again after changing them. |
fit() zoomToSection(id) zoomBy(f) reveal(box) | Move the view: the whole chart, one section, in or out, or just enough to show a box. |
getView() setView(v) toScreen(x, y) toWorld(x, y) | The camera, and converting between chart and screen positions. |
startHold(h) updateHold(h) endHold() holdRemainingMs() | Show a hold's countdown (after POST /v1/events/{id}/holds); updateHold moves its end. In live mode the map does this itself. |
setAnnouncements(on) | Pause what screen readers hear from the map, e.g. while your page plays a demo on it. |
destroy() | Remove the map and its listeners. |
Colours
Set any of these CSS custom properties on the map's container (they win over the theme option), then call refreshTheme() if you change them later.
| Property | Colours |
|---|---|
--sc-category-1 … --sc-category-20 | Each category (win over the chart's own colours). |
--sc-price-ramp | Price shading, cheapest first: #0d9488, #2563eb, #c2185b. |
--sc-sold --sc-held --sc-blocked --sc-blocked-hatch | Seats that can't be picked. |
--sc-accent --sc-focus | Picked seats; the keyboard focus ring. |
--sc-stage --sc-stage-text --sc-stage-glow --sc-table | The stage, its name, its light; tables. |
--sc-label --sc-label-bg --sc-row-text --sc-seat-text | Section names, row names and seat numbers. |
--sc-bg --sc-font | The background; the font for text on the map. |
--sc-card-bg --sc-card-fg --sc-card-line --sc-card-muted --sc-card-good --sc-card-bad | The seat card, level tabs, zoom buttons and filters. |
Box office screen
SeatManager is the staff screen: the map with every seat selectable, beside a panel with live counts. Staff see who holds or bought a seat, block and unblock seats (named, like "Press"), change categories for this event, and undo. Other staff's changes and buyers' holds show up as they happen.
import { SeatManager } from "https://seatpublic.com/sdk/seatmap/v0/index.js";
const manager = await SeatManager.connect(document.getElementById("manager"), {
apiBase: "https://api.seatpublic.com", eventId,
// your server makes the pass: POST /v1/events/{id}/manager-tokens with the secret key
token: () => fetch(`/admin/events/${eventId}/seat-token`).then(r => r.json()).then(r => r.token),
onSellRequest: ({ seats }) => openSale(seats), // you sell, then PATCH the seats sold with the order
onRefundRequest: ({ orders }) => openRefund(orders), // you refund, then call seats/release
});| Option | What it does |
|---|---|
apiBase eventId | The API and the event. |
token | A staff pass (mt_…), or a function that fetches one from your server. With a function the screen renews the pass before it runs out. |
permissions | What the pass allows (view, status, category), to hide the rest. The server checks either way. |
onSellRequest onRefundRequest | Sell or refund in your own system. Without them, those buttons aren't shown. A pass never sells or refunds. |
onConnection onError | The live connection's state; a message when something fails. |
The pass request and its answer: quickstart, box office screen.
Questions? Write to [email protected].