---
url: >-
  https://game-engine-io.github.io/enginex-frontend-sdk/reference/api/@getenginex/sdk-igaming/interfaces/CasinoApi.md
---
[Reference](../../../index.md) / [@getenginex/sdk-igaming](../index.md) / 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`](BiggestWinner.md)\[]>

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

#### Parameters

##### input?

[`GetBiggestWinnersInput`](GetBiggestWinnersInput.md)

##### options?

[`CallOptions`](../../sdk/interfaces/CallOptions.md)

#### Returns

`Promise`<[`BiggestWinner`](BiggestWinner.md)\[]>

#### 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`](Game.md)>

A catalog game. Public.

#### Parameters

##### input

###### gameId

`string`

##### options?

[`CallOptions`](../../sdk/interfaces/CallOptions.md)

#### Returns

`Promise`<[`Game`](Game.md)>

#### 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`](../../sdk/interfaces/Page.md)<[`CasinoTransaction`](CasinoTransaction.md)>>

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

#### Parameters

##### input?

[`CasinoPageInput`](CasinoPageInput.md)

##### options?

[`CallOptions`](../../sdk/interfaces/CallOptions.md)

#### Returns

`Promise`<[`Page`](../../sdk/interfaces/Page.md)<[`CasinoTransaction`](CasinoTransaction.md)>>

#### 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`](GameLaunch.md)>

Opens a game: creates the game session (ending the previous one, if any) and returns the URL and how to
open it ([GameLaunch.launchTarget](GameLaunch.md#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`](LaunchGameInput.md)

##### options?

[`CallOptions`](../../sdk/interfaces/CallOptions.md)

#### Returns

`Promise`<[`GameLaunch`](GameLaunch.md)>

#### 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`](GameCategory.md)\[]>

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

#### Parameters

##### params?

[`NoParams`](../../sdk/type-aliases/NoParams.md)

##### options?

[`CallOptions`](../../sdk/interfaces/CallOptions.md)

#### Returns

`Promise`<[`GameCategory`](GameCategory.md)\[]>

#### 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`](../../sdk/interfaces/Page.md)<[`Game`](Game.md)>>

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`](ListGamesInput.md)

##### options?

[`CallOptions`](../../sdk/interfaces/CallOptions.md)

#### Returns

`Promise`<[`Page`](../../sdk/interfaces/Page.md)<[`Game`](Game.md)>>

#### 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`](GameProvider.md)\[]>

Providers with active games. Public.

#### Parameters

##### params?

[`NoParams`](../../sdk/type-aliases/NoParams.md)

##### options?

[`CallOptions`](../../sdk/interfaces/CallOptions.md)

#### Returns

`Promise`<[`GameProvider`](GameProvider.md)\[]>

#### 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`](../../sdk/interfaces/Page.md)<[`GameSession`](GameSession.md)>>

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

#### Parameters

##### input?

[`CasinoPageInput`](CasinoPageInput.md)

##### options?

[`CallOptions`](../../sdk/interfaces/CallOptions.md)

#### Returns

`Promise`<[`Page`](../../sdk/interfaces/Page.md)<[`GameSession`](GameSession.md)>>

#### Example

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

#### Throws

`UNAUTHENTICATED` without a session.
