Skip to Content
MineDuels

Web API overview

A built-in HTTP API for player stats, matches, the server list, drain and config editing.

The web API is a small HTTP server inside the MineDuels plugin. It answers JSON. Use it from dashboards, Discord bots, deploy scripts and your own website.

What you can do with it:

  • Read any player's stats, live state and match history, online or not.
  • List running matches on every server, and finished matches with filters.
  • Read kit and overall leaderboards.
  • See every server in the network with its players, free arenas, queues and drain flag.
  • Start or stop drain on this server or on any other server of the network.
  • Read, edit and bulk edit config files, then reload them, in one request.

It is off by default, listens on 127.0.0.1 only, and refuses every request that has no API key.

Quick start

  1. Open plugins/MineDuels/webapi.yml and set enabled: true.
  2. Restart the server. The console prints the address:
[MineDuels] Web API listening on http://127.0.0.1:8765/v1
  1. Create a key in the console or in game:
/md web key create dashboard read
Key dashboard (read) created. Copy it now, it is not shown again:
mdk_Qm9k1s2yQeW3uYb0n8kz1V5lGq7cAa4m9H2xTt6RjLw
  1. Call the API:
curl -H "Authorization: Bearer mdk_Qm9k1s2yQeW3uYb0n8kz1V5lGq7cAa4m9H2xTt6RjLw" \
  http://127.0.0.1:8765/v1/status
{
  "ok": true,
  "data": {
    "version": "0.10.0",
    "server": "lobby-1",
    "crossServer": true,
    "role": "lobby",
    "online": 42,
    "runningMatches": 7,
    "draining": false,
    "uptimeSeconds": 86400,
    "databaseQueue": 0,
    "web": { "served": 120, "refused": 3 }
  }
}

The address

Every endpoint lives under the base URL:

http://<host>:<port><base-path>/<endpoint>

With the defaults that is http://127.0.0.1:8765/v1/<endpoint>. Change host, port and base-path in webapi.yml. Run /md web url to print the address the server uses.

You want to call it fromUse
The same machinehttp://127.0.0.1:8765/v1 (default)
Another machine on your networkSet host: 0.0.0.0, open the port, use http://<server-ip>:8765/v1
The internetPut HTTPS in front of it, for example https://api.example.com/v1

Opening http://127.0.0.1:8765/v1 in a browser without a key shows the endpoint list, so you can check that the address is right.

Response format

Every answer is JSON with an ok flag.

{ "ok": true, "data": { "...": "..." } }
{ "ok": false, "error": { "code": "unauthorized", "message": "the key is not valid" } }

The HTTP status carries the result too: 200 success, 4xx your request, 5xx the server. See errors.

All endpoints

All paths are relative to the base URL. The scope is the lowest key scope that may call it.

Method and pathScopeWhat it returns
GET /noneEndpoint list and version
GET /statusreadThis server's state
GET /serversreadEvery server of the network
GET /kitsreadKit names
GET /arenasreadArena template names
GET /queuesreadPlayers waiting per queue
GET /partiesreadParties on this server
GET /tournamentsreadThe running or waiting tournament
GET /drainreadDrain state of this server and the network
GET /players/{id}readStats and live state of a player
GET /players/{id}/statsreadStored stats of a player
GET /players/{id}/matchesreadA player's finished matches
GET /leaderboards/{kit}readRanked leaderboard, or overall
GET /matches/runningreadRunning matches on every server
GET /matchesreadFinished matches with filters
GET /matches/{id}readOne finished match
GET /configreadEditable config files
GET /config/{file}adminA config file, secrets hidden
POST /drain/startwriteStart drain here or on another server
POST /drain/stopwriteStop drain
POST /reloadwriteReload the config files
PUT /config/{file}adminReplace a config file
PATCH /configadminBulk edit config values

Where to go next

On this page