A simple Express.js API server for serving Minecraft player statistics from a MySQL database.
This project is the web API companion for the Stats-Plugin Minecraft plugin.
- Stats-Plugin: Minecraft server plugin that collects and stores player stats to a MySQL database. (View Plugin Repo)
- Stats-Web: This web API (you are here) provides endpoints to access and display those stats (e.g., for web dashboards, leaderboards, etc). (View Web Repo)
- Stats-Plugin runs on your Minecraft server and saves player stats to a MySQL database.
- Stats-Web connects to the same database and exposes REST API endpoints for retrieving and displaying those stats (e.g., for web dashboards, leaderboards, etc).
- Retrieve player stats by UUID
- Get all player balances
- Leaderboards for top balances, most blocks broken, most playtime, most kills, and most deaths
- Node.js (v16+ recommended)
- MySQL database (populated by the Stats-Plugin)
- Clone the repository
- Install dependencies:
npm install
- Copy
example.env
to.env
and fill in your MySQL credentials:DB_HOST=localhost DB_USER=root DB_PASSWORD=yourpassword DB_NAME=stats DB_PORT=3306
- Start the server:
node index.js
GET /api/stats/:uuid
- Get stats for a player by UUIDGET /api/bank
- Get all player balancesGET /api/topbalance
- Get top 10 player balancesGET /api/mostblockbroken
- Get top 10 players by blocks brokenGET /api/mostplaytime
- Get top 10 players by playtimeGET /api/mostkills
- Get top 10 players by mob killsGET /api/mostdeath
- Get top 10 players by deaths
All endpoints return JSON responses.
See example.env
for required variables:
DB_HOST
- MySQL hostDB_USER
- MySQL userDB_PASSWORD
- MySQL passwordDB_NAME
- MySQL database nameDB_PORT
- MySQL port (default: 3306)
MIT