Skip to content

URL Parameters

Richard Fu edited this page Jan 3, 2026 · 2 revisions

URL Parameters

The Stake Engine Client supports automatic configuration from URL parameters, making it easy to integrate into browser-based games without manual configuration.

Overview

When Stake Engine launches your game, it passes configuration via URL parameters:

https://your-game.com/?sessionID=abc123&rgs_url=rgs.stake-engine.com&lang=en&currency=USD

The client automatically reads these parameters, allowing you to call API functions without explicitly passing configuration.

Supported Parameters

URL Parameter Maps To Description Required Default
sessionID sessionID Player session identifier Yes -
rgs_url rgsUrl RGS server hostname Yes -
lang language Player language code No 'en'
currency currency Currency code (USD, EUR, etc.) No 'USD'

Usage with URL Parameters

With URL parameters present, you can omit configuration from function calls:

import { authenticate, play, getBalance } from 'stake-engine-client';

// All configuration is read from URL automatically
const auth = await authenticate();
const balance = await getBalance();

const bet = await play({
  amount: 1.00,
  mode: 'base'
  // sessionID, rgsUrl, language, currency all come from URL
});

Explicit Configuration Override

You can still explicitly pass parameters to override URL values:

import { play } from 'stake-engine-client';

// Override URL parameters with explicit values
const bet = await play({
  sessionID: 'custom-session',  // Override URL sessionID
  rgsUrl: 'custom.rgs-server.com',  // Override URL rgs_url
  currency: 'EUR',  // Override URL currency
  amount: 5.00,
  mode: 'base'
});

Replay Mode URL Parameters

For replay functionality, additional parameters are supported:

https://your-game.com/?replay=true&game=my-game&version=1&mode=base&event=12345&rgs_url=rgs.stake-engine.com
Parameter Description Required for Replay
replay Set to 'true' to enable replay mode Yes
game Game identifier Yes
version Game version number Yes
mode Game mode (base, freespin, etc.) Yes
event Event ID to replay Yes

See Replay Helpers for utility functions that work with replay URL parameters.

Browser vs Node.js

Browser Environment

URL parameters are automatically detected using window.location.search:

// Automatically works in browser
import { authenticate } from 'stake-engine-client';

const auth = await authenticate();
// Reads from window.location.search

Node.js Environment

In Node.js, there's no browser window object, so you must explicitly provide configuration:

import { authenticate } from 'stake-engine-client';

// Must provide explicit config in Node.js
const auth = await authenticate({
  sessionID: 'player-session-123',
  rgsUrl: 'api.stakeengine.com',
  language: 'en'
});

Implementation Details

The client uses URLSearchParams internally to parse query strings:

// Internal implementation example
const params = new URLSearchParams(window.location.search);
const sessionID = params.get('sessionID') || undefined;
const rgsUrl = params.get('rgs_url') || undefined;
const language = params.get('lang') || 'en';
const currency = params.get('currency') || 'USD';

Best Practices

  1. Browser Games: Rely on URL parameters for configuration

    • No manual config needed
    • Works automatically with Stake Engine launcher
  2. Node.js Applications: Always use explicit configuration

    • URL parameters aren't available
    • Pass config object to every function
  3. Hybrid Approach: Use URL parameters with selective overrides

    • Read most config from URL
    • Override specific values when needed
  4. Testing: Pass explicit config during development

    • Easier to test without setting up URL parameters
    • Can use .env files or config objects

Examples

Pure URL-based Configuration (Browser)

// Game launched from: ?sessionID=abc&rgs_url=rgs.example.com&lang=en&currency=USD

import { authenticate, play } from 'stake-engine-client';

const auth = await authenticate();
// Uses URL params automatically

const bet = await play({
  amount: 1.00,
  mode: 'base'
  // currency, sessionID, rgsUrl all from URL
});

Explicit Configuration (Node.js)

import { authenticate, play } from 'stake-engine-client';

const config = {
  sessionID: process.env.SESSION_ID,
  rgsUrl: process.env.RGS_URL,
  language: 'en'
};

const auth = await authenticate(config);
const bet = await play({
  ...config,
  currency: 'USD',
  amount: 1.00,
  mode: 'base'
});

Mixed Approach (Browser with Overrides)

// URL provides sessionID and rgs_url
// But we want to override currency

import { play } from 'stake-engine-client';

const bet = await play({
  currency: 'EUR',  // Override URL currency
  amount: 1.00,
  mode: 'base'
  // sessionID and rgsUrl still come from URL
});

Related Pages

Clone this wiki locally