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

Reference / @getenginex/sdk-igaming / CasinoApi

CasinoApi ​

Catalog, game launch and casino history. The catalog (listGames, listCategories, listProviders, getGame) is public; the other methods require login.

Methods ​

getBiggestWinners() ​

getBiggestWinners(input?, options?): Promise<BiggestWinner[]>

Biggest prizes of a round in the operator's casino (home ranking), with the player's name masked. Requires login.

Parameters ​

input? ​

GetBiggestWinnersInput

options? ​

CallOptions

Returns ​

Promise<BiggestWinner[]>

Example ​

ts
const winners = await igaming.casino.getBiggestWinners({ limit: 10, days: 7 })

Throws ​

INTERNAL_ERROR (500) if a prize comes with an unknown currency; UNAUTHENTICATED without a session.


getGame() ​

getGame(input, options?): Promise<Game>

A catalog game. Public.

Parameters ​

input ​
gameId ​

string

options? ​

CallOptions

Returns ​

Promise<Game>

Example ​

ts
const game = await igaming.casino.getGame({ gameId: 'g-1' })

Throws ​

GAME_NOT_FOUND (404) if the id does not exist in the operator's catalog.


getHistory() ​

getHistory(input?, options?): Promise<Page<CasinoTransaction>>

The player's round history (bets, prizes, reversals), paginated.

Parameters ​

input? ​

CasinoPageInput

options? ​

CallOptions

Returns ​

Promise<Page<CasinoTransaction>>

Example ​

ts
const page = await igaming.casino.getHistory({ page: 1, perPage: 20 })
page.items.forEach((tx) => console.log(tx.roundId, tx.type, tx.amount, tx.currency))

Throws ​

INTERNAL_ERROR (500) if the history has a currency the gateway does not know; UNAUTHENTICATED without a session.


launchGame() ​

launchGame(input, options?): Promise<GameLaunch>

Opens a game: creates the game session (ending the previous one, if any) and returns the URL and how to open it (GameLaunch.launchTarget: in an iframe, by redirecting the tab, or in a new tab). Requires login, including in demo mode. It is not idempotent: each call opens a new session.

The returned URL carries the game session 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. Do not log it to logs, analytics or error tracking.

Parameters ​

input ​

LaunchGameInput

options? ​

CallOptions

Returns ​

Promise<GameLaunch>

Example ​

ts
const launch = await igaming.casino.launchGame({ gameId: game.id, isMobile: isPhone() })
// If gameUrl comes relative, resolve it against the gateway origin.
switch (launch.launchTarget) {
  case 'iframe':
    iframe.src = launch.gameUrl
    break
  case 'redirect':
    window.location.assign(launch.gameUrl)
    break
  default: {
    // 'new_tab', and any target the SDK does not know yet. Opened after an `await`, the tab may be
    // blocked as a popup (`window.open` returns null): fall back to the current tab.
    const tab = window.open(launch.gameUrl, '_blank')
    if (tab) tab.opener = null
    else window.location.assign(launch.gameUrl)
  }
}

Throws ​

GAME_NOT_FOUND (404) for a nonexistent game; FAILED_PRECONDITION (422) for an inactive game; SELF_EXCLUDED (422), COOLING_OFF or ACCOUNT_BLOCKED when responsible gaming blocks the player (outside demo mode); UNAVAILABLE (503) when the casino cannot verify the player's restrictions; PROVIDER_ERROR (503) and CASINO_UNAVAILABLE (codes defined in enginex-commons for provider/casino failures; treat them as unavailability); VALIDATION_ERROR if the response comes without sessionId or without gameUrl; INTERNAL_ERROR (502) when the provider gave no way to open the game; UNAUTHENTICATED without a session. COOLING_OFF, ACCOUNT_BLOCKED and CASINO_UNAVAILABLE arrive with HTTP 500 (the gateway does not map them yet): identify by the code, not by the status.


listCategories() ​

listCategories(params?, options?): Promise<GameCategory[]>

Categories with active games, to build lobby tabs/filters. Public.

Parameters ​

params? ​

NoParams

options? ​

CallOptions

Returns ​

Promise<GameCategory[]>

Example ​

ts
const categories = await igaming.casino.listCategories()
categories.sort((a, b) => a.priority - b.priority)

Throws ​

UNAVAILABLE/PROVIDER_ERROR (503) when the call to the casino service fails.


listGames() ​

listGames(input?, options?): Promise<Page<Game>>

Games of the operator's catalog, paginated and filterable. Public: it does not send the session, even with login (the catalog does not depend on the player).

Maintenance, a provider switch, temporary unavailability or an operator without a casino do not become errors: the gateway answers 200 and reports the reason in an availability field next to the list, which this SDK version does not expose yet. In those cases the list may come empty, without an error; show a generic empty state.

Parameters ​

input? ​

ListGamesInput

options? ​

CallOptions

Returns ​

Promise<Page<Game>>

Example ​

ts
const page = await igaming.casino.listGames({ category: 'slots', sort: 'popular', perPage: 24 })
page.items.forEach((game) => renderCard(game.name, game.thumbnail))

Throws ​

INVALID_ARGUMENT (400) for search above 100 characters or more than 100 ids; UNAVAILABLE/PROVIDER_ERROR (503) only when the call to the casino service itself fails.


listProviders() ​

listProviders(params?, options?): Promise<GameProvider[]>

Providers with active games. Public.

Parameters ​

params? ​

NoParams

options? ​

CallOptions

Returns ​

Promise<GameProvider[]>

Example ​

ts
const providers = await igaming.casino.listProviders()

Throws ​

UNAVAILABLE/PROVIDER_ERROR (503) when the call to the casino service fails.


listSessions() ​

listSessions(input?, options?): Promise<Page<GameSession>>

The player's game sessions, from newest to oldest, paginated.

Parameters ​

input? ​

CasinoPageInput

options? ​

CallOptions

Returns ​

Promise<Page<GameSession>>

Example ​

ts
const { items } = await igaming.casino.listSessions({ perPage: 10 })
const active = items.find((s) => s.status === 'active')

Throws ​

UNAUTHENTICATED without a session.