SlottyClient Reference
The SlottyClient class is the main entry point for the Slotty Labs SDK. It provides access to all API modules.
Constructor
import { SlottyClient } from '@slottylabs/sdk';
const client = new SlottyClient(config: SlottyClientConfig);SlottyClientConfig
interface SlottyClientConfig {
/** API key (sk_sandbox_* or sk_live_*) */
apiKey: string;
/** Webhook secret for signature verification (optional) */
webhookSecret?: string;
/** API base URL (optional, auto-detected from key prefix) */
baseUrl?: string;
/** Request timeout in milliseconds (default: 10000) */
timeout?: number;
/** Custom fetch implementation (optional, for testing) */
fetch?: typeof fetch;
}Auto-detected Base URL
If baseUrl is not provided, it is automatically detected from the API key prefix:
sk_sandbox_*→https://sandbox-api.slottylabs.comsk_live_*→https://api.slottylabs.com
client.auth
Authentication and SSO token management.
createSSOToken()
Creates a single-use SSO launch token for a player.
const result = await client.auth.createSSOToken(request: CreateSSOTokenRequest): Promise<CreateSSOTokenResponse>;CreateSSOTokenRequest
interface CreateSSOTokenRequest {
/** Operator's external player ID */
playerId: string;
/** Player currency code (e.g. "USD", "EUR", "BTC") */
currency: string;
/** Jurisdiction code (e.g. "CW", "MT", "GI") */
jurisdiction: string;
/** Locale code (e.g. "en", "de", "es") */
locale: string;
/** Target game ID (optional, for direct launch) */
gameId?: string;
/** Display username (optional) */
username?: string;
/** Enable demo mode (optional, default: false) */
demoMode?: boolean;
}CreateSSOTokenResponse
interface CreateSSOTokenResponse {
/** Single-use JWT launch token (30s TTL) */
launchToken: string;
/** Token expiry timestamp (ISO 8601) */
expiresAt: string;
}Example
const { launchToken, expiresAt } = await client.auth.createSSOToken({
playerId: 'player-123',
currency: 'USD',
jurisdiction: 'CW',
locale: 'en',
gameId: 'slotty-slots',
username: 'Player123',
});
console.log(`Token expires at: ${expiresAt}`);
// Use launchToken in a game launch URL within 30 secondsclient.games
Game catalog and launch URL management.
getLaunchUrl()
Generates a game launch URL with the given token and options.
const url = client.games.getLaunchUrl(
gameId: string,
launchToken: string,
options?: LaunchUrlOptions,
): string;LaunchUrlOptions
interface LaunchUrlOptions {
/** Locale code (default: "en") */
lang?: string;
/** Lobby URL to redirect on exit */
lobby?: string;
/** Enable demo mode */
demo?: boolean;
/** Channel: "desktop" or "mobile" */
channel?: 'desktop' | 'mobile';
}Example
const launchUrl = client.games.getLaunchUrl('slotty-slots', launchToken, {
lang: 'en',
lobby: 'https://yourcasino.com/lobby',
channel: 'desktop',
});
// Returns: https://games.slottylabs.com/launch/slotty-slots?token=eyJ...&lang=en&lobby=...&channel=desktoplist()
Returns the full game catalog available to your tenant.
const games = await client.games.list(): Promise<GameListResponse>;GameListResponse
interface GameListResponse {
games: GameSummary[];
total: number;
}
interface GameSummary {
id: string;
name: string;
type: 'single_step' | 'multi_step' | 'session_based';
volatility: 'low' | 'medium' | 'high' | 'very_high';
maxWin: number;
rtpVariant: string;
enabled: boolean;
thumbnailUrl: string;
}getDetails()
Returns detailed information about a specific game.
const game = await client.games.getDetails(gameId: string): Promise<GameDetails>;GameDetails
interface GameDetails {
id: string;
name: string;
type: 'single_step' | 'multi_step' | 'session_based';
volatility: 'low' | 'medium' | 'high' | 'very_high';
maxWin: number;
rtpVariant: string;
rtpRange: { min: number; max: number };
enabled: boolean;
thumbnailUrl: string;
description: string;
features: string[];
minBet: number;
maxBet: number;
currencies: string[];
version: string;
}client.wallet
Player wallet operations.
getBalance()
Returns the current balance for a player.
const balance = await client.wallet.getBalance(playerId: string): Promise<WalletBalance>;WalletBalance
interface WalletBalance {
playerId: string;
balance: number;
currency: string;
updatedAt: string; // ISO 8601
}Example
const { balance, currency } = await client.wallet.getBalance('player-123');
console.log(`Balance: ${balance} ${currency}`);client.test
Sandbox testing utilities. Only available with sk_sandbox_* API keys.
createPlayer()
Creates a test player with a starting balance.
const result = await client.test.createPlayer(request: CreateTestPlayerRequest): Promise<CreateTestPlayerResponse>;CreateTestPlayerRequest
interface CreateTestPlayerRequest {
externalId: string;
currency: string;
startingBalance: number;
username: string;
}CreateTestPlayerResponse
interface CreateTestPlayerResponse {
player: {
id: string;
externalId: string;
username: string;
currency: string;
};
wallet: {
id: string;
balance: number;
currency: string;
};
ssoToken: string;
}forceOutcome()
Forces a specific outcome for the next round. See Sandbox Testing for game-specific outcome formats.
await client.test.forceOutcome(request: ForceOutcomeRequest): Promise<void>;ForceOutcomeRequest
interface ForceOutcomeRequest {
playerId: string;
gameId: string;
outcome: SlotsOutcome | SafeSmashOutcome | BitKeyRushOutcome | FoxOutcome | CatapultOutcome;
}getHealth()
Returns the health status of all platform services.
const health = await client.test.getHealth(): Promise<HealthCheckResponse>;HealthCheckResponse
interface HealthCheckResponse {
status: 'healthy' | 'degraded' | 'unhealthy';
checks: Record<string, 'ok' | 'error'>;
timestamp: string;
version: string;
}SlottyApiError
Custom error class thrown for all API errors.
class SlottyApiError extends Error {
/** HTTP status code */
statusCode: number;
/** Slotty error code (e.g. "80001") */
code: string;
/** Human-readable error message */
message: string;
/** Unique request ID for support */
requestId: string;
/** Original response body */
body: Record<string, unknown>;
}Example Error Handling
import { SlottyClient, SlottyApiError } from '@slottylabs/sdk';
try {
const { launchToken } = await client.auth.createSSOToken({
playerId: 'player-123',
currency: 'USD',
jurisdiction: 'CW',
locale: 'en',
});
} catch (err) {
if (err instanceof SlottyApiError) {
switch (err.code) {
case '80001':
console.error('Invalid API key');
break;
case '80003':
console.error('Rate limited — retry after backoff');
break;
case '80010':
console.error('Player not found');
break;
default:
console.error(`API Error ${err.code}: ${err.message}`);
}
console.error(`Request ID: ${err.requestId}`);
} else {
// Network error, timeout, etc.
console.error('Unexpected error:', err);
}
}