Skip to main content

Midasbuy Game SDK

1. SDK Description

Provides functionality to display and hide the game menu bar, and allows developers to customize error handling.

2. Integrating the SDK

Include the script in your HTML file:

<script src="https://cdn.midasbuy.com/js/game.stable.js"></script>

3. API Documentation

3.1. midas.game(params)

Init the game sdk:

const gameApi = midas.game({
appid: '1460000xxx',
language: 'en',
region: 'us',
sandbox: 1,
});
ParameterRequiredLocationTypeFormatDescription
appidYesparamsStringstring.min_len: 1Application ID
languageYesparamsStringstring.len: 2Language code; currently, Midasbuy supports ar,hk,tr,de,id,pu,tw,en,ja,ru,vn,es,ko,fr,my,th
regionYesparamsStringstring.len: 2Country code; refer to the [region select] for available options
sandboxNoparamsNumber0 for production, 1 for sandbox. Default is 0, use 1 for debugging

3.2. gameApi.show(options)

Display the game menu bar:

gameApi.show({
gradually: true
})
.then((res) => {
console.log(res); // { res: 'show_menu_success' }
})
.catch((res) => {
console.log(res); // { res: 'show_menu_fail' }
});
ParameterRequiredLocationTypeFormatDescription
graduallyNoparamsBooleanWhether the menu display has a transition animation, default is true

3.3. gameApi.hide()

Hide the game menu bar:

gameApi.hide();

3.3. Error Handling

gameApi.setErrorHandler(handler: (error: Error) => void)

Custom error handling:

gameApi.setErrorHandler((error) => {
console.error("Custom error handler:", error);
});
  • handler: Custom error handler function, default is console.error.

4. Calling Example

const gameApi = midas.game({
appid: '1460000xxx',
language: 'en',
region: 'us',
sandbox: 1,
});

gameApi.show({
gradually: true
})
.then((res) => {
console.log(res); // { res: 'show_menu_success' }
})
.catch((res) => {
console.log(res); // { res: 'show_menu_fail' }
});

gameApi.hide();

gameApi.setErrorHandler((error) => {
console.error("Custom error handler:", error);
});

Demo page link: Midasbuy Game SDK Demo

Share status