YES SDK
Integrate your games with the YES platform. Add leaderboards, ads, and haptic feedback with just a few lines of code.
1Getting Started
No installation needed
The SDK is automatically injected into your game when it runs on the YES platform. Just use the global yes object.
Quick Start
// Submit a score (fire and forget)if (typeof yes !== 'undefined') {yes.submitScore(score);}// Reward the player with an adconst ad = await yes.showRewardedAd();if (ad.rewarded) givePlayerCoins(100);// Trigger haptic feedbackyes.haptic('success');
Local Development
When running outside the YES platform (e.g., local development), the SDK operates in standalone mode and returns mock data. This allows you to develop and test without being connected to the platform.
2API Reference
Scores
Boost Player Retention
Leaderboards drive competition and keep players coming back. Games with score systems see significantly higher retention rates as players compete to climb the ranks.
yes.submitScore()#
yes.submitScore(score: number): void
Submit a score to the leaderboard. Just call it — no need to await.
Parameters
| Name | Type | Description |
|---|---|---|
score | number | The score to submit (must be a positive number) |
Example
// Fire and forget — just call itif (typeof yes !== 'undefined') {yes.submitScore(gameState.score);}
Ads
Two Ad Formats
Rewarded ads are opt-in — the player chooses to watch in exchange for a reward. Interstitial ads play between natural moments (e.g., between levels) and are rate-limited by the SDK so players aren't overwhelmed.
yes.showRewardedAd()#
yes.showRewardedAd(): Promise<RewardedAdResult>
Display a rewarded video ad to the player. The player can earn rewards by watching the full ad.
Returns
Promise<RewardedAdResult>Object containing rewarded (boolean), and optionally errorCode and errorMessage if failed
Example
const result = await yes.showRewardedAd();if (result.rewarded) {// Player completed the ad - give reward!player.coins += 100;showMessage('You earned 100 coins!');} else {// Ad was skipped or failedif (result.errorCode === 'USER_DISMISSED') {showMessage('Watch the full ad to earn rewards');} else if (result.errorCode === 'NOT_LOADED') {showMessage('No ad available right now');}}
yes.isRewardedAdReady()#
yes.isRewardedAdReady(): Promise<AdReadyStatus>
Check if a rewarded ad is available to show. Use this to conditionally display 'Watch Ad' buttons.
Returns
Promise<AdReadyStatus>Object containing ready (boolean)
Example
// Check before showing the "Watch Ad" buttonconst { ready } = await yes.isRewardedAdReady();const watchAdButton = document.getElementById('watchAdBtn');watchAdButton.style.display = ready ? 'block' : 'none';
yes.showInterstitialAd()#
yes.showInterstitialAd(): Promise<InterstitialAdResult>
Show an interstitial ad between natural game moments (e.g., between levels). Rate-limited by the SDK — if called too frequently, it resolves immediately without showing an ad. Times out after 60 seconds.
Returns
Promise<InterstitialAdResult>Object containing shown (boolean) indicating whether the ad was displayed
Example
// Between levelsasync function onLevelComplete() {await yes.showInterstitialAd();loadNextLevel();}
yes.isInterstitialAdReady()#
yes.isInterstitialAdReady(): Promise<AdReadyStatus>
Check if an interstitial ad is available and not rate-limited. Returns false if the cooldown period hasn't elapsed since the last interstitial.
Returns
Promise<AdReadyStatus>Object containing ready (boolean)
Example
const { ready } = await yes.isInterstitialAdReady();if (ready) {await yes.showInterstitialAd();}
Haptic
yes.haptic()#
yes.haptic(style?: HapticStyle): void
Trigger haptic feedback on the player's device. Fire-and-forget — no need to await. Falls back silently on devices without haptic support.
Parameters
| Name | Type | Description |
|---|---|---|
style? | 'light' | 'medium' | 'heavy' | 'success' | 'warning' | 'error' | 'selection' | The haptic feedback style. Defaults to 'medium' |
Example
yes.haptic(); // default medium tapyes.haptic('success'); // positive feedbackyes.haptic('error'); // negative feedback
3Full Example
Here's a complete example showing how to integrate all SDK features in a game:
let player = null;let score = 0;// Initialize when SDK is readyyes.onReady(async () => {player = await yes.getPlayer();document.getElementById('playerName').textContent = player.username;});// Called when player completes a levelasync function onLevelComplete(levelScore) {score += levelScore;// Submit score (fire and forget)yes.submitScore(score);yes.haptic('success');// Show an interstitial between levelsawait yes.showInterstitialAd();loadNextLevel();}// Rewarded ad for extra livesasync function watchAdForLife() {const result = await yes.showRewardedAd();if (result.rewarded) {player.lives++;showMessage('Extra life earned!');}}
4Best Practices
Safety Check
Guard against the SDK not being loaded, and always check ad results:
// Guard before callingif (typeof yes !== 'undefined') {yes.submitScore(score);}// Always check ad resultsconst ad = await yes.showRewardedAd();if (ad.rewarded) {giveReward();}
Score Submission Timing
Submit scores at natural game moments - end of level, game over, or achievement completion. Avoid spamming score submissions during gameplay.
Testing Locally
The SDK returns mock data in standalone mode, so you can develop and test without uploading to YES. All API calls will succeed with sample responses.