Skip to main content

Replication API

The Replication API is Crowded Kingdoms' authoritative spatial replication surface over UDP (User Datagram Protocol). Game clients that can open raw UDP sockets authenticate via the Management API, mint an app-scoped token for the app they are entering (mintAppToken — see Portals & app-scoped tokens), call serverWithLeastClients on the Game API for Buddy assignment, then exchange replication messages directly with a Buddy server. Buddy authenticates only app-scoped tokens; the identity session token that login returns is rejected for gameplay.

Buddy is the name of the replication server program—not a separate product. When platform docs mention Buddy, they mean an instance of that program running in your environment. The wire protocol, handshake, and operational guides in this section describe how to speak to Buddy over UDP.

This section documents native UDP integrations—handshake timing, wire payloads, sequencing, HMAC, and failure modes. If you'd rather not implement the wire protocol by hand, the official CrowdyCPP SDK implements it natively in portable C++.

Browsers and the GraphQL UDP proxy

Clients that cannot open raw UDP sockets (typical browsers) route spatial traffic through the Game API's GraphQL mutations and WebSocket subscriptions instead—see the GraphQL UDP proxy guide.

Both paths share the same Management API identity (register / login) and the same app-scoped token minted from it (mintAppToken or the browser portal flow); only the transport differs (UDP to Buddy vs. GraphQL through the proxy).

Quick start

  1. Getting started — prerequisites and endpoints
  2. Authenticate and assign — login, mintAppToken, serverWithLeastClients, session-ready wait
  3. Send and receive — first spatial message and notifications
  4. Wire formats and HMAC — binary layout reference
  5. Operations — heartbeats, errors, reassignment
  6. Troubleshooting — "sends succeed but nothing comes back" and other connectivity issues
  7. Load testing — simulate real player traffic against your app with the open-source cks-loadtest tool