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
Platform-controlled pricing
yes.purchase()#yes.purchase(tierId: PurchaseTierId, options?: PurchaseOptions): Promise<PurchaseResult>
Prompt the player to spend coins from their wallet. The platform shows a native confirmation modal with the tier cost and optional label. Always check result.success before granting in-game content.
Parameters
| Name | Type | Description |
|---|---|---|
tierId | 'tier_1' | 'tier_2' | 'tier_3' | 'tier_4' | The coin tier to charge. Throws synchronously if the tier ID is invalid. |
options.label? | string | Label shown in the confirmation modal (e.g. 'Unlock Level Pack'). Helps players understand what they're purchasing. |
Returns
Promise<PurchaseResult>{ success, tierId?, coinsSpent? } on success — { success: false, reason } on failure. reason is 'cancelled' | 'insufficient_funds' | 'error'
Example
const result = await yes.purchase('tier_2', { label: 'Extra Lives' });if (result.success) {// Coins deducted — grant the in-game itemgrantExtraLives();} else if (result.reason === 'insufficient_funds') {showMessage('Not enough coins!');} else if (result.reason === 'cancelled') {// Player tapped cancel — do nothing}
| Tier ID | Coins |
|---|---|
tier_1 | 50 |
tier_2 | 150 |
tier_3 | 500 |
tier_4 | 1000 |
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 — no await needed. Use this at game init to set your UI language.
Returns
stringLanguage code: 'en' (English) or 'tr' (Turkish). Defaults to 'en' if not set.
Example
const lang = yes.getLanguage();if (lang === 'tr') {setUILanguage('turkish');} else {setUILanguage('english');}
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!');}}// In-game coin purchaseasync function unlockLevelPack() {const result = await yes.purchase('tier_2', { label: 'Level Pack' });if (result.success) {grantLevelPack();yes.haptic('success');} else if (result.reason === 'insufficient_funds') {showMessage('Not enough coins!');}}
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.