Chuyển đến nội dung
InstaPlay
Các mục hướng dẫn

The instaplay CLI: emulator, autotest and publishing

instaplay is a command-line tool: a portal emulator, a portal-like autotest, metadata checks and publishing a build with a moderation submission. It needs Node.js 22 or newer.

Installation

Install the CLI into your project instead of fetching it from the registry on the fly:

npm install --save-dev instaplay
npx instaplay --help

instaplay test needs playwright-core and its Chromium (an optional dependency of the CLI — publishing does not need a browser):

npm i -D playwright-core && npx playwright-core install chromium

Projects created with npm create instaplay-game already have the CLI and playwright-core in devDependencies (Phaser and PixiJS) — just run npx playwright-core install chromium once.

Before the npm release. The instaplay, @instaplay/sdk and create-instaplay-game packages are not in the public npm registry yet — npm install returns E404. Do not install packages with these names from other sources: that is someone else's code. Until then the InstaPlay team sends the CLI and SDK archives (.tgz) on request via support (topic “Other”); they install the same way, only from a file: npm i -D ./instaplay-cli-<version>.tgz. This page will be updated as soon as the packages are on npm.

Key and sign-in

Create a key with the “Publish” scope in the dashboard (API keys) and save it:

npx instaplay login --key ipk_… --api https://<portal>/api/v1
npx instaplay whoami   # the studio, whether it is trusted, the key scopes

The key is stored in ~/.config/instaplay/credentials.json. In CI set the INSTAPLAY_API_KEY and INSTAPLAY_API_URL environment variables — they take precedence over the file.

Commands

Command What it does
dev [folder] the portal emulator at http://localhost:4300: the game on a separate origin, the SDK, games domain headers with the game network, a panel — player, pause, sound, locale, offline, failures, saves, leaderboards, player token, country, test ads; --url <dev server> — the game from a dev server instead of a folder, --game-id <id> — the token aud, --https — the emulator over https, --allow-local-network — a local game server in the network (below)
test [folder] headless Chromium over the emulator on desktop and mobile: init, ready, JS errors, external requests, blank frame, page scrolling (R13), gameplay after input, build file types (S09, as on the portal); --script smoke.mjs — your own scenario; the network follows the production rules, --allow-local-network — as in dev
check [folder|zip] the instaplay.json metadata threshold, category and tags against the portal reference list (M03 — the only step that uses the network), leaderboards, archive, cover, game network (M04 — address rules, wildcards, privacy policy domain); --offline — without network: everything except M03 (publish checks the category and tags)
publish <folder|zip> uploads the build and waits for automated checks; --submit — then a moderation submission
status [folder|buildId] checks of the latest build and the state of the latest submission
publish-batch <manifest.json> check and publish for several games with a report

Engine builds

dev and test take an export folder as is — they do not need instaplay.json. The engine is guessed from the files; the --engine unity|godot|construct|html and --entry <page> flags take precedence.

Engine Detected by What the CLI checks
Unity WebGL Build/*.loader.js Brotli without “Decompression Fallback”
Godot 4 *.pck and *.wasm export without Thread Support
Construct 3 scripts/c3main.js or c3runtime.js offline support turned off

The emulator serves *.br and *.gz files the same way as the games domain (compression).

Is the SDK included. Either a /_ip/sdk/v1.js tag in the page HTML or an init call over the bridge counts: an engine may load the SDK itself (document.createElement('script')). Without the tag dev waits for init after the game loads and prints “The page does not include the SDK” only if it does not arrive within 20 s; test reports the E01 warning only if no profile received init.

Network, dev server and token in the emulator

  • Network. The emulator takes network from instaplay.json and builds the same CSP as the games domain, by the same rules as moderation (M04): what works in the emulator passes on the portal too. An invalid network means a CSP without it (codes in the terminal). Like the games domain, the emulator refuses Service Workers (403) (game network).
  • Local game server. instaplay dev --allow-local-network (and instaplay test with the same flag) lets localhost, 127.0.0.1 and [::1] addresses from network into the emulator CSP — with a port and the http/ws schemes (for example http://localhost:8080, ws://localhost:8080), with a “will not pass on the portal” warning. Without the flag such addresses are not applied (a hint about the flag is printed). Moderation and instaplay check still reject them: to publish you need a server on a DNS name with https/wss. Other private addresses (10.…, *.local) are not allowed even with the flag.
  • HTTPS. The portal serves games over https, the emulator over http by default. So a protocol-relative address (//api.example.com) becomes http: in the emulator and the CSP blocks it, while on the portal it would become https: and pass. instaplay dev --https runs the emulator portal and “games domain” over https with a self-signed certificate (created on every start, never written to disk): open the game address printed by the CLI first and accept the certificate, then the portal (the browser does not ask inside a frame). Without --https the emulator prints CSP violations to the terminal, and a request to http://<host from network> comes with a hint about //address and --https.
  • Dev server. instaplay dev --url http://localhost:5173/ — the game from a Vite (or similar) dev server: the emulator proxies the page and root paths (except /_ip/ and /_emu/), applies the games domain headers and adds the dev server origin (http: and ws: for hot reload) to connect-src only in this mode. Build for publishing with relative paths (base: './').
  • Player token. The emulator signs tokens with its own dev key: JWKS — /_emu/jwks.json, iss — the emulator origin, aud — --game-id <dashboard id> or dev:<game slug>, sub — player.id of the panel player. The values are printed at start; the panel switches “issued”, “unavailable”, “expired” (player token).
npx instaplay dev ./dist --game-id 0193a1b2-7c4d-7e5f-8a9b-0c1d2e3f4a5b
# Player token: JWKS http://localhost:4300/_emu/jwks.json, iss http://localhost:4300, aud 0193a1b2-…

Publishing

npx instaplay publish ./my-game --submit --note "First version"
npx instaplay status ./my-game   # pending → in_review → approved → published

Submission states: pending (waiting for a moderator) → in_review (a moderator took it) → approved → the game is published; a moderator may send it back for changes (changes_requested — fix and submit again with --submit) or reject it (rejected, the reason is in the email and the dashboard). You can withdraw your submission in the dashboard (withdrawn) (Moderation).

  • The build updates the game draft (texts, images, leaderboards from instaplay.json). Until the first approval the game address is draft-…; the address from instaplay.json is fixed on approval. The CLI prints a link to the game in the dashboard.
  • Which game the CLI updates. The studio's game with the slug from instaplay.json — the published address or the “Game address” in the draft. A game created in the dashboard gets the CLI build if it has the same address; otherwise the CLI creates a new game (Dashboard).
  • --submit sends a moderation submission after the checks; a build with warnings needs --acknowledge-warnings. Without --submit you can submit in the dashboard.
  • Repeating the same build does not create a second one: the default idempotency key is pub-<address>-<zip hash>. Changed instaplay.json with the same zip — repeat with --idempotency-key <new>.
  • Submission: the idempotency key is new on every run, so --submit after revising or withdrawing the previous submission sends a new one; the portal does not accept a second open submission (submission_open).
  • Trusted studios (the platform grants this status) are published right after the checks, without a submission. The exception is a new code origin in network.script (External code): the CLI says a submission is needed, the build updates the draft, and --submit sends the submission; without --submit the exit code is 1 — the version was not released.

Errors

Answer What to do
scope_missing the key lacks the “Publish” scope — create a new key
401 the key is wrong or revoked, or the studio is banned
contact_unverified verify the studio contact email (Dashboard)
warnings_unacknowledged repeat with --acknowledge-warnings
submission_open the game already has an open submission — wait for the decision
slug_ambiguous the studio has two games with this address in their drafts — change the address of the extra one in the dashboard or the slug in instaplay.json
slug_taken the address belongs to another studio's game — change the slug in instaplay.json
quality_failed texts or images are below the threshold — instaplay check shows the fields
idempotency_key_reused metadata changed for the same build — repeat with --idempotency-key <new>

Exit codes: 0 — success, 1 — a check failed or the submission was not accepted, 2 — a startup error (key, network, metadata).