Embedding
The sportsbook runs in an iframe on your page. The embed SDK creates the iframe, passes the launch token, sizes it, checks the origin of every message and gives you callbacks for what happens inside. It has no dependencies and weighs about 5 KB.
With the SDK
Section titled “With the SDK”<div id="sportsbook"></div><script src="https://api.orbisportbook.com/embed/v1.js"></script><script> const sb = OrbiSportbook.mount('#sportsbook', { url: 'https://api.orbisportbook.com', tenant: 'your-tenant', launchToken: '<launch token from your server>', // omit for anonymous browsing height: matchMedia('(max-width: 899px)').matches ? 'fill' : 'auto', onLoginRequired: () => openYourLogin(), onDepositRequested: () => openYourCashier(), onBalanceChanged: ({ balance, currency }) => updateYourHeader(balance, currency), onSessionExpired: () => fetchLaunchTokenFromYourServer(), // a string, a promise of one, or null });</script>/embed/v1.js is the SDK for protocol version 1. It receives compatible fixes
under the same URL and is served with Cache-Control: public, max-age=3600, stale-while-revalidate=86400 and Access-Control-Allow-Origin: *. Do not add
an integrity attribute: the next compatible update would break it.
npm install @bookmaker/embed-sdkimport { mount, type SportsbookInstance } from '@bookmaker/embed-sdk';// the protocol types and helpers on their own:import type { SportsbookEvents, HostCommands } from '@bookmaker/embed-sdk/protocol';
const sb: SportsbookInstance = mount(document.getElementById('sportsbook')!, { url: 'https://api.orbisportbook.com', tenant: 'your-tenant', launchToken, onBetPlaced: ({ betId, stake, currency }) => analytics.track('bet', { betId, stake, currency }),});ES module with type declarations, zero runtime dependencies.
Options
Section titled “Options”| Option | Type | |
|---|---|---|
url |
string | Sportsbook base URL. Its origin is the only one the SDK talks to. Required. |
tenant |
string | Your tenant id. Required. |
launchToken |
string | From your server (Player sessions). Omit it and players browse anonymously. |
path |
string | First route, see deep links. |
selections |
string[] | Outcome ids to put on the slip when the sportsbook opens (at most 10), e.g. the price a player clicked in a widget. |
readOpenParams |
boolean | Without path and selections, open the ob_path and ob_select of your page’s URL, where a widget click lands. Default true. |
locale |
'en' | 'pt-BR' | 'es' |
Language; default the tenant’s. See locale. |
currency |
string | Currency shown before login, e.g. 'EUR'; put in the launch URL. After login the session’s currency applies. Default the tenant’s. |
displayCurrency |
{ code, rate } |
Show amounts converted into another currency, e.g. { code: 'BRL', rate: 5.4231 } (units of code per 1 unit of the session currency). Presentation only; sent with set_display_currency once the sportsbook is ready, never put in the URL. See display currency. |
overrides |
object | Presentation overrides for this iframe over the brand’s back-office configuration: theme, colorScheme and visual content sections. Sent with set_overrides once ready, never put in the URL. Catalog curation, languages and the display policy are refused here (the SDK throws): pass them from your server. See launch overrides. |
height |
'auto' | 'fill' |
Sizing mode. Default 'fill'. |
minHeight |
number | auto mode: height in px until the first resize event. Default 600. |
scrollOffset |
number | false |
auto mode: when the player opens another sportsbook page while the top of the iframe is scrolled out of view, the SDK scrolls your page back to it, leaving this many pixels for your sticky header. Default 0; false turns it off. |
shareParam |
string | false |
The query parameter of your page that carries a shared bet code. Without path, mount() opens /share/{code} when your page URL has it. Default ob_share; false turns it off. |
title |
string | Accessible name of the iframe. Default Sportsbook. |
bottomInset |
number | 'auto' |
Height in px (0 to 200) of your page’s fixed bottom bar when it is drawn over the iframe. On phones the sportsbook lifts its bottom navigation and bet slip above it. 'auto': the SDK measures your bar itself and keeps the sportsbook told as it changes (how). A number wins: nothing is measured then. Default 0. Prefer ending the iframe above your bar; see the iframe on a phone. |
bottomInsetIgnore |
string | With bottomInset: 'auto': a CSS selector of fixed elements that are not your bar, e.g. '.cookie-banner, #chat-button'. An invalid selector is ignored. |
onReady, onLoginRequired, onDepositRequested, onBalanceChanged, onBetPlaced, onBetSettled, onRouteChange, onResize, onError |
function | One callback per event, called with its payload. |
onSessionExpired |
function | Return a fresh launch token (or a promise of one) and the SDK sends set_launch_token; return null to leave the player logged out. One call at a time. |
onEvent |
function | (type, payload) for every event, after the specific callback. |
A callback that throws is reported with console.error and does not stop the
others.
The instance
Section titled “The instance”| Member | |
|---|---|
setLaunchToken(token) |
Log a player in, or replace an expired session, without reloading the iframe. |
navigate(path) |
Go to a deep link. |
setLocale(locale) |
en, pt-BR or es. |
refreshBalance() |
Re-read the balance from your wallet, e.g. after a deposit in your cashier. The iframe answers with balance_changed. |
logout() |
End the sportsbook session (call it when the player logs out of your site). |
setDisplayCurrency({ code, rate }) |
Show amounts converted into code at rate, or update the rate (call it again). setDisplayCurrency(null) goes back to the session currency. Presentation only. See display currency. |
setOverrides(overrides) |
Replace your page’s overrides; setOverrides(null) clears them (the launch’s stay). An invalid value changes nothing and is reported with an invalid_override error event. |
on(type, handler) |
Subscribe to one event type; returns an unsubscribe function. |
ready |
Promise of the ready payload. |
iframe, origin |
The iframe element and the sportsbook origin. |
destroy() |
Remove the iframe and every listener. |
Commands sent before the sportsbook is ready are queued and sent after ready.
There is no command to change the currency: see currency.
setDisplayCurrency() only changes how amounts are shown.
Without the SDK
Section titled “Without the SDK”Any page can frame the sportsbook and speak the postMessage
protocol directly. Use the launchUrl returned by
integration/sessions, or build the URL yourself:
https://api.orbisportbook.com/?tenant=<tenant>&launch=<launchToken>&path=/live&locale=pt-BR¤cy=USD&height=fill&origin=https%3A%2F%2Fwww.your-site.example| Parameter | |
|---|---|
tenant |
Required. Also tells the server which frame-ancestors to send. |
launch |
The single-use launch token. Removed from the iframe’s address at once. |
path |
First route (deep links). An invalid path is ignored and reported with an error event. |
select |
Outcome ids to put on the slip at start-up, comma separated (at most 10), e.g. a widget click’s ob_select. Suspended or closed ones are skipped. |
coupons |
A shared bet’s booking code (K7M3Q9XT; any case, spaces or a dash): without a valid path, opens /share/<code>. Useful when your page can only pass one query parameter of its own address on to the iframe. Alias ob_share; coupons wins when both are present. A value that is not a code is ignored, with no error. |
locale |
en, pt-BR or es, as a BCP 47 tag in any case (pt-br is pt-BR, es-MX is es). See locale. |
lang |
Alias of locale; locale wins when both are present. |
currency |
Currency to show before login. A display hint; the session’s currency is authoritative. |
height |
auto or fill (default). In auto the page must not depend on the viewport height, so tell the sportsbook. |
origin |
Your page’s origin. Browsers without location.ancestorOrigins (Firefox) use it, or the Referer, to know who the parent is. It is checked against your allowed origins like any other. |
bottomInset |
Whole px, 0 to 200, of your fixed bar covering the bottom of the iframe (any other value counts as 0). See the iframe on a phone. |
token |
Deprecated: the session token itself in the URL. Still accepted for existing integrations; use launch. |
tenant, height, origin, locale, lang, currency and bottomInset are sticky: they
stay in the iframe’s address across in-app navigation, so a reload keeps them.
launch, token, path, select, coupons and ob_share are consumed at start-up and removed.
The allow="clipboard-write; web-share" attribute lets the ticket’s Share button open the
player’s own share sheet (WhatsApp, Telegram, Instagram…) and copy links from inside the frame.
Without web-share the button falls back to copying the link. The embed SDK sets it for you.
<iframe id="sb" title="Sportsbook" allow="clipboard-write; web-share" style="width: 100%; height: 100%; border: 0" src="https://api.orbisportbook.com/?tenant=your-tenant&launch=lt_…&origin=https%3A%2F%2Fwww.your-site.example"></iframe><script> const SB = 'https://api.orbisportbook.com'; const frame = document.getElementById('sb');
window.addEventListener('message', (e) => { // only our iframe, only the sportsbook origin, only protocol v1 if (e.source !== frame.contentWindow || e.origin !== SB) return; const m = e.data; if (!m || m.source !== 'bookmaker-sportsbook' || m.v !== 1) return; if (m.type === 'login_required') openYourLogin(); if (m.type === 'balance_changed') updateYourHeader(m.payload.balance, m.payload.currency); });
function send(type, payload = {}) { // always the exact sportsbook origin, never '*' frame.contentWindow.postMessage({ source: 'bookmaker-host', v: 1, type, payload }, SB); } // e.g. after your login: send('set_launch_token', { launchToken });</script>Sizing modes
Section titled “Sizing modes”auto |
fill |
|
|---|---|---|
| Height | The iframe grows to its content: the SDK sets it from every resize event. |
The iframe fills its container (height: 100%); give the container a height. |
| Scrolling | Your page scrolls; the iframe has no scrollbar. | The sportsbook scrolls inside the iframe. |
| Best for | Desktop pages with your header and footer around the sportsbook. | Phones and app-like layouts. |
| Sticky parts | The sportsbook header and bet slip scroll away with the page. | Header, bet slip and bottom navigation stay in view. |
/* fill: the sportsbook takes the screen below your header */#sportsbook { height: calc(100dvh - var(--your-header-height)); }Mobile
Section titled “Mobile”On screens narrower than 900 px the sportsbook switches to its mobile layout:
a bottom navigation bar and a bottom-sheet bet slip, both fixed to the
bottom of the iframe’s viewport. In auto mode that viewport is as tall as
the whole sportsbook. Use fill on phones, sized with dvh so the
browser’s toolbars are accounted for. The reference operator chooses per
device:
height: matchMedia('(max-width: 899px)').matches ? 'fill' : 'auto',The iframe on a phone
Section titled “The iframe on a phone”The sportsbook adapts to the part of the iframe that is on screen: when the iframe is taller than the screen, or runs below it, the bottom navigation and the bet slip with its “Place bet” button move up into the visible part.
It cannot see your own fixed elements. A fixed bottom bar of your page drawn over the iframe hides what is under it. Two ways out, the first preferred:
-
End the iframe above your bar. Give the container the screen’s height minus your header and your bar:
/* header 64 px, fixed bottom bar 56 px */#sportsbook { height: calc(100dvh - 64px - 56px); } -
If your bar has to cover the iframe, let the SDK measure it with
bottomInset: 'auto', or pass its height as a number (mount({ ..., bottomInset: 56 }), or&bottomInset=56in the iframe URL). The sportsbook keeps that many pixels at the bottom clear on phones.
The number has to be measured in each real environment: the same bar can be
64 px in a phone’s browser and about 96 px in your app’s webview, with the
device’s safe area (the bar’s getBoundingClientRect().height, padding
included). 'auto' does that measure for you, everywhere.
To measure by hand, open your page on a phone (or the browser’s device mode) and run in the console of your page:
const f = document.querySelector('#sportsbook iframe').getBoundingClientRect();const bar = document.querySelector('#your-bottom-bar').getBoundingClientRect();console.log({ iframeBottom: f.bottom, screen: innerHeight, barTop: bar.top, overlap: Math.max(0, f.bottom - bar.top) });overlap must be 0 (option 1) or equal to bottomInset (option 2).
An iframe taller than the screen under a fixed header of yours (height: 100vh below it) is the setup to avoid: the sportsbook measures only the part of the frame that is on screen, so anything of yours fixed over it still covers it. Opening the bet slip does not scroll your page. Prefer fill, or bottomInset.
bottomInset: ‘auto’
Section titled “bottomInset: ‘auto’”OrbiSportbook.mount('#sportsbook', { url: 'https://sportsbook.example.com', tenant: 'your-tenant', launchToken, bottomInset: 'auto', bottomInsetIgnore: '.cookie-banner', // optional});The iframe opens with 0. Once the sportsbook is ready, the SDK (on your page)
looks at three points of the iframe’s visible bottom edge (left, middle and
right) with document.elementsFromPoint, and takes the first element above
the iframe that is position: fixed or sticky (itself or an ancestor), ends
at the iframe’s bottom, is at most 200 px tall and covers less than 30% of
the iframe. The value is how much of the iframe it covers (the largest of the
three points, whole px, 0 to 200), sent with the
set_bottom_inset command. It is measured
again on resize, rotation, scroll (a bar that hides when the page scrolls),
the end of a CSS transition, visualViewport changes and changes to your
page, at most once per frame; moves of 2 px or less wait until the page is
quiet. destroy() stops it.
Caveats:
- Anything fixed at the bottom counts while it shows: a cookie banner, a
chat button, a floating “Deposit” button. Leave them out with
bottomInsetIgnore('.cookie-banner'), or pass the number. - A bar drawn with a
transform, inside another iframe, or in asandboxed frame may not be seen: pass the number. - The ceiling is 200 px, as for the number.
- A number wins over
'auto': with a number nothing is measured. - An older sportsbook (without
set_bottom_insetin itsreadyevent’sfeatures) gets nothing; nothing breaks, and the inset stays 0. - To check what the SDK sees, run
OrbiSportbook.measureBottomInset(document.querySelector('#sportsbook iframe'))in your page’s console (the script-tag build), or importmeasureBottomInsetfrom the package.
Deep links
Section titled “Deep links”| Path | Opens |
|---|---|
/ |
Home: live now and featured coupons |
/live, /live/{sportId} |
In-play, all sports or one (football, basketball, tennis; see sport ids) |
/sport/{sportId} |
A sport’s competitions and events |
/competition/{competitionId} |
One competition, e.g. /competition/br-serie-a |
/event/{eventId} |
An event with all its markets |
/my-bets |
The player’s open and settled bets (anonymous players: login_required) |
/share/{code} |
A shared bet, ready to add to the slip. The SDK opens it by itself when your page URL has ?ob_share={code} |
Open one at launch with path, later with navigate(path). The iframe reports
every navigation with a route event ({path, title}); mirror it in your own
URL to make sportsbook pages shareable, and pass it back as path on the next
load:
onRouteChange: ({ path, title }) => { const url = new URL(location.href); url.searchParams.set('sb', path); history.replaceState(null, '', url); document.title = `${title} · Your Casino`;},path: new URLSearchParams(location.search).get('sb') ?? undefined,Locale
Section titled “Locale”en, pt-BR and es ship today. Pass locale at mount (or locale / lang
in a raw iframe URL), or switch at any time with setLocale(); the
sportsbook re-renders in place and keeps the route and the bet slip. Without
either, it uses the tenant’s default locale.
Locales are BCP 47 tags, matched case-insensitively and falling back to the
base language: pt-br and pt are pt-BR, es-MX is es, en-GB is en.
Anything else is ignored and reported with an error event
(unsupported_locale).
Currency
Section titled “Currency”A session holds one wallet currency for its whole lifetime (see
session currency). The currency option
and URL parameter only decide what the sportsbook shows before that:
| Situation | What the sportsbook shows |
|---|---|
Anonymous visitor, currency enabled for the tenant |
Amounts and limits in that currency. |
Anonymous visitor, currency not enabled (or unknown) |
The tenant’s default currency, and an error event with code: "unsupported_currency". |
| After the launch token is exchanged | The session’s currency. If the URL asked for another one, an error event with code: "currency_mismatch" is sent; the session’s currency still applies. |
The SDK puts currency into the launch URL. The launchUrl returned by
integration/sessions already carries the
session’s currency, so the two always agree when you use it.
Switching currency
Section titled “Switching currency”There is no set_currency command. A session is one wallet currency:
switching in the middle of a session would mix balances, open bets and
cash-outs of two wallets, and responsible gambling totals with them. To let
the player change currency, create a new session for it and remount:
async function switchCurrency(currency) { // your endpoint: POST /api/v1/integration/sessions with { externalPlayerId, currency } const res = await fetch('/my-site/sportsbook-launch', { method: 'POST', body: JSON.stringify({ currency }) }); const { launchToken } = await res.json(); sb.destroy(); sb = OrbiSportbook.mount('#sportsbook', { url, tenant, launchToken, currency });}Open bets keep their own currency and settle into the wallet they were placed from.
Display currency
Section titled “Display currency”To show a player amounts in another currency than their wallet’s (a USD wallet
shown in reais, for example), keep the session currency and give the
sportsbook a display currency: a registry code and a rate, the units
of code per 1 unit of the session currency.
const sb = OrbiSportbook.mount('#sportsbook', { url, tenant, launchToken, // a USD session displayCurrency: { code: 'BRL', rate: 5.4231 }, // shown in reais});
// later: a new rate, another display currency, or back to USDsb.setDisplayCurrency({ code: 'BRL', rate: 5.4310 });sb.setDisplayCurrency(null);You can also pass it server side, as displayCurrency when you
create the session; it then reaches the
iframe with the launch token. The sportsbook shows the balance, stakes,
potential returns, limits, cash-out amounts and bet history converted, marked
as approximate (≈ R$ 10,03), and keeps the exact session-currency amount
visible: the slip’s Debit line, under the balance, on receipts. A stake
typed in the display currency is converted up to the session currency.
Nothing else changes: bets, wallet calls, balance_changed, bet_placed and
bet_settled stay in the session currency.
An unknown code or an invalid rate shows the session currency and sends an
error event with code: "unsupported_display_currency". A rate belongs to
the currency it was set for: if the session currency changes (a launch token
in another currency), the display currency is dropped with the same error;
send it again for the new currency. See Currencies
for the rules and the arithmetic.
Allowed origins
Section titled “Allowed origins”Any site may frame an operator integration’s sportsbook (seamless wallet): the
API sends Content-Security-Policy: frame-ancestors * with every sportsbook
page of your tenant, GET /api/v1/config reports tenant.embedAnyOrigin: true,
and the iframe talks to whichever page framed it. Events still go to that
page’s origin only, never to '*'.
embedOrigins (exact origins: scheme, host and port, no path, no
wildcards) no longer restricts framing. It is still returned as
tenant.embedOrigins and passed to Predictions as the ancestors of its frame.
Set them in the back office under Configurações → Integração, or with the API (staff token):
PUT /api/v1/admin/tenantAuthorization: Bearer <staff token>Content-Type: application/json
{"embedOrigins": ["https://www.your-casino.example", "https://m.your-casino.example"]}Your page’s own CSP
Section titled “Your page’s own CSP”If your site sends a Content Security Policy, allow the sportsbook origin for the script and the frame:
script-src 'self' https://api.orbisportbook.com; frame-src https://api.orbisportbook.comWhat changes in embed mode
Section titled “What changes in embed mode”| In the sportsbook | When embedded |
|---|---|
| Registration, login, CPF validation, KYC, account, deposits, withdrawals | Managed by your platform; no onboarding or cashier flow is supplied by the iframe. |
| Header balance | Your wallet balance, labelled as such. |
| Deposit button | Sends deposit_requested; open your cashier. |
| Log in button, Log in to bet, My Bets when anonymous | Send login_required with a reason; open your login. |
| Session ends | session_expired; no dialog inside the iframe. |