In your game

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

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 ad
const ad = await yes.showRewardedAd();
if (ad.rewarded) givePlayerCoins(100);
// Trigger haptic feedback
yes.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

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
NameTypeDescription
scorenumberThe score to submit (must be a positive number)
Example
// Fire and forget — just call it
if (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 failed
if (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" button
const { 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 levels
async 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
NameTypeDescription
style?'light' | 'medium' | 'heavy' | 'success' | 'warning' | 'error' | 'selection'The haptic feedback style. Defaults to 'medium'
Example
yes.haptic(); // default medium tap
yes.haptic('success'); // positive feedback
yes.haptic('error'); // negative feedback

Coins

Purchases have been removed

Games no longer sell items for coins. A coin is now worth exactly one rewarded ad, so reward moments belong in 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

Players set their language in the Yes app. Use 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

This is the most common localization bug we see. Capturing 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:

game.js
let player = null;
let score = 0;
// Initialize when SDK is ready
yes.onReady(async () => {
player = await yes.getPlayer();
document.getElementById('playerName').textContent = player.username;
// Localize the UI to match the app's language
const lang = yes.getLanguage();
setUILanguage(lang); // 'en' or 'tr'
});
// Called when player completes a level
async function onLevelComplete(levelScore) {
score += levelScore;
// Submit score (fire and forget)
yes.submitScore(score);
yes.haptic('success');
// Show an interstitial between levels
await yes.showInterstitialAd();
loadNextLevel();
}
// Rewarded ad for extra lives
async 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.