Web component
The recommended integration. Your registered domain is your identity: the widget resolves the operator, the template, the language and the endpoints from it. Four steps, and everything else is back-office configuration.
1 — Send us
| Domain | The host your players play on. Exact match, with one derivation: a registered casino.example.com also answers www.casino.example.com, and the other way round. |
| Any other host | Every other host the widget runs on — a second brand, your staging site — is registered as a page of its own, with its own domain. Our API answers a browser only from a registered page's domain, so an unregistered host fails CORS. |
| Wallet base URL | One HTTPS address, any host. We compose {base}/balance, {base}/transaction and {base}/profile from it — see Reference. A trailing slash is trimmed before we append a path; a base carrying a query string or a fragment is refused. |
| Service key | A long-lived secret you issue. Rotate it whenever you like and tell us. Write-only on our side. It also keys the signature on every call we make, so it must be the same bytes on both sides. |
We answer with your tenant UUID. It is an identifier, not a secret — it is visible in page source wherever it is used. Your production page will not need it; keep it for staging and for the iframe path. The only secret in this contract is the service key you issued to us.
2 — Paste
<script type="module" src="https://cdn.example.com/sportsbook-widget.js"></script>
<sportsbook-widget auth-token="<the player's session token>"></sportsbook-widget>
-
auth-token— the token your own site already issued to that player. Set it on sign-in, remove it on sign-out. The bare token orBearer <token>, as your site holds it — we strip the scheme. The sportsbook needs a player: with no token we send the page back to/— see When there is no session for the event that says so and how to keep an anonymous page instead. -
Do not pin an
integrityhash. The bundle is evergreen. -
Off the registered domain — staging,
localhost— addtenant-id="<your UUID>": those hosts are not registered, so the domain says nothing. Send us that host too, or the browser is refused before the UUID is read. On the registered domain itself the attribute is never needed, and one that names no page (an id from before the page was re-registered, say) is set aside for the domain's own page rather than refused — so a stale value cannot take your sportsbook down, though it should still be corrected. -
bottom-inset— only if your page keeps a fixed bar at the bottom of the screen, such as a mobile navigation with Home / Search / Deposit / Profile. Give it the bar's height in pixels (bottom-inset="72") and the widget stops underneath it instead of running behind it.It has to be declared because it cannot be measured: your bar lives on your document, outside our shadow root, and the container you give the widget genuinely does reach the bottom of the screen — the bar simply paints over it. Without this, the last of the page goes under the bar, and on a phone that is where the bet slip keeps its stake box and its Apostar button.
It defaults to
0, so an embed that keeps nothing at the bottom needs nothing here, and a value we cannot read as a length is treated as0rather than breaking the layout. -
locale— only if your site has its own language switch. Give it the language your page is in —es,enorpt, with or without a region (locale="es-MX") — and update it when the player switches. The widget reads in that language and draws no language picker of its own. A language we do not ship reads in English. Without the attribute the widget opens in your page's default language and offers its own picker.
Those are the attributes. Everything else the widget needs it
resolves itself: it asks cdn.example.com for the API origin,
and your page's configuration in the back-office for the rest.
You do not have to give the widget a height. It measures how much of the screen is
left below wherever you placed it — under your own header, and above the bar you
declared with bottom-inset — and takes exactly that, at every width. The
sportsbook then scrolls inside the element, so a list that reads more as the
player scrolls does not make your page taller. It measures again when the window
resizes and when anything scrolls, so a header that collapses as the player scrolls
down is followed rather than fought.
3 — Allow, if you run a CSP
script-src https://cdn.example.com;
style-src https://cdn.example.com;
connect-src https://cdn.example.com https://api.example.com wss://api.example.com;
Without wss: odds never update. style-src and the {cdn} origin in
connect-src are for the widget's own stylesheet and deployment config.
4 — Answer the three addresses your base composes to
| Player profile | GET{base}/profile. Who the player is. |
| Balance | GET{base}/balance. What they have. |
| Debit · Credit · Rollback · Prize | POST{base}/transaction, one URL. type tells them apart. |
That is the whole server-side contract. Which Bearer arrives on what is in Player sessions; error symptoms are in the Reference.
Events
All bubble and cross the shadow boundary — one listener on a container catches them all.
| Event | detail |
|---|---|
sportsbook-ready | { element } |
sportsbook-error | { message, code } |
sportsbook-session-expired | { reason, redirectUrl } |
sportsbook-bet-added | { bet } |
sportsbook-bet-removed | { betId } |
sportsbook-slip-cleared | {} |
sportsbook-view-change | { view } |
sportsbook-league-selected | { sportId, leagueId } |
When there is no session
The sportsbook is for a player, so the widget never sits in a page without one.
It dispatches sportsbook-session-expired and, unless you say otherwise,
sends the page to / — your own root, because we cannot sign a player in
and you can. A page already at / is left alone rather than reloaded.
detail.reason says which of the two happened:
reason | |
|---|---|
missing | No token arrived. You never set auth-token, or you removed it — which is the sign-out we document. We allow ~1.5s from load, so setting the attribute from your own script (or posting it into the iframe) is in time. |
expired | We asked and your {base}/profile refused the token: expired, signed out in another tab, revoked. The widget also drops it — no balance, no bet slip, no request carrying it. |
detail.redirectUrl is where it is about to go, or null when it will go
nowhere. To take over — open your login modal, mint a fresh token, or keep an
anonymous page showing odds only — cancel the default:
widget.addEventListener('sportsbook-session-expired', (e) => {
e.preventDefault(); // we stay put; the page is yours
showLogin(); // and when you have a new token:
widget.setAttribute('auth-token', token);
});
Setting auth-token to a different value re-arms the widget: the player is
signed in again with no reload. Setting the same refused token changes nothing.
Cancel the default and the widget stays as it is — the full catalog, no balance
and no slip — which is how you run a page for visitors who are not signed in.