Build your own client
The hosted web player is one client of the Player API and the play WebSocket; yours can be another. A client doesn’t need the game’s engine: the server sends each seat its view of the match and every move it may make, with labels to show them by.
All requests go to https://play.arbitas.dev. The examples use curl for the HTTP calls and C# for the socket.
1. Find the game’s player tenant
Section titled “1. Find the game’s player tenant”Each game has its own pool of player accounts, its player tenant. Ask for it by the game’s ID; no sign-in is needed:
curl https://play.arbitas.dev/v1/games/gam_…/access{ "game": "gam_…", "playerTenant": "ptn_…", "name": "Tic-tac-toe", "allowGuests": true }2. Sign the player in
Section titled “2. Sign the player in”Sign-in is the token endpoint, POST /v1/auth/token, with a form-encoded body. A player can start as a guest:
curl -X POST https://play.arbitas.dev/v1/auth/token \ -d grant_type=urn:arbitas:grant-type:guest \ -d player_tenant=ptn_… -d game=gam_… \ -d device_id=$DEVICE_ID -d birth_date=2001-04-30 -d country=GBOr with an emailed code: ask for one with POST /v1/auth/email-code (JSON: playerTenant and email), then send
the code with grant_type=urn:arbitas:grant-type:email-code, email and code. Email sign-in opens once the game has
a live version.
device_idis an opaque ID your client keeps for each install.birth_dateandcountryare needed the first time, for the age gate: a new account must be at least 13, or the country’s higher age of digital consent. The date of birth isn’t stored. Show your own question for it; the answersignupRefusednever says which age would pass.
The answer holds an access_token, which lasts 15 minutes, and a refresh_token, which lasts 30 days. Refresh with
grant_type=refresh_token; each refresh gives a new refresh token, and the old one stops working. Keep the refresh
token in the platform’s secure storage.
3. Gather players in a lobby
Section titled “3. Gather players in a lobby”With the access token as Authorization: Bearer …:
- Create a lobby with
POST /v1/lobbies: the number of seats, live or over days (live), and optionally a time control, a turn limit, variants, and whether it’s rated. - Invite others with its
inviteToken: they join withPOST /v1/lobbies/{lobbyId}/join. Sharing the token is up to your client. - The host can seat search bots in free seats with
POST /v1/lobbies/{lobbyId}/bots, except in a rated lobby. - Each player says they’re ready with
POST /v1/lobbies/{lobbyId}/ready, and the host starts it withPOST /v1/lobbies/{lobbyId}/startonce every seat is taken and ready.
Poll GET /v1/lobbies/{lobbyId} to follow it; there are no lobby updates over the socket. Once it has started, the
lobby’s match holds the match’s ID.
4. Play the match
Section titled “4. Play the match”Open the play WebSocket with the access token, subscribe to the match, and act on what arrives. In C#:
using var socket = new ClientWebSocket();socket.Options.SetRequestHeader("Authorization", $"Bearer {accessToken}");await socket.ConnectAsync(new Uri("wss://play.arbitas.dev/v1/play"), cancellationToken);
await SendAsync(socket, new { type = "subscribe", match = matchId }, cancellationToken);
// Each frame is one JSON object, sent as one text message.static Task SendAsync(ClientWebSocket socket, object frame, CancellationToken cancellationToken) => socket.SendAsync(JsonSerializer.SerializeToUtf8Bytes(frame), WebSocketMessageType.Text, true, cancellationToken);The server answers with a snapshot of the match as the player’s seat sees it, then a delta after every move. Both
carry moves when the seat can act: every legal move, complete, with a label for each choice to show the player.
Send the one they pick back as it is:
await SendAsync(socket, new{ type = "submitMove", match = matchId, clientSeq = version + 1, baseVersion = version, move = new { action = picked.Action, choices = picked.Choices.Select(c => new { step = c.Step, value = c.Value }) },}, cancellationToken);Draw the board from the seat’s view, the engine’s view of the state for that seat. The
protocol guide covers the rest: rejected moves, reconnecting with resume, the seats frame, clocks,
quick chat, and the socket closing every 15 minutes or so when the access token expires.
If you’d rather not hold a socket, as in a game played over days, the Player API has the same thing over HTTP:
GET /v1/matches/{matchId}, GET /v1/matches/{matchId}/log?since=… and POST /v1/matches/{matchId}/moves.
5. Around the match
Section titled “5. Around the match”The Player API also has what a full client needs around play, all with the same token:
- The player’s matches and whose turn it is:
GET /v1/players/me/matches. - Replays of finished matches:
GET /v1/matches/{matchId}/replay. - Matches to watch:
GET /v1/watch, for matches a host opened to spectators. - Profiles and ratings:
GET /v1/players/{playerId}/profile. - Notifications: the inbox, notification settings, and devices for push.
- Reports about another player:
POST /v1/reports. - The player’s data: export and deletion, which every client should offer.