SDK
The Yes SDK runs inside your game. Submit scores, show ads, trigger haptics, and spend platform coins — all from a single global yes object.
Getting Started
No installation needed
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 lets you develop and test without being connected to the platform.
API Reference
Scores
Boost player retention
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
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
Coins
Purchases have been removed
yes.showRewardedAd() instead.yes.purchase() still exists so published games keep running, but it always resolves with { success: false, reason: 'purchase_unavailable' } — it never shows UI and never charges the player. Hide any store UI your game gates on it.Language
Match the app's language
getLanguage() to read it and localize your game's UI so everything feels native to them.yes.getLanguage()#yes.getLanguage(): string
Returns the app's current language code. Synchronous, and already correct before your first line of game code runs — you do not need to wait for onReady().
Returns
stringOne of 'en', 'tr', 'es', 'pt-BR', 'de', 'fr', 'ar'. Defaults to 'en'. Note that 'pt-BR' is region-tagged and 'ar' is right-to-left.
Example
const lang = yes.getLanguage();const base = lang.split('-')[0]; // 'pt-BR' -> 'pt'setUILanguage(SUPPORTED[base] ? base : 'en');
yes.onLanguageChange(callback)#yes.onLanguageChange(callback: (language: string) => void): () => void
Fires when the player switches language while your game is running. Only on an actual change — read the initial value with getLanguage(). Returns an unsubscribe function.
Returns
() => voidCall it to stop listening.
Example
// Localize now, and again whenever the player switches.applyTranslations();yes.onLanguageChange(() => applyTranslations());
Never freeze the language at module scope
getLanguage() once into a module-level constant means your HUD and menus keep whatever language they had at startup, while text you render later comes out correct — so the game looks half-translated. Read it where you use it, or re-render from onLanguageChange().Full Example
A complete game.js that uses every SDK feature:
let player = null;let score = 0;// Initialize when SDK is readyyes.onReady(async () => {player = await yes.getPlayer();document.getElementById('playerName').textContent = player.username;// Localize the UI to match the app's languageconst lang = yes.getLanguage();setUILanguage(lang); // 'en' or 'tr'});// 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!');}}
Best Practices
Safety check
Guard against the SDK not being loaded, and always check ad results before granting rewards:
if (typeof yes !== 'undefined') {yes.submitScore(score);}const 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 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 resolve with sample responses.