RetiPie
SDK

SDK Overview

Call window.retipie from your game to handle pause and resume, declare leaderboards, submit scores, and report analytics. Nothing to install.

The RetiPie SDK is the runtime RetiPie adds to every game. Call window.retipie from your game code to declare a leaderboard, submit scores, pause and resume from your own UI, and report loading and gameplay. RetiPie handles the communication with the app.

Runtime surface

window.retipie = {
  game,
  leaderboards,
  analytics,
  ads,   // not active yet
  version,
};

The ads namespace exists in the runtime but isn't active yet — platform monetization hasn't launched. In the RetiPie app, calling it is safe: the returned promises resolve with completed: false and an error code instead of throwing. In the Slice preview nothing answers the request, so the promise rejects after about 75 seconds; wrap calls in try/catch. Documentation for ads will be published when they go live.

What the SDK handles

  • Freezing your game automatically when the platform pauses it, and resuming it afterwards. See Game Lifecycle.
  • Leaderboard declarations and score submission.
  • Loading progress and gameplay start, stop, and restart markers.

Using the SDK from your game

Nothing to install

RetiPie adds the SDK to every game it serves, in the Slice preview and in the feed. You don't install a package, add a <script> tag, or call an init function. window.retipie exists before your first script runs, so you don't need to wait for the page's load event.

if (window.retipie) {
  window.retipie.analytics.gameplayStart();
}

window.retipie is read-only and installed by RetiPie. Don't assign to it; code that tries to replace it is flagged during upload checks. The guard above keeps your game working when you open the same build outside RetiPie, where the object doesn't exist.

TypeScript

Copy types/retipie.d.ts into a folder your tsconfig.json includes; each release also attaches it. It types window.retipie as optional, so TypeScript reminds you to guard each call. There is no npm package.

Engine wrappers

The Unity package and the Godot addon are published in RetiPie/retipie-sdk. Both call window.retipie. For setup, see the Unity WebGL export guide and the Godot HTML5 export guide.

Using an AI coding assistant? Point it to AGENTS.md. It has the full API, a tested example for each engine and an upload checklist. These docs are also available as plain text: llms.txt lists every page, and any page opens as Markdown when you add .md to its address.

Integration checklist

  1. When the game starts, declare the leaderboard if the game has a score.
  2. While assets load, report progress from 0 to 100. If you report progress at all, finish with 100.
  3. When a run starts, call gameplay start.
  4. When a run ends, submit the score, then call gameplay stop.
  5. When the player chooses to play again, call gameplay restart, then gameplay start when the new run begins.
  6. If the game has its own pause menu, pause when it opens and resume when it closes. In JavaScript, use the SDK; in Unity and Godot, use the engine's pause (Engine notes).
StepJavaScriptUnity (C#)Godot (GDScript)
Declare leaderboardretipie.game.configure({ leaderboards: { default: { order: 'desc', unit: 'points', precision: 0 } } })RetiPieGame.ConfigureDefaultLeaderboard()RetiPie.game.configure_default_leaderboard()
Loading progressretipie.analytics.loadingProgress(percent)RetiPieAnalytics.LoadingProgress(percent)RetiPie.analytics.loading_progress(percent)
Run startsretipie.analytics.gameplayStart()RetiPieAnalytics.GameplayStart()RetiPie.analytics.gameplay_start()
Submit scoreretipie.leaderboards.submitScore(score)RetiPieLeaderboards.SubmitScore(score)RetiPie.leaderboards.submit_score(score)
Run endsretipie.analytics.gameplayStop()RetiPieAnalytics.GameplayStop()RetiPie.analytics.gameplay_stop()
Player plays againretipie.analytics.gameplayRestart()RetiPieAnalytics.GameplayRestart()RetiPie.analytics.gameplay_restart()
Own pause menuretipie.game.pause() / retipie.game.resume()Time.timeScale = 0 / Time.timeScale = 1get_tree().paused = true / get_tree().paused = false
Custom eventretipie.analytics.trackEvent(name, data)RetiPieAnalytics.TrackEvent(name, data)RetiPie.analytics.track_event(name, data)

In Unity and Godot, the calls do nothing outside a Web export running in RetiPie, so you can leave them in your code.

Next steps

On this page