Everything you need to integrate real-time multiplayer functionality into your game
Core RESTful endpoints for game management and player interactions
Initializes a new game session and returns connection parameters.
{
"game_id": "string", // Unique game identifier
"version": "string", // Game version
"mode": "string", // Game mode (e.g., "competitive", "coop")
"max_players": number, // Maximum players in session
"region": "string" // Preferred server region
}
{
"session_id": "string", // Unique session identifier
"websocket_url": "string", // WebSocket connection URL
"auth_token": "string", // Temporary auth token for WebSocket
"expires_in": number, // Token validity in seconds
"server": "string" // Assigned game server
}
Retrieves all players in the current game session.
{
"players": [
{
"player_id": "string",
"username": "string",
"avatar": "string",
"ready": boolean,
"ping": number,
"team": "string",
"is_host": boolean
}
],
"count": number
}
Real-time communication between game clients and server
Establish WebSocket Connection
Connect to the provided websocket_url with the auth_token
const socket = new WebSocket('wss://gameserver.example.com/session/abc123?token=xyz456');
Send Initialization Message
Send player metadata immediately after connection
socket.send(JSON.stringify({
"type": "player_init",
"data": {
"player_id": "player123",
"username": "GameMaster",
"character": "warrior",
"loadout": {...}
}
}));
Receive Game State
Server will send initial game state and subsequent updates
{
"type": "player_input",
"data": {
"sequence": 123, // Incrementing sequence number
"inputs": { // Game-specific input state
"move_x": 0.5,
"move_y": -0.2,
"buttons": {
"jump": true,
"attack": false
}
},
"timestamp": 123456789 // Client timestamp
}
}
{
"type": "player_ready",
"data": {
"ready": true
}
}
{
"type": "game_state",
"data": {
"players": {
"player123": {
"position": [x, y, z],
"health": 100,
"state": "moving"
}
},
"world": {
"time": 120,
"events": [...]
},
"server_time": 123456790
}
}
{
"type": "player_joined",
"data": {
"player_id": "newplayer456",
"username": "Newbie",
"team": "blue"
}
}
Secure your game sessions with proper authentication
All REST API endpoints require an Authorization header with a valid JWT token.
Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...
Tokens can be obtained through your platform's OAuth2 flow or via the authentication API.
WebSocket connections require:
wss://gameserver.example.com/session/abc123?
token=xyz456&
player_id=player123
Maintaining and monitoring game sessions
Clients must send periodic heartbeat messages to maintain the connection.
{
"type": "heartbeat",
"data": {
"timestamp": 123456789,
"sequence": 42
}
}
{
"type": "heartbeat_ack",
"data": {
"server_time": 123456790,
"latency": 42
}
}
| Event | Timeout | Action |
|---|---|---|
| No heartbeat received | 10 seconds | Player marked as disconnected |
| No reconnection | 30 seconds | Player removed from session |
| No active players | 5 minutes | Session terminated |