net_backend

API reference

The complete HTTP + WebSocket + JSON API of a net_backend_server server, for clients that talk to it directly: web pages, JavaScript / TypeScript, C#, GDScript, Python, anything with an HTTP and a WebSocket library.

Rust clients have ready-made libraries that already speak everything below:

Your client is… Use
a Rust app net_backend_client + net_backend_protocol
a Bevy game bevy_net_backend + net_backend_protocol
other Rust code net_backend_protocol + any HTTP / WebSocket library
anything else this document

1. Overview#

A net_backend_server is a game backend you run yourself. Every server built with the framework speaks the same API; which parts are present depends on the modules the server registers. The reference server (the one the repository's deployment files install) registers every module below; a game's own server registers the modules it uses:

Module What it adds
core GET /v1/info, /healthz, /readyz, the WebSocket endpoint /v1/ws, the API documents
auth accounts, logins (email + password, Steam), tokens, sessions, email verification, password reset, roles, admin routes
storage per-player JSON objects (save slots, settings) with versions; other players read the public ones (and the owner's friends the friends ones)
chat public rooms, direct messages, history, presence, moderation, message editing, read markers and unread counts, typing indicators, rooms created by players (owner / moderators, public or private, invitations, kicks)
leaderboards boards (best / latest / sum scores; all-time, daily or weekly), score submission, the top, the player's rank and the ranks around it
notifications notifications stored per player and pushed live (notify.new), read / unread, deletes, a retention
friends friends by account: requests by account id, display name or friend code, accept / decline / cancel / remove, blocks, the friends' online state (friends.presence); with Steam login, which of a list of Steam IDs belong to accounts here (for players who linked Steam), with a per-player opt-out
groups groups (guilds, clans): create, invitations, open groups, join / leave / kick, roles (owner, admin, member), ownership transfer, metadata, a name search, a group chat room
files players' binary files (screenshots, replays, mods, levels): multipart uploads with a content type, a SHA-256 and quotas, downloads, a visibility (private, public, friends, shared with chosen accounts), metadata
oauth logins with an OpenID Connect provider's ID token (Google, or any OpenID Connect provider the operator configures), linked to the accounts
lobbies lobbies: create, join by id or join code, leave, kick, a new host, ready flags, metadata, visibility (public / private / friends-only), state (open / in game / closed), a search by metadata, live pushes to the members (lobby.member, lobby.changed), a lobby chat room
matchmaking queues and tickets; matches made by the server's rules (the game's, or first come, first matched), told to the players (match.found, match.expired)

GET /v1/info lists the modules a server runs. A game's own server may add its own routes and WebSocket kinds on top; they follow the same conventions and appear in the server's API documents.

Base URL#

Throughout this document the server is https://your-server.example. Every API path starts with /v1/ (two health routes do not). WebSocket: wss://your-server.example/v1/ws.

Production servers run behind a reverse proxy that terminates TLS: use https:// and wss://.

Versioning#

  • Paths: /v1 is stable: within /v1 routes, fields and WebSocket kinds keep their names and stay.
  • Protocol version: an integer, 1. A client may name the version it speaks in the x-net-backend-protocol header (HTTP requests and the WebSocket handshake) or in the protocol field of the WebSocket auth message. Without it the server assumes 1. Every HTTP answer (except CORS preflights) carries the server's own version in the same header, and GET /v1/info lists the accepted range:
json
{"protocol":1,"min_protocol":1,"modules":["auth","chat","storage"]}
  • An unsupported version is refused with unsupported_protocol and the details {"supported_min":1,"supported_max":1}: HTTP 400 on normal routes; on /v1/ws never 400 (see Version mismatch).

Machine-readable documents#

Document Where What
OpenAPI 3.1 GET /v1/openapi.json every documented HTTP route with its request and answer schemas; feed it to an OpenAPI generator for typed clients (TypeScript, C#, …)
AsyncAPI 3.0 GET /v1/asyncapi.json the WebSocket endpoint: the envelope, auth / auth.ok / auth.failed, every request kind with its answer, every push, the close codes (also as x-close-codes)
Browser UI GET /v1/docs an interactive viewer of the OpenAPI document, only when the operator enables it

The operator decides whether the documents are public (openapi.enabled, on by default). The admin routes are left out of the OpenAPI document unless the operator lists them (admin_in_openapi in the auth and storage module settings). This document covers all of them.

Health#

Route Answer
GET /healthz 200 {"status":"ok"} while the process runs (liveness)
GET /readyz 200 {"status":"ready"} when the database answers; 503 (error body) while shutting down or when the database is unreachable (readiness)

Generated from API.md (repository commit 84a9d3c, file sha256 e735542eb5f5).