Turbostars – Sportsbook Modules
The Turbostars Sportsbook Modules integration provides seamless access to Sportsbook functionality through the Operator Games API SDK.
It uses automatic parameter injection, where the getModules() API leverages a JavaScript Proxy to automatically include host, cid, and token in all module method calls.
This design keeps the integration simple, future-proof, and type-safe, as developers only need to provide parameters specific to their use case, while new Sportsbook methods are supported automatically without requiring any SDK updates.
How It Works?
When you call provider.getModules(), the SDK returns a proxied version of window.Sportsbook.
This proxy automatically injects shared parameters (host, cid, and token) from your SDK configuration into every method call, leaving you to focus only on game- or event-specific logic.
Auto-Injection Flow
Usage
Basic Setup
// Initialize the SDK
const sdk = await Hub88Games.init({
provider_token: 'YOUR_TOKEN',
partner_key: 'YOUR_PARTNER_KEY',
launcher_base_url: 'https://launcher.example.com'
});
// Get the provider instance
const provider = sdk.getProviderInstance();
// Retrieve modules with auto-injection enabled
const modules = provider.getModules();Available Module Methods
1. Bet slip Count Tracking
Tracks the number of bets in the user’s bet slip.
await modules.initBetslipCount({
onChange: (count) => {
console.log('Betslip count:', count);
updateBetslipBadge(count);
}
});Parameter
Type
Required
Description
onChange
function
Yes
Callback function triggered when the betslip count changes.
Auto-Injected Parameters: host, cid, token
2. Categorizer Data Subscription
Subscribes to updates in the categorizer data (sports/esports navigation).
await modules.subscribeOnCategorizerData({
onChange: (categorizerData) => {
console.log('Categorizer data:', categorizerData);
renderNavigationMenu(categorizerData);
},
sportsbookPath: '/betting',
isShowCategorizerInSportsbook: false,
lang: 'en'
});onChange
function
Yes
Callback receiving categorizer data updates.
sportsbookPath
string
No
Current sportsbook route for contextual data.
isShowCategorizerInSportsbook
boolean
No
Keep categorizer visible within sportsbook (default: false).
lang
string
No
Language code (ISO 639-1), e.g., en, es.
Auto-Injected Parameters: host, cid, token
3. Get Tournaments by Discipline
Retrieves tournament data for a specific discipline (e.g., Dota 2, CS:GO, LoL).
const tournaments = await modules.getTournamentsByDiscipline({
disciplineId: 'dota2',
sportsbookPath: '/betting',
lang: 'en'
});
console.log('Dota 2 tournaments:', tournaments);disciplineId
string
Yes
The discipline ID (dota2, csgo, lol).
sportsbookPath
string
No
Optional route path for correct URL generation.
lang
string
No
Language code for data localization.
Auto-Injected Parameters: host, cid, token
Future Method Support
The SDK uses dynamic proxying, so any new Sportsbook module methods introduced by Turbostars or future providers will work automatically, no SDK upgrade required.
// Example of a potential future feature
await modules.subscribeToLiveScores({
onChange: (scores) => console.log(scores),
sportTypes: ['football', 'basketball']
});
// The SDK automatically injects host, cid, tokenTypeScript Types
// User-facing params (host/cid/token omitted - auto-injected)
interface BetslipCountUserParams {
onChange: (count: number) => void
}
interface CategorizerDataUserParams {
onChange: (data: any) => void
sportsbookPath?: string
isShowCategorizerInSportsbook?: boolean
lang?: string
}
interface TournamentsByDisciplineUserParams {
disciplineId: string
sportsbookPath?: string
lang?: string
}
interface SportsbookModules {
initBetslipCount(config: BetslipCountUserParams): Promise<void>
subscribeOnCategorizerData(config: CategorizerDataUserParams): Promise<void>
getTournamentsByDiscipline(config: TournamentsByDisciplineUserParams): Promise<any>
// Any future methods will be typed as 'any' but still work
}Best Practices
Call getModules() After Initialization
getModules() After InitializationEnsure the SDK and provider are fully initialized before requesting modules.
const sdk = await Hub88Games.init(config);
const provider = sdk.getProviderInstance();
const modules = provider.getModules(); // ✅ Modules are readyDon't call the getModules() method before initialisation as this will return a null.
Reuse the Same Modules Instance
Avoid redundant getModules() calls for better performance.
// Good - store for reuse
const modules = provider.getModules();
await modules.initBetslipCount({ onChange: handleCount });
await modules.subscribeOnCategorizerData({ onChange: handleCategorizer });
// Less efficient - multiple getModules calls
await provider.getModules().initBetslipCount({ onChange: handleCount });
await provider.getModules().subscribeOnCategorizerData({ onChange: handleCategorizer });Handle Errors Gracefully
Use try/catch to capture initialization or communication errors.
try {
const modules = provider.getModules();
if (!modules) {
console.error('Modules not available');
return;
}
await modules.initBetslipCount({
onChange: (count) => console.log(count)
});
} catch (error) {
console.error('Module initialization failed:', error);
}Last updated
Was this helpful?

