Hosted games: players and saves

What this is

A game that is only a web page can use Arena54 as its backend: Identity (a player agrees once and your game learns their display name), Saves (a few named values per player) and Leaderboards and achievements. None of those carries anything of value. Items, transfers, the pass, selling and play time follow further down, and a ledger and an exchange have their own guide. Each module has its own switch on Arena54’s side, and the developers page shows which are open today.

1. Register the game

  1. In the dashboard, open Your games and register it. Tick Hosted, Identity and Saves.
  2. Under Where the game runs, list its addresses, for example https://play.example.com and http://localhost:5173.
  3. Create a publishable test key for it. It starts with a54_pub_test_ and may sit in your page.

2. A sample player

With a test key you get a sample player without anyone signing in.

JavaScript, in your page
const API = "https://developers.arena54.com/api/v1/play";
const KEY = "a54_pub_test_…";

const { data } = await (await fetch(API + "/test-token", {
  method: "POST",
  headers: { Authorization: "Bearer " + KEY },
})).json();
const player = data.token;   // send this as X-Arena54-Player

3. Save and load

JavaScript
const headers = { Authorization: "Bearer " + KEY, "X-Arena54-Player": player };

await fetch(API + "/saves/slot-1", { method: "PUT", headers, body: JSON.stringify({ level: 3, coins: 120 }) });

const save = await (await fetch(API + "/saves/slot-1", { headers })).json();
console.log(save.data.value);   // { level: 3, coins: 120 }
MethodPathPurpose
POST/v1/play/test-tokenA sample player. Test keys only
GET/v1/play/meWho the token is: id, name, when it expires
DELETE/v1/play/meThe player erases themselves from this game: saves, scores, achievements, items and the connection
DELETE/v1/play/players/{id}Erase one player: saves, scores, achievements, their connection. Their ledger account is unlinked
GET/v1/play/visitFor the game being visited: the player’s open visit and where they came from, or null
POST/v1/play/visit/endFor the game being visited: say the visit is over
GET/v1/play/visitsFor the home game: where this player went, and whether each visit is over
POST/v1/play/beatSay the player is still playing. Call it about once a minute. Arena54 counts the time by its own clock
GET/v1/play/playtimeHow long this player has played this game, and when they last played
POST/v1/play/players/{id}/beatThe same, from a game’s server that keeps track of its own players
POST/v1/play/hoursTotals a game counted itself: one call for up to 500 players, a row a player a day. Sending a day again replaces it
GET/v1/play/savesThe player’s saved values: names and sizes
GET/v1/play/saves/{key}One value
PUT/v1/play/saves/{key}Write one value. Any JSON
DELETE/v1/play/saves/{key}Remove one value

A save’s name is 1 to 64 letters, digits, dots, dashes or underscores. Test saves and live saves are kept apart.

4. Real players

With a live key, send the player to Arena54 to agree. They come back to your page with a token in the address’s fragment.

JavaScript
// Send them. `redirect` must be inside an address you registered.
location.href = "https://arena54.com/play/authorize?game=YOUR-GAME-SLUG"
  + "&redirect=" + encodeURIComponent(location.origin + "/")
  + "&state=" + crypto.randomUUID();

// When they return:  https://your-game/#a54_token=a54p_…&state=…
const back = new URLSearchParams(location.hash.slice(1));
const player = back.get("a54_token");
history.replaceState(null, "", location.pathname);   // take the token out of the address bar
  • The player sees your game’s name, what it will learn (a display name and an id only your game sees) and where they will be sent.
  • A token lasts two hours. When it is refused, send the player through the same address again. They see the same screen and press the button once more.
  • A player can disconnect your game at arena54.com/play/connections. The next call answers 401 player_revoked.

5. Leaderboards

Tick Leaderboards and achievements for the game, then list its boards in the dashboard, one per line: an id, a name, whether high or low wins, the largest score you accept, and who reports it.

In the dashboard
high-score | High score | high | 1000000 | page
fastest-lap | Fastest lap (ms) | low | 600000 | server
JavaScript
// Report a score. The player’s best is kept; a worse one changes nothing.
const r = await (await fetch(API + "/boards/high-score", { method: "POST", headers, body: JSON.stringify({ score: 4200 }) })).json();
console.log(r.data);   // { improved: true, best: 4200, rank: 7 }

// Show the top ten. This works before anyone signs in; with a player token it also says where they stand.
const top = await (await fetch(API + "/boards/high-score?limit=10", { headers })).json();
console.log(top.data.top, top.data.me);   // [{ rank, player, name, score, verified, at }], { best, rank }
MethodPathPurpose
GET/v1/play/boardsThe game’s boards
GET/v1/play/boards/{id}The top scores, 10 unless you send limit (more than 100 is treated as 100). No player needed
POST/v1/play/boards/{id}Report {"score": n}: a whole number from 0 to the board’s largest
GET/v1/play/achievementsThe game’s achievements, and which the player has. Needs a player token
POST/v1/play/achievements/{id}Unlock one. Twice is the same as once

A score reported by a page can be forged, because the page runs on the player’s device. Each row says so: verified is true only when your own server reported it with a secret key. If a board matters, mark it server and it refuses a publishable key with 403 server_only. A game with no server can keep the damage small with a sensible largest score. A player who disconnects the game leaves its boards at once.

A board marked replay believes only a replay: send {"score": n, "replay": {"v": 1, "seed": …, "inputs": […]}} and Arena54 re-runs your game’s rules on its own servers. The row is checked only when the replay gives the same number; otherwise reason says why. This needs a replay engine for your game on Arena54. Write to us if your game is deterministic from a seed and its inputs.

6. Achievements

List them in the dashboard the same way: an id, a name, a description, and who unlocks it.

In the dashboard
first-win | First win | Win a round | page
JavaScript
await fetch(API + "/achievements/first-win", { method: "POST", headers });   // { slug, name, new: true } the first time

const all = await (await fetch(API + "/achievements", { headers })).json();
console.log(all.data);   // [{ slug, name, description, writer, unlocked_at }]

Unlocking twice is the same as once. Both calls need a player token. Test and live are kept apart, as with saves.

7. Erasing a player

When a player asks you to delete their data, call this from your server with the game’s secret key. It needs no module ticked.

Your server
await fetch("https://developers.arena54.com/api/v1/play/players/" + playerId, { method: "DELETE", headers: { Authorization: "Bearer " + process.env.ARENA54_SECRET_KEY } });
// → { player, removed: { saves, scores, achievements, connection, ledger_accounts_unlinked } }
  • It removes the player’s saves, scores, achievements and the record that they connected. Calling it again removes nothing and still answers 200.
  • A ledger cannot forget a movement, because its rows are never changed and the books must still add up. The player’s account is unlinked instead: its owner becomes a random label and it is frozen, so no account or row names the player.
  • Not removed, because nothing can remove it: anything you wrote into a movement’s meta or into your audit log. Do not put a name, an email or a phone number there.
  • A live key erases the live player. A test key erases test data.

8. Items and entitlements

An item is something a player owns in your game: a skin, a trophy, a season pass. Tick Items and entitlements, list your items in the dashboard (an id, a name, a description), and grant them from your server. This module has its own switch on Arena54’s side; while it is off, these calls answer 503 module_off.

MethodPathPurpose
POST/v1/play/checkoutStart the purchase of an item at its own price. Answers the address of Arena54’s checkout page. Test keys only for now
GET/v1/play/checkout/{id}Whether one purchase or tip by this player is open, paid, cancelled or refunded
POST/v1/play/tipsStart a tip from the player to your game, of an amount they choose. Answers the address of the checkout page
GET/v1/play/itemsThe game’s items, and which the player owns
GET/v1/play/entitlements?game={slug}: what this player owns in another game, if they chose to share it
PUT/v1/play/players/{id}/items/{item}Grant an item to a player. Twice is the same as once
DELETE/v1/play/players/{id}/items/{item}Take an item back
GET/v1/play/players/{id}/itemsWhat one player owns
POST/v1/play/players/{id}/items/{item}/transferMove an item the player owns to another game, along a route both makers agreed. It leaves this game
Your server
const headers = { Authorization: "Bearer " + process.env.ARENA54_SECRET_KEY };
await fetch("https://developers.arena54.com/api/v1/play/players/" + playerId + "/items/gold-helmet", { method: "PUT", headers });
// → { player, item: "gold-helmet", new: true }
  • Only your server grants an item. A page can read what its player owns and can never write it, so owning an item is always a server’s word.
  • Another game can honour your items. It calls GET /v1/play/entitlements?game=your-slug with its own player’s token and gets the items that same person owns in your game.
  • Only if the player chose to. Sharing is off until the player turns it on for your game at arena54.com/play/connections. Two games know one person by two different ids, and neither learns the other’s.
  • A shared look. Each item carries look. It is null until the item’s maker attaches a picture (and a .glb model, if they have one) in the dashboard and a person at Arena54 approves it. Then it is { picture, model, kind, colour, rarity }, so the game honouring the item can show the very thing. A look says how an item appears. It grants nothing: owning is what the list says. Shared looks have their own switch on Arena54’s side, and while it is off every look is null.
  • An empty list means nothing to honour. It is the same answer for a player who does not play that game, has not shared it, or owns nothing there, so do not read more into it.
  • What your game gives for another game’s item is your own rule. Arena54 moves nothing of value between games here.

9. Moving an item to another game

Honouring leaves the item where it is. A transfer moves it: the player stops owning it in your game and starts owning its match in the other. Item transfer has its own switch on Arena54’s side; while it is off the call answers 503 module_off.

MethodPathPurpose
POST/v1/play/players/{id}/items/{item}/transferMove an item the player owns to another game, along a route both makers agreed. It leaves this game
Your server
await fetch("https://developers.arena54.com/api/v1/play/players/" + playerId + "/items/yellow-bus/transfer", {
  method: "POST",
  headers: { Authorization: "Bearer " + process.env.ARENA54_SECRET_KEY, "Content-Type": "application/json" },
  body: JSON.stringify({ to: "other-game-id", ref: "order-8841" }),
});
// → { transfer, player, item: "yellow-bus", to: "other-game-id", moved: true, replay: false }
  • Nothing is transferable until both makers say so. In the dashboard you offer that one of your items may go to another game. Its maker accepts by choosing which of their own items arrives. Either of you can close the route.
  • The player must have agreed. They are connected to both games and have turned on sharing for yours at arena54.com/play/connections.
  • All or nothing. The item leaves your game and arrives in the other together, or neither happens. If the player already owns the match there, nothing moves.
  • Send your own ref. The same reference twice is one move, answered with replay: true, so a retry after a timeout is safe.
  • 409 cannot_transfer is one answer for four reasons: the player does not own the item, already owns its match there, does not play that game, or has not turned on sharing. You are not told which, so a game cannot learn where its player plays.
  • A player may move a set number of items out of a game in a day. Past it the call answers 429 transfer_limit.
  • Each game’s audit log gets its own entry, with its own id for the move and its own id for the player. The two games are never given each other’s.
  • A test key checks that the route is agreed and moves nothing: it answers moved: false, test: true.
  • There is no undo call. To send an item back, the two makers agree a route in the other direction.

10. A visit to another game

A player in your game can visit another listed game and arrive already signed in. They see one screen on Arena54 that says what the other game will learn, and nothing is sent until they agree. Visits have their own switch on Arena54’s side; while it is off these calls answer 503 module_off.

MethodPathPurpose
GET/v1/play/visitFor the game being visited: the player’s open visit and where they came from, or null
POST/v1/play/visit/endFor the game being visited: say the visit is over
GET/v1/play/visitsFor the home game: where this player went, and whether each visit is over
The home game’s page
location.href = "https://arena54.com/play/visit?from=your-game-id&to=other-game-id"
  + "&redirect=" + encodeURIComponent("https://other-game.example/play")
  + "&state=" + encodeURIComponent(yourOwnValue);
The visited game’s page, after the player lands
// The address ends with #a54_token=…&a54_visit=…&from=your-game-id&state=…
const visit = await fetch("https://developers.arena54.com/api/v1/play/visit", { headers }).then((r) => r.json());
// → { visit, from: { slug, name }, brought_items, agreed_at, arrived_at }, or null
await fetch("https://developers.arena54.com/api/v1/play/visit/end", { method: "POST", headers }); // when they leave
  • The player must already play the home game. A visit starts from a game they are connected to, goes only to an address the other game registered, and both games must have Identity ticked.
  • Two ids, never joined. Each game gets its own id for the player and its own id for the visit. Neither is told the other’s.
  • What is brought is what was ticked. If the player ticks the box, the visited game can read what they own at home through /play/entitlements. Nothing moves.
  • The home game can see how it went. GET /play/visits lists where the player went and whether each visit is started, arrived, ended or expired. A visit nobody ended expires by itself.
  • Erasing a player in either game removes their id from that game’s side of every visit.
  • A test key sees no visits: a sample player is nobody in another game.

11. Selling an item

An item with a price can be bought through Arena54’s checkout, so your game holds no card form and no payment code. With a test key the whole purchase works and no money is taken. With a live key the purchase is real. If real payments are closed, a live key answers 503 payments_not_open and takes nothing.

MethodPathPurpose
POST/v1/play/checkoutStart the purchase of an item at its own price. Answers the address of Arena54’s checkout page. Test keys only for now
GET/v1/play/checkout/{id}Whether one purchase or tip by this player is open, paid, cancelled or refunded
POST/v1/play/tipsStart a tip from the player to your game, of an amount they choose. Answers the address of the checkout page
Your page
const buy = await fetch("https://developers.arena54.com/api/v1/play/checkout", {
  method: "POST", headers: { ...headers, "Content-Type": "application/json" },
  body: JSON.stringify({ item: "gold-helmet", redirect: location.origin + "/shop" }),
}).then((r) => r.json());
location.href = buy.data.url;
// The player comes back to /shop#a54_sale=<id>&status=paid (or cancelled).
// Confirm with GET /play/checkout/<id> before you show the item.
  • The price is Arena54’s. Put it on the item’s line in the dashboard: id | name | description | price, in whole naira. A price is never taken from a page.
  • Confirm before you trust. The address the player returns to can be typed by anyone. Ask GET /play/checkout/{id}, or read the player’s items, before showing what was bought.
  • A paid test purchase gives the sample player the item, in test data only.
  • Tips. POST /play/tips with { amount, redirect } opens the same checkout for an amount the player chooses, in whole naira within the price range. Nothing is granted for a tip. Confirm it the same way, with GET /play/checkout/{id}.
  • Your dashboard lists every sale and your share of it. Test purchases are marked and never count towards a payout.
  • The share, the price range, the payout day and the minimum are on the pricing page.

12. Play time

Arena54 can count how long each player spends in your game and show it to them, as game libraries do. Play time has its own switch on Arena54’s side; while it is off these calls answer 503 module_off.

MethodPathPurpose
POST/v1/play/beatSay the player is still playing. Call it about once a minute. Arena54 counts the time by its own clock
GET/v1/play/playtimeHow long this player has played this game, and when they last played
POST/v1/play/players/{id}/beatThe same, from a game’s server that keeps track of its own players
POST/v1/play/hoursTotals a game counted itself: one call for up to 500 players, a row a player a day. Sending a day again replaces it
Your page
// About once a minute while the player is in the game, and the tab is in front.
setInterval(() => {
  if (document.visibilityState === "visible") fetch("https://developers.arena54.com/api/v1/play/beat", { method: "POST", headers });
}, 60_000);
  • You never send a duration. Each call adds the time Arena54’s own clock says has passed since the last one, up to a minute and a half. Calling more often adds nothing extra.
  • A silence longer than that starts a new sitting, and the gap is not counted. So stop calling when the player is away.
  • A game that never calls shows no hours for its players, which is different from zero.
  • The player sees their hours per game at arena54.com/play/connections. Only they see them.
  • Your dashboard shows, for each game, how many players have played, the hours in all, and the middle sitting.
  • A game whose own server knows who is playing can call POST /play/players/{id}/beat with its secret key instead. The same clock rule applies.
  • A game that counts its own players’ time, such as a city, can send totals instead: POST /play/hours with its secret key and { "players": [{ "id": "pl_…", "day": "2026-10-13", "seconds": 5400 }] }, up to 500 rows a call. One call an hour covers every player. A day sent again replaces the earlier figure, so a repeat is harmless.
  • A total is refused, row by row, when it is more than 86,400 seconds, more than has passed of today, in the future, or older than two days. Days are Africa/Lagos. A player who is not connected to your game is skipped and named in the answer. Use totals or beats for a game, not both: totals replace what beats counted.
  • A test key is answered and nothing is counted. Erasing a player removes their time.

Limits and refusals

CodeStatusWhen
origin_not_allowed403The page’s address is not one the game registered
module_not_enabled403The module is not ticked for this game
module_off503Arena54 has switched the module off
invalid_player401No token, an expired or altered one, or one for another game or mode
player_revoked401The player disconnected the game
test_only403A sample player was asked for with a live key
server_only403The board or achievement takes writes only from a secret key
bad_score400The score is not a whole number from 0 to the board’s largest
too_large413The value is over your plan’s size for one save
too_many409The player already holds your plan’s number of saves. Replacing one still works
bad_key, bad_json400The save’s name or the body is not acceptable
rate_limited429Too many calls this minute, for the key or for one player

How many saves a player may hold, how large each may be, and how many boards and achievements a game may have come from your plan. See pricing.

What a page can never do

A page runs on the player’s device, and a player can change what it sends. So a token reaches only its own player’s saves, and nothing here grants anything of value. Do not keep a balance or an unlock in a save and trust it: a player can write their own saves. The same holds for a score or an achievement a page reports. Currency and items will come through the ledger, where a page cannot mint by asking.