Skip to main content
The WebSocket Gateway allows you to receive ER:LC server data in real time without the need to continuously poll the REST API. By connecting to the gateway, you can subscribe to the data channels you’re interested in and receive updates automatically.

Connection

URL: wss://api.erlcrussia.com/v2/gateway When connecting to the HTTP endpoint (not WebSocket), a 426 error with code 5020 is returned.

Quick Start

Connection Lifecycle

  1. Connect — establish a WebSocket connection
  2. Authenticate — send auth with your token
  3. Subscribe — subscribe to desired channels via subscribe
  4. Receive Data — get real-time updates
  5. Unsubscribe — unsubscribe from channels via unsubscribe
  6. Disconnect — close the connection

Client Messages

All messages are sent in JSON format with an action field.

Authentication

The first message that must be sent after connecting. Without authentication, all other actions will be rejected.

Response Upon Success

After successful authentication, a cache snapshot is automatically sent (if available).

Channel Subscription

Subscribe to one or more data channels.
Single channel via channel field is also supported:

Response

Subscription Denied

If you don’t have access to a specific channel:

Channel Unsubscription

Unsubscribe from channels you no longer need.

Response


Cache Retrieval

Request the current cache snapshot for your subscriptions.
Returns data only for channels you are subscribed to.

Ping

Connection check.

Response


Data Channels


Channel Data Structure

Server

Players

Staff

Queue

JoinLogs

KillLogs

CommandLogs

ModCalls

EmergencyCalls

Vehicles


Server Messages

Connection Event

Sent immediately after the connection is established:

Cache Update

When server data changes, an updated snapshot is sent to all subscribed clients:
Data is returned only for channels the client is subscribed to.

Empty Cache

If the cache is unavailable:

Empty Snapshot

If the cache exists but there is no data for your subscriptions:

Error


Keep-Alive

The server sends a WebSocket ping every 30 seconds. The client must respond with pong. If the client does not respond, the connection will be closed. For manual connection checking, use the ping action:

Full Example