Docs / Multiplayer / Dedicated server
Web endpoints
The web port (web_port, also behind the tunnel) answers:
| Request | Answer |
|---|---|
GET / |
A small page with the name, message, map and players. |
GET /status |
JSON: name, motd, map, players, max_players, version, date, time, weather, protocol, vehicles, the announced fleet, plugins (the suggested catalog ids, when there are any), and world (AI cars, buses, parked cars, people walking, waiting and aboard, traffic and passenger density). |
GET /icon.png |
The server icon. |
GET /players |
Only with share_positions = 1, else 404. |
GET /buses |
Only with share_ai = 1, else 404. |
| WebSocket | Players joining over the web (below). |
/admin/, /api/admin/ |
The web panel and its API. |
POST /admin |
The local tool. |
GET /players returns a JSON array refreshed every second, for a live map on a website:
| Field | Meaning |
|---|---|
id, name |
Player number and name. |
bus, paint, line, destination, tour |
What they drive. Empty when on foot. |
x, y |
World metres east and north. |
heading |
Degrees clockwise from north. |
speed_kmh |
Speed. |
on_foot |
Not driving. A player on foot is where they walk, even with their own bus parked nearby. |
aboard |
The id of the player whose bus they ride in, or null. They are placed with that bus. |
parked |
A bus standing free (parked buses). |
lat, lon |
On a map with [worldcoordinates] (such as Berlin-Spandau), else null. |
It is off by default: tell your players when you turn it on.
GET /buses has the same CORS header and is refreshed every second, but tells only the AI timetable buses:
| Field | Meaning |
|---|---|
id |
ai-<id> of the bus in the simulation, kept apart from player ids. |
ai |
Always true, so a map can draw these buses like players. |
bus, line, tour, destination |
Vehicle file, line, tour and the trip's terminus. |
x, y, heading, speed_kmh |
World metres, degrees clockwise from north and speed. |
trip |
The timetable trip (.ttp) file, empty when the bus drives none now. |
next_stop_id, next_stop_index |
The map object and its index in the trip of the next stop, null when none is known. |
delay_s |
Seconds behind (positive) or ahead of the timetable. |
number |
The bus's fleet number, empty when its script has none. |
It needs share_ai = 1 and adds no player data; it is off by default.
WebSocket players#
Players can join at the web port over a WebSocket instead of UDP. Each datagram is one binary message. This is what the Cloudflare tunnel carries.
The gateway gives each WebSocket player a UDP socket of its own on 127.0.0.1. The session log then says joined from 127.0.0.1:<port>, and the gateway logs who that is: gateway: player WebSocket from <address> on 127.0.0.1:<port>.
The address is the one a proxy or tunnel on this machine forwards: the last X-Forwarded-For, else CF-Connecting-IP.
With Cloudflare's proxy in front of a proxy of yours, the last X-Forwarded-For is a Cloudflare edge, and players would share a few addresses (16 connections each at most). Set gateway_proxy_header = cf-connecting-ip then, and only then.
The same gateway and tunnel also open for a player hosting by code. A joining game that cannot reach the code's addresses joins through the tunnel.
Something wrong or missing? Fix it on GitHub or open an issue.