This version (v0.7) has not been published to npm yet.
Skip to content

Reference / @getenginex/sdk-igaming / SportsbookApi

SportsbookApi ​

FIRST sportsbook (GET /first/session). The provider and the configuration come from the core's enginex.config.getSportsbook().

Methods ​

createSession() ​

createSession(params?, options?): Promise<SportsbookSession>

Creates the FIRST session for the logged-in player: returns the sportsbook URL (with the operator token) to load in an iframe. Requires login. There is no cache in the SDK: each call generates a new token; reuse the session until expiresAt - 30_000 and call enginex.config.getSportsbook() first to confirm enabled && provider === 'first'.

The returned URL carries the operator token. The SDK delivers it only in the return value: no hook (onRequest/onResponse/onError) nor onValidationIssue receives it, and the response is always validated in strict mode. The separate token (operator_token) is never exposed. Do not log the URL to logs, analytics or error tracking.

Parameters ​

params? ​

NoParams

options? ​

CallOptions

Returns ​

Promise<SportsbookSession>

Example ​

ts
const sb = await enginex.config.getSportsbook()
if (sb.enabled && sb.provider === 'first') {
  const { launchUrl, expiresAt } = await igaming.sportsbook.createSession()
  iframe.src = launchUrl
}

Throws ​

UNAUTHENTICATED without a session; the gateway envelope's code when FIRST is not enabled for the operator (HTTP 400) and UNAVAILABLE (503) when the FIRST configuration is incomplete, the session service is down or the bets service's sportsbook configuration is not available; VALIDATION_ERROR if launch_url is not an absolute http(s) URL or expires_in_seconds is not greater than zero.