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
Coins
Platform-Controlled Pricing
Coin costs are defined by the platform using fixed tiers — your game never sets prices directly. This keeps the economy consistent across all games and ensures players always know what to expect.
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
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 — 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');}
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;// 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!');}}
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.