Skip to main content
The platform injects window.Turntable into your game document before your code runs. All Promise-returning calls resolve to null (never reject) when something is unavailable — your game should degrade gracefully, not crash.

Identity

Turntable.player

{ handle: string, isMember: boolean } | null
The current player. Guests have handles too (e.g. player4821); isMember is true for signed-in accounts. Use it for greeting and personalization:
if (Turntable.player) {
  title.textContent = 'Ready, @' + Turntable.player.handle + '?';
}

Scores

Turntable.submitScore(score)

Report a finished round’s score (a number). Drives the feed UI (“Your last score”), player stats, best-score tracking, and achievements. Call it every time a round ends.

Persistent state

Per-player, per-game JSON storage. Survives app restarts — and the guest-to-member account merge, so nothing is lost when a guest signs up.

Turntable.saveState(state)Promise

Persists a JSON object. Hard cap 32KB (keep under 8KB); 600 writes/hour.

Turntable.loadState()Promise<object | null>

Resolves the saved object, or null on first play — always handle null.
var best = 0;
Turntable.loadState().then(function (s) {
  if (s && s.best) { best = s.best; showBest(best); }
});
// later, when a run beats it:
if (score > best) { best = score; Turntable.saveState({ best: best }); }

Economy

See Economy for the full model. In brief:

Turntable.wallet.balance()Promise<number | null>

The player’s platform-wide coin balance.

Turntable.shop.listItems()Promise<Item[]>

Your game’s purchasable items (defined by the game’s creator). Loot-box items include their drop odds — odds are always public.

Turntable.shop.purchase(itemId)Promise<result>

Requests a purchase. The player approves or declines in native UI your game can’t touch; the promise resolves with { status: "approved" | "declined" | "expired" | "error", granted?, newBalance?, error? }. Never assume success.

Turntable.inventory.list()Promise<OwnedItem[]>

What this player owns in your game ({ itemId, name, source, acquiredAt }[]).