Create your account before using our SDK.
<script type="text/javascript" src="https://huhgames.com/api/sdk/huh.js"></script>
GameSDK.init('YOUR_DEV_ID', 'YOUR_PUBLISHER_ID');
Call ads during natural game breaks (Before level, after level, etc). Pause game and music while ad is playing.
//
// pause game / music before calling:
//
GameSDK.APIAds.show(function() {
//
// ad is finished, unpause game/music
//
console.log("ad completed");
});
Games using reward ads earn 3x more on average. Give users rewards (extra life, puzzle hints, etc) for watching an ad.
Reward ads work in two steps:
// step 1: call this to check if reward ad available
GameSDK.GEvents.reward(canShowReward, rewardSuccess);
// this will be called if a reward ad can be shown or not
var canShowReward = function(success, showAdFn) {
if(success) {
// you can show user a button for a reward, must call showAdFn() on click
// ex: rewardButton.onclick = function() { showAdFn(); }
} else {
// no ad to show, do nothing
}
}
// after ad is played (after showAdFn() is called)
var rewardSuccess = function(success) {
if(success) {
// give user the reward
} else {
// no reward
}
// remove reward button
// ex: rewardButton.remove();
}
You can add Achievements and High scores while uploading your game. These features increase game plays, revenue and visibility.
var api_awards = [];
api_awards.push(AWARD_ID);
// can push more than one award at a time
GameSDK.Achievements.save(api_awards, function(response) {
if(response.success) {
console.log('achievement saved');
} else {
console.log(response.errormsg);
}
});
var boardinfo = {};
boardinfo.score = SCORE_VAR;
boardinfo.board = HS_BOARD_ID;
GameSDK.Scores.save(boardinfo, function(response) {
if(response.success) {
console.log('high score saved');
} else {
console.log(response.errormsg);
}
});
GameSDK.User.get(function(userData) {
console.log(userData);
console.log(userData.user.id);
console.log(userData.user.name);
console.log(userData.user.avatar);
});
Make sure "Use Worker" is set to "No" in advanced project settings for SDK to work correctly.
Insert your Developer ID and Publisher ID
YOU_DEV_ID
YOUR_PUBLISHER_ID
Call show ad action
Trigger once on button clicks (start button, next level button, restart button, etc). SDK handles Ad cooldown. In dev mode ads will show each time for testing.
Games using reward ads earn 3x more on average. Give users rewards (extra life, puzzle hints, etc) for watching an ad.
Two steps: Check if ad available, if it is then show user a button to click
Step 1: Call Check if Reward Ad Available (step 1) action (can be called at any point, usually takes 200ms to return true/false)
Step 1 Condition: Reward Ad Check (step 1)
If there is an ad available this will trigger true.
Now you can show a button the user can tap with Play Reward Ad (step 2) action.
Step 2 Conditions: Use Reward Ad Success to give user the reward and Reward Ad Failure to get pinged when reward ad failed.
You can add Achievements and High scores while uploading your game. These features increase game plays, revenue and visibility on Lagged.
Save Achievement action, Trigger once when true:
example_awardid_j001
Save score action, score=whole integer, trigger once
example_boardid_jf01
Get user variables (expressions). Registered users will have an ID 0
UserName UserID UserAvatar
© 2025 Huh Games