Operator Games API SDK

The Operator Games API SDK is a JavaScript/TypeScript library that provides operators with a unified integration layer for multiple game suppliers, starting with Turbostars. With this SDK, you can have:

  • A unified interface by integrating one SDK for multiple game suppliers,

  • Automatic token validation done with Hub88 backend,

  • Automatically select the correct supplier based on game code received after a successful token validation,

  • Integrate games directly without iframes (Shadow Mode),

  • Configuration management by handling provider-specific configurations seamlessly.

As the SDK runs natively, it avoids iframe limitations, reduces overhead, and provides a smoother, mobile-friendly gaming experience.


Integration Flow

The integration follows a simple two-step process:


Authorisation

  • The operator backend calls Hub88’s /game/authorize endpoint and returns initialisation data to the frontend.

  • Hub88 API validates tokens, resolves provider and game configuration, and delivers provider-specific data.

  • Operator Games API SDK initialises the correct provider SDK based on the game code prefix (e.g., btsg_ → Turbostars).

  • Game supplier (provider SDK) is initialised seamlessly in the player’s browser.


Integration Steps

Step 1: Authorise Game Session (Backend)

Your backend must call the Hub88 Authorise API /game/authorize to retrieve the initialisation payload.

API Endpoint

  • Staging

POST https://api.server1.ih.testenv.io/operator/generic/v2/game/authorize
  • Production:

POST https://api.hub88.io/operator/generic/v2/game/authorize

Request Body

{
  "user": "john12345",
  "token": "f562a685-a160-4d17-876d-ab3363db331c",
  "sub_partner_id": "my-casino-id",
  "platform": "GPL_DESKTOP",
  "operator_id": 1,
  "meta": {},
  "ip": "0.0.0.0",
  "lobby_url": "https://amazingcasino.com/lobby",
  "lang": "en",
  "game_code": "btsg_csgo",  // Turbostars games start with 'btsg_'
  "deposit_url": "https://amazingcasino.com/deposit",
  "currency": "EUR",
  "game_currency": "EUR",
  "country": "EE"
}

Response

{
  "provider_pid": "ta-hub88-stage",  // Required: Partner key for SDK
  "provider_user": "cg_147549",  // Optional: User identifier
  "provider_token": "9002CAA58FE78D1C460E40EEA75563A54A377F5C",  // Required: SDK token
  "provider_game": null,   // Optional: Game identifier
  "provider_currency_code": "USD", // Optional: Currency code
  "launcher_base_url": "https://launcher.server1.ih.testenv.io"  // Required: API base URL
}

Return this payload securely to your frontend.


Step 2: Initialise SDK Client (Frontend)

Use the authorisation response to initialise the Operator Games API SDK on your frontend.

Installation via CDN

<script src="https://cdn.hub88.io/games-sdk/hub88-games-sdk-1.0.5.js"></script>

Basic Integration Example

<!-- Container for the game -->
<div id="game-container"></div>

<!-- Include the SDK -->
<script src="https://cdn.hub88.io/games-sdk/hub88-games-sdk-<version>.js"></script>

<script>
async function launchGame() {
  try {
    // Get authorization data from your backend
    const authData = await fetch('/api/game/authorize', {
      method: 'POST',
      body: JSON.stringify({
        game_code: 'btsg_csgo',
        user: 'player123'
        // ... other parameters
      })
    }).then(r => r.json());

    // Initialize Hub88 Games SDK
    const gameInstance = await Hub88Games.init({
      // Required parameters (minimum needed)
      provider_token: authData.provider_token,
      provider_pid: authData.provider_pid,        // Maps to provider_pid
      launcher_base_url: authData.launcher_base_url,

      // Optional parameters
      containerId: 'game-container',
      lang: 'en',
      loginUrl: 'sendPostMessage',  // or your login URL
      depositUrl: 'sendPostMessage' // or your deposit URL
    });

    console.log('Game loaded successfully!');

  } catch (error) {
    console.error('Failed to load game:', error);
  }
}

// Launch the game
launchGame();
</script>

Advanced Configuration

const gameInstance = await Hub88Games.init({
  // Required parameters
  provider_token: authData.provider_token,
  provider_pid: authData.provider_pid,
  launcher_base_url: authData.launcher_base_url,

  // Optional parameters
  game_code: 'btsg_csgo',           // Override game code if needed - NOT necessary since we get this information from the session related to the token.
  lang: 'en',                       // Language preference
  containerId: 'game-container',    // DOM container ID
  loginUrl: 'sendPostMessage',      // Login handling method
  depositUrl: 'sendPostMessage',    // Deposit handling method

  // Advanced options (provider-specific)
  meta: {
    allowToChangeParentStyles: true,  // Allow game to modify parent CSS
    disallowUrlChange: false,         // Control URL routing behavior
    lineFilter: 'sport',              // Filter content: 'sport', 'esport', or custom
    sub_partner_id: 'casino-section', // Sub-partner identification
    customStyles: 'https://cdn.example.com/game-styles.css'  // Custom styling
  }
});

SDK Methods and Lifecycle

Method
Description

isInitialized()

Returns true if SDK is ready.

getProvider()

Returns the detected provider (e.g., turbostars).

update(config)

Updates optional configuration (e.g., language, meta).

destroy()

Cleans up resources and terminates the session.

Instance Methods

// Check if SDK is initialized
if (gameInstance.isInitialized()) {
  console.log('SDK is ready');
}

// Get current provider
const provider = gameInstance.getProvider(); // Returns: 'turbostars'

// Update configuration (optional parameters only)
await gameInstance.update({
  lang: 'es',
  meta: {
    lineFilter: 'esport'
  }
});

// Clean up when done
await gameInstance.destroy();

Game Supplier Support

Multi-Provider Architecture

This SDK is built on a multi-provider architecture, allowing operators to integrate with a wide range of game suppliers through a single SDK.

The initial release focuses on Turbostars integration, but the SDK is fully extensible, meaning new suppliers can be added easily by Hub88 without you changing your integration. This ensures long-term scalability and compatibility as more providers are onboarded.

Turbostars Integration

Games with the prefix btsg_ are automatically recognised and handled by the supplier Turbostars.

  • Supported Games: CS:GO, Dota 2, LoL, and other esports titles

  • Features: Live betting, pre-match odds, multiple bet types

Example Game Codes

Game Code
Title

btsg_csgo

Counter-Strike: Global Offensive

btsg_dota2

Dota 2

btsg_lol

League of Legends


Error Handling

Common Error Scenarios

INVALID_TOKEN

Token validation failed

The provided token is invalid, expired, or not recognised by Hub88.

Refresh or reissue the token and reattempt initialisation.

PROVIDER_NOT_FOUND

Game provider not supported

The SDK could not detect or match the game’s provider (e.g., unknown prefix).

Verify the game code and ensure the provider is supported by the SDK.

CONTAINER_NOT_FOUND

Game container missing

The specified DOM container for the game does not exist or cannot be found.

Ensure the container element (e.g. #game-container) is present in the DOM before initialisation.

CONFIG_VALIDATION_FAILED

Invalid configuration

One or more configuration parameters are missing or invalid in the SDK setup.

Check all required parameters (provider_token, provider_pid, launcher_base_url).

UNKNOWN_ERROR (default)

Initialisation failed (generic error)

A non-specific error occurred during SDK setup or communication.

Review logs for details and confirm SDK configuration and network connectivity.

try {
  const gameInstance = await Hub88Games.init(config);
} catch (error) {
  switch (error.code) {
    case 'INVALID_TOKEN':
      console.error('Token validation failed:', error.message);
      // Redirect to login or refresh token
      break;

    case 'PROVIDER_NOT_FOUND':
      console.error('Game provider not supported:', error.message);
      // Show unsupported game message
      break;

    case 'CONTAINER_NOT_FOUND':
      console.error('Game container missing:', error.message);
      // Ensure DOM container exists
      break;

    case 'CONFIG_VALIDATION_FAILED':
      console.error('Invalid configuration:', error.message);
      // Check required parameters
      break;

    default:
      console.error('Initialization failed:', error.message);
  }
}

Validation Requirements

The SDK validates these required parameters:

  • provider_token - Required, alphanumeric string 10–100 characters. Can't be empty or null.

  • provider_pid - Required, non-empty string.

  • launch_base_url - Required, must be a valid URL

Security Considerations

  1. Follow the best practices of Server-Side Authorisation. Always call /game/authorize from your backend, never expose operator credentials to the frontend.

  2. Do not expose operator credentials.

  3. Generate fresh tokens for each new session.


Migration from iframe Integration

<iframe src="https://launcher.server1.ih.testenv.io/game/btsg_csgo?token=..."></iframe>
const gameInstance = await Hub88Games.init({
  provider_token: "...",
  provider_pi: "...",
  launcher_base_url: "https://launcher.server1.ih.testenv.io"
});

By switching to the SDK, you can expect improved performance and additional features compared to the traditional iframe integration.


Last updated

Was this helpful?