MuteBefehl Wiki

API

HTTP, WebSocket and the plugin API.

MuteCloud speaks HTTP and WebSocket on the same address, by default 127.0.0.1:8770. Both live in mutecloud.toml:

mutecloud.toml
[api]
bind = "127.0.0.1:8770"
token = "..."

If the API binds to the outside without a token, the cloud warns on start. Without a token only callers from the same machine are allowed.

HTTP

A="Authorization: Bearer $TOKEN"
H="http://127.0.0.1:8770"
curl -H "$A" $H/api/services
RouteWhat it doesRight
GET /api/healthliveness, no token needed
GET /api/openapi.jsondescription of this API
GET /api/statusnode, version, counts
GET /api/nodesall nodes in the clustergroups.view
GET /api/groupsall groupsgroups.view
GET /api/groups/{name}one group with its serversgroups.view
POST /api/groups/{name}/{action}start, stop, restart, rollout, disable, backupdepends
GET /api/servicesrunning serversservice.view
GET /api/services/{id}one serverservice.view
GET /api/services/{id}/logsrecent log linesservice.view
POST /api/services/{id}/{action}stop, drain, restartdepends
POST /api/services/{id}/execa command to that server's consoleservice.console
GET /api/playerswho is onlineplayers.view
GET /api/players/{name}a single playerplayers.view
GET /api/ranksranksranks.view
GET /api/ranks/{player}a player's rightsranks.view
GET /api/data/{namespace}shared storagedata.view
GET PUT DELETE /api/data/{namespace}/{key}one entrydata.view / data.edit
POST /api/announcebroadcast to all playersannounce
POST /api/maintenancetoggle maintenancemaintenance
GET /api/layerstemplates with their revisionlayers.read
GET /api/layers/{name}a template as tar.gzlayers.read
GET /api/updateversion and whether a newer one waitsgroups.view
POST /api/commandany command, answer as linesdepends

Missing a right gives 403 and names the right that was missing. After eight wrong tokens an address is locked out for a minute.

curl -H "$A" -X POST $H/api/groups/Lobby/start
curl -H "$A" -X POST -H 'Content-Type: application/json' \
     -d '{"line":"say Restart in 5 minutes"}' $H/api/services/Lobby-1/exec
curl -H "$A" -X POST -H 'Content-Type: application/json' \
     -d '{"message":"&bBack in a moment","title":true}' $H/api/announce

The complete description is served at /api/openapi.json, which allows clients to be generated or the routes to be imported into tools such as Postman or Insomnia.

Tokens

token create website groups.view players.view
token list
token delete website

A token receives only the rights it requires. * grants full access and should not be handed to a web frontend.

WebSocket

ws://127.0.0.1:8770/ws carries the same protocol the bridges use. After connecting you send:

{"t":"hello","d":{"version":1,"role":"operator","token":"..."}}

From then on events arrive as they happen: snapshot, service_update, service_gone, log, network, permissions, node_info. To control things you send command and the answer comes back as output with the same request id.

This is the appropriate interface for a web frontend or a bot that should receive events instead of polling.

For plugins

The bridge is deployed to every server and exposes a small API:

MuteCloud.services();                    // every server in the network
MuteCloud.services("Lobby");             // one group
MuteCloud.best("Lobby");                 // the emptiest one accepting players
MuteCloud.send(player, "Lobby");         // move a player
MuteCloud.networkPlayers();              // players across the network
MuteCloud.data("myplugin").set(k, v);    // shared storage

Plus placeholders such as %mutecloud_service%, %mutecloud_network_players% and %mutecloud_players_lobby% once PlaceholderAPI is installed.

On this page