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,
});
Parameter | Required | Location | Type | Format | Description |
---|---|---|---|---|---|
appid | Yes | params | String | string.min_len: 1 | Application ID |
language | Yes | params | String | string.len: 2 | Language code; currently, Midasbuy supports ar,hk,tr,de,id,pu,tw,en,ja,ru,vn,es,ko,fr,my,th |
region | Yes | params | String | string.len: 2 | Country code; refer to the [region select] for available options |
sandbox | No | params | Number | 0 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' }
});
Parameter | Required | Location | Type | Format | Description |
---|---|---|---|---|---|
gradually | No | params | Boolean | Whether 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 isconsole.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