> For the complete documentation index, see [llms.txt](https://wiki.playgama.com/playgama/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://wiki.playgama.com/playgama/bridge-sdk/api.md).

# API

Reference for Playgama Bridge SDK modules. Method names and behavior are identical on every platform — Bridge maps each call to the native platform SDK internally.

## Required steps

These steps are **mandatory** for every game. Platforms verify them during moderation — a game that skips any of them can be rejected or behave incorrectly for players. Everything else moderation checks is in the [Game Requirements](/playgama/game-requirements.md).

1. **Ship** [**`playgama-bridge-config.json`**](/playgama/bridge-sdk/config.md) **inside the archive**, next to `index.html`. A build whose config is missing, unreachable or invalid fails the automatic build check.
2. **Load and initialize the Bridge before the game.** The SDK script is the first script in the `<head>` of `index.html`, loaded normally — not `async`, not added later from code — and initialization finishes before the game starts loading its engine and assets. In Plain JS call `bridge.initialize()` and wait for the promise before anything else; the engine plugins and their templates do this for you (see [Setup](/playgama/bridge-sdk/setup.md)). Do not call any SDK API before initialization finishes.
3. **Localize the game using** [**`platform.language`**](/playgama/bridge-sdk/api/platform.md#language) — read it once after initialization and use it as the source language for your localization system.
4. **Save and load progress only through** [**Storage**](/playgama/bridge-sdk/api/storage.md) — never through `localStorage`, `sessionStorage`, IndexedDB, cookies or an engine's own save system such as `PlayerPrefs`. At startup, read all keys in one `storage.get([...])` call and restore the player's state before showing gameplay. Write only when meaningful progress changes — a level completed, a purchase, a settings change — with all changed keys in one call, never every frame or on every action.
5. **Handle** [**pause**](/playgama/bridge-sdk/api/platform.md#pause) **and** [**audio**](/playgama/bridge-sdk/api/platform.md#is-audio-enabled) **state.** At startup, check `platform.isAudioEnabled` and start muted if it is `false`; then react to the pause and audio state events. Platforms fire them when the player switches tabs, minimizes the browser, or an ad opens — a game that keeps playing sound in the background fails moderation.
6. **Send** [**`platform.sendMessage('game_ready')`**](/playgama/bridge-sdk/api/platform.md#sending-a-message-to-the-platform) when the first playable frame is ready and the player can interact with it — never while a loading screen is still displayed. Platforms use this message to hide their loading screen and start analytics.
7. **Show** [**interstitial ads**](/playgama/bridge-sdk/api/advertisement/interstitial.md) — call `showInterstitial()` at every natural pause, such as level transitions or game over. Do not add your own timers or counters: Bridge decides when an ad is actually shown, including the delay before the first one and the interval between them.
8. **Hide what the platform does not support** instead of showing it broken: rewarded ad buttons when [`isRewardedSupported`](/playgama/bridge-sdk/api/advertisement/rewarded.md) is `false`, the store when [`payments.isSupported`](/playgama/bridge-sdk/api/payments.md) is `false`, the leaderboard when [`leaderboards.type`](/playgama/bridge-sdk/api/leaderboards.md) is `not_available`, sign-in buttons when [`player.isAuthorizationSupported`](/playgama/bridge-sdk/api/player.md) is `false`, links outside the platform when [`platform.isExternalLinksAllowed`](/playgama/bridge-sdk/api/platform.md#is-external-links-allowed) is `false`.

If the game uses [rewarded ads](/playgama/bridge-sdk/api/advertisement/rewarded.md) or [payments](/playgama/bridge-sdk/api/payments.md), the rules marked **only** and **always** on those pages are mandatory as well: grant a reward only in the `rewarded` state, check permanent purchases with `getPurchases()` on every launch, consume every consumable purchase.

## Everything else — optional, but highly recommended

The remaining modules are not required to pass moderation, but each one directly improves monetization, retention, or platform ranking. Integrate as many as make sense for your game.

### Monetization

* [**Advertisement → Rewarded**](/playgama/bridge-sdk/api/advertisement/rewarded.md) — opt-in ads for in-game rewards (a revive once per attempt, double coins, hint). Usually the highest-eCPM format because players consent.
* [**Advertisement → Banner**](/playgama/bridge-sdk/api/advertisement/banner.md) — passive ads on idle screens (menu, lobby, pause).
* [**Advertisement → Advanced Banners**](/playgama/bridge-sdk/api/advertisement/advanced-banners.md) — multiple banners with custom positions and responsive layouts, driven by config placements.
* [**Advertisement → AdBlock detection**](/playgama/bridge-sdk/api/advertisement/adblock.md) — detect blocked ads and show fallback messaging.
* [**Payments**](/playgama/bridge-sdk/api/payments.md) — in-game purchases, both consumable and permanent, with a single product catalog for all platforms.

### Engagement and retention

* [**Leaderboards**](/playgama/bridge-sdk/api/leaderboards.md) — competitive score tables.
* [**Achievements**](/playgama/bridge-sdk/api/achievements.md) — milestones ("defeat the first boss").
* [**Tasks**](/playgama/bridge-sdk/api/tasks.md) — daily / weekly / permanent quests with progress tracking and rewards.
* [**Daily Rewards**](/playgama/bridge-sdk/api/daily-rewards.md) — login streak rewards.
* [**Notifications**](/playgama/bridge-sdk/api/notifications.md) — platform notifications scheduled for after the player leaves the game, to bring them back.
* [**Multiplayer (beta)**](/playgama/bridge-sdk/api/multiplayer.md) — realtime rooms on Playgama servers: invite friends by code or link, quick match, messages between players.
* [**Social**](/playgama/bridge-sdk/api/social.md) — share, invite friends, join community, add to favorites, rate the game. Free organic acquisition.
* [**Cross-Promo**](/playgama/bridge-sdk/api/cross-promo.md) — "more games" modal and games-list API to route players between your titles.

### Platform integration depth

* [**Player**](/playgama/bridge-sdk/api/player.md) — authorization state, player id, name, and avatar for personalization and server-side profiles.
* [**Device**](/playgama/bridge-sdk/api/device.md) — device type, OS, orientation events, safe-area insets for notch-aware layouts.
* [**Remote Config**](/playgama/bridge-sdk/api/remote-config.md) — platform-managed flags to tune the game without a release.
* [**Clipboard**](/playgama/bridge-sdk/api/clipboard.md) — copy/paste for invite links and promo codes.
* [**Analytics**](/playgama/bridge-sdk/api/analytics.md) — your own game events (levels, shop, economy) in Playgama analytics.
