Asobiai SDK

Saves

Save progress with AIGame.save and AIGame.load. Players who are logged in on Asobiai get cloud saves on their account, so they can continue on another device. Guests and embeds save in the browser.

v2.7.0Check it from your game with window.AIGame?.version.Changelog

Usage

js
// Save (to the player's account when logged in; otherwise in the browser)
await window.AIGame?.save("slot1", { stage: 3, coins: 120, items: ["key"] });

// Load (null if there is none)
const data = await window.AIGame?.load("slot1");

await window.AIGame?.listSaves();      // => [{ slot: "slot1", updatedAt, cloud: true }]
await window.AIGame?.deleteSave("slot1");
  • Data must be JSON-serializable. Up to 256 KB per slot and 10 slots per game. Slot names use letters, numbers, _ . - (max 32).
  • A copy is always kept in the browser, so it works offline too. load returns whichever of the cloud and browser copies is newer.
  • Don't save every frame (over 120 saves a minute are refused). Save on stage clear, when closing a menu, and so on.
  • Your game's own localStorage and IndexedDB also work and are kept per game (but only in that browser).

When the save format changes

New versions normally share saves with earlier versions. If you change your save format and old data would no longer work, choose "Start with fresh save data" when uploading (new_save in MCP / API). From that version on, not only AIGame.save but also the game's own localStorage and IndexedDB are kept apart from earlier versions (no code changes needed, and old data isn't deleted).