Ir para o conteúdo
InstaPlay
Seções da documentação do SDK

SDK changelog

The SDK follows SemVer: /_ip/sdk/v1.js is the latest release of major 1 (backward compatible fixes arrive automatically), /_ip/sdk/v1.<minor>.<patch>.js is a pinned version. The bridge protocol (ip) is versioned separately; the portal supports the current and the previous one.

1.4.0 — November 2026

Sign-in from the game. The ip: 1 protocol does not change — games on 1.0–1.3 keep working; the pinned /_ip/sdk/v1.0.0.js, v1.1.0.js, v1.2.0.js and v1.3.0.js stay available, and /_ip/sdk/v1.js is now 1.4.0.

  • InstaPlay.player.login() — the portal sign-in window over the game (the counterpart of CrazyGames user.showAuthPrompt()): Google, VK ID, Yandex ID (if configured on the portal) and email with a one-time code. Outcome LoginResult: signed_in (with player), already_signed_in (with player, no window), cancelled.
  • The first sign-in upgrades the guest to an account in place: the same player.id, pseudonym and saves, the game goes on without a restart; the getToken() cache is dropped, the next token has kind: account. A sign-in to an existing account gives a different player.id: then playerChanging { reason: 'login' } and a restart in about 1.5 s.
  • Only on a player gesture (click, tap, key) — otherwise the new gesture_required error code; at most 3 times a minute (rate_limited); one window at a time — a repeated call returns the same promise; the window closes after 15 minutes (cancelled), the call timeout is 16 minutes. While the window is open — pause with the overlay reason, then resume.
  • Errors: not_supported (outside the portal, preview), unavailable (no sign-in methods or the API is unavailable), gesture_required, rate_limited, not_initialized, timeout.
  • The login capability — isSupported('login'); the reserved name authorize is now its alias (it used to be always false).
  • The instaplay dev emulator: a “Sign-in from the game” window with “Sign in as a test player” and “Cancel” buttons.
  • Reference — Player, the guide with examples and the CrazyGames SDK mapping — Player and sign-in. Engine wrappers for Unity, Godot and Construct 3 — 1.3.0 (sign-in).

1.3.0 — November 2026

Ads. The ip: 1 protocol does not change — games on 1.0–1.2 keep working; the pinned /_ip/sdk/v1.2.0.js stays available.

  • InstaPlay.ads.interstitial({ placement, moment }) — a full-screen ad in a natural break (between levels); result { shown, reason }. During gameplay — reason: 'gameplay_active'.
  • InstaPlay.ads.rewarded({ placement }) — a rewarded ad: the portal asks the player itself (“Watch an ad for a reward?”), the reward comes only after the ad is watched; result { rewarded, reason, grant }, grant.token is a signed ip-reward+jwt JWT (aud: reward:<game id>) for your server.
  • InstaPlay.ads.available(type) — whether an ad can be shown now (portal frequency limits).
  • Regular outcomes (no ad, cooldown, the player declined) do not reject the promise; outside the portal — reason: 'disabled'. While the ad is shown the game gets pause { reason: 'ad' } and mute; sound turned off by the player stays off. Capability — isSupported('ads').
  • Reference — Ads, the guide with reward verification on your server — Ads in your game. Engine wrappers for Unity, Godot and Construct 3 — 1.2.0 (ads).

1.2.0 — November 2026

The ip: 1 protocol does not change — games on 1.0 and 1.1 keep working; the pinned /_ip/sdk/v1.1.0.js stays available.

  • init() returns country — the player country (ISO 3166-1 alpha-2) or null. The field already existed in the bridge protocol; currently the portal does not pass the country (null), and outside the portal it is always null. How to pick a server region — Game network.
  • playerChanging: a guest replaced by another guest is now switch (was logout); logout is only a sign-out from an account. The reasons are the same on the portal and in the emulator (there “Player A → Player B” is switch).

1.1.0 — November 2026

Games with their own server (the ip: 1 protocol does not change — games on 1.0 keep working):

  • InstaPlay.player.getToken() — a player token signed by the portal (JWT ES256, 10 minutes) for your own server; cached until a minute before expiry; the token feature (isSupported('token')).
  • init() returns session: ok — a real player, none — no session (player is the p_guest stub), local — outside the portal. Without ok do not use player.id as a key.
  • Initial sound and pause: InstaPlay.system.muted and InstaPlay.system.pause — from init, then by the mute/unmute, pause/resume events.
  • The playerChanging { reason: 'login' | 'logout' | 'switch' } event about 1.5 s before the game restarts when the player signs in or out in another tab (a guest who became an account — also login).
  • The Feature type knows token, ads, shop, authorize (the last three are false until the purchases and ads phase).
  • Analytics: a batch not accepted because of the network, a timeout, a limit or unavailability goes back to the buffer (retry 1 → 60 s, the buffer keeps the last 200 events); it is dropped only on a data error.
  • Lifecycle notifications limit — 120 per minute; a repeated gameplay.start/gameplay.stop of the same state does not spend it.
  • The frame URL parameters instaplay_origin and instaplay_locale are a stable contract.

Saves and more:

  • Two tabs of one browser: the version a key is written from comes from the memory of this page load (what it last received from the server), not from the buffer shared by tabs. A stale tab loses to the cloud: set → version_conflict, its local version goes to __ip:orphan:<key>, the key "must be read". Between devices — as before.
  • A pause of any reason (portal window, sign-in, an ad) sends the save buffer immediately — like a hidden tab.
  • Player: kind: 'account' for a signed-in player, the nickname they chose and avatar — an image path on the game origin. Signing in or out in another tab restarts the game.
  • Saves: a local version never checked against the server (no get, after a failed get, without a session) no longer overwrites the cloud on conflict — the server wins, set rejects with version_conflict, the local one goes to __ip:orphan:<key>. A checked one still wins.
  • saves.get without a server answer and without a local copy rejects (unavailable/offline) instead of returning null.
  • The save buffer is bound to the player: if the guest changes in the same browser (cookies cleared or blocked, a shared computer), the other player's buffer is neither sent nor returned to the game — it goes to __ip:orphan:<key>, and the previous player's cloud is left untouched.
  • Strings with \u0000 and lone surrogates — invalid_payload at once; data errors are not retried; at most 20 timer retries per page load (then online, hiding the tab, flush, the next init).
  • An exception in onConflict falls back to the default behaviour instead of a hanging write.
  • Analytics: property keys are ^[A-Za-z_][A-Za-z0-9_]{0,39}$, as on the server; level of level.* is not lost with 10 properties.
  • Local mode: leaderboard periodStart is a YYYY-MM-DD date, as on the portal.
  • Saves (re-review): "the local version wins" and force apply only when the server confirmed the version the write grew from during this page load. A copy from a previous load or another tab never destroys the cloud: if the cloud has not changed, the write succeeds; if it has, the cloud wins.
  • New field SaveEntry.confirmed: true — the server answered during this load, false — a copy from the device (the cloud did not answer). Always true in local/disabled modes.
  • After losing on send, the key "must be read": set before a get of that key rejects with version_conflict.
  • Only data errors are not retried (invalid_payload, payload_too_large, quota_exceeded, message_too_large); internal_error and unknown codes are retried.
  • Without a session remove/clear reject with unavailable and touch nothing; __ip:orphan:<key> lives for 30 days and is removed first when storage is full.

1.0.0 — November 2026

  • The script from the game origin: /_ip/sdk/v1.js (+ v1.d.ts types), npm @instaplay/sdk (preview).
  • init, loading.progress, ready, gameplay.start/stop, game.happyMoment, level.*.
  • player.get — a guest with a player×studio pseudonym.
  • saves.* — cloud saves with versions, an offline buffer and conflicts.
  • leaderboard.submit/get — day/week/all-time periods (MSK), player rank.
  • analytics.event/flush — batched events.
  • Portal events: pause, resume, mute, unmute, visibility, localeChanged.
  • Bridge protocol ip: 1.