Skip to content

SlottyClient Reference

The SlottyClient class is the main entry point for the Slotty Labs SDK. It provides access to all API modules.

Constructor

typescript
import { SlottyClient } from '@slottylabs/sdk';

const client = new SlottyClient(config: SlottyClientConfig);

SlottyClientConfig

typescript
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.com
  • sk_live_*https://api.slottylabs.com

client.auth

Authentication and SSO token management.

createSSOToken()

Creates a single-use SSO launch token for a player.

typescript
const result = await client.auth.createSSOToken(request: CreateSSOTokenRequest): Promise<CreateSSOTokenResponse>;

CreateSSOTokenRequest

typescript
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

typescript
interface CreateSSOTokenResponse {
  /** Single-use JWT launch token (30s TTL) */
  launchToken: string;

  /** Token expiry timestamp (ISO 8601) */
  expiresAt: string;
}

Example

typescript
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 seconds

client.games

Game catalog and launch URL management.

getLaunchUrl()

Generates a game launch URL with the given token and options.

typescript
const url = client.games.getLaunchUrl(
  gameId: string,
  launchToken: string,
  options?: LaunchUrlOptions,
): string;

LaunchUrlOptions

typescript
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

typescript
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=desktop

list()

Returns the full game catalog available to your tenant.

typescript
const games = await client.games.list(): Promise<GameListResponse>;

GameListResponse

typescript
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.

typescript
const game = await client.games.getDetails(gameId: string): Promise<GameDetails>;

GameDetails

typescript
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.

typescript
const balance = await client.wallet.getBalance(playerId: string): Promise<WalletBalance>;

WalletBalance

typescript
interface WalletBalance {
  playerId: string;
  balance: number;
  currency: string;
  updatedAt: string; // ISO 8601
}

Example

typescript
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.

typescript
const result = await client.test.createPlayer(request: CreateTestPlayerRequest): Promise<CreateTestPlayerResponse>;

CreateTestPlayerRequest

typescript
interface CreateTestPlayerRequest {
  externalId: string;
  currency: string;
  startingBalance: number;
  username: string;
}

CreateTestPlayerResponse

typescript
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.

typescript
await client.test.forceOutcome(request: ForceOutcomeRequest): Promise<void>;

ForceOutcomeRequest

typescript
interface ForceOutcomeRequest {
  playerId: string;
  gameId: string;
  outcome: SlotsOutcome | SafeSmashOutcome | BitKeyRushOutcome | FoxOutcome | CatapultOutcome;
}

getHealth()

Returns the health status of all platform services.

typescript
const health = await client.test.getHealth(): Promise<HealthCheckResponse>;

HealthCheckResponse

typescript
interface HealthCheckResponse {
  status: 'healthy' | 'degraded' | 'unhealthy';
  checks: Record<string, 'ok' | 'error'>;
  timestamp: string;
  version: string;
}

SlottyApiError

Custom error class thrown for all API errors.

typescript
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

typescript
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);
  }
}