A very simple API for querying game server information using GameDig and Bun.
A full list of supported games and their unique identifiers can be found in the GameDig documentation.
Bun installed on your system.
Clone the project using git:
git clone https://github.com/Virtual-Instanity/gamedig-api.gitMove to GameDig API directory:
cd gamedig-apiinstall dependencies:
bun installRun:
bun run startRun dev
bun run devBuild and start the container (in background):
docker compose up -d --buildThe container reads API_TOKEN and APP_PORT from the same .env file (or from system environment variables). Without APP_PORT the server uses port 3000. Stop with:
docker compose downYou can configure the environment variables in two ways:
- Copy
.env.example.to.env:cp .env.example .env
- Set the required variables directly in your system's environment.
API_TOKEN: Secret token for authenticating API requests. Required.APP_PORT: The port on which the API will run. Default:3000.RATE_LIMIT_MAX: Max requests per IP per window. Default:30.RATE_LIMIT_WINDOW_SEC: Rate limit window length, seconds. Default:60.MAX_CONCURRENT_QUERIES: Max simultaneous game server queries. Default:5.
- Bearer Token: a required in header for API authentication.
- Content-Type: the request must have the type
application/json. Invalid bodies return422with validation details. - Rate limiting: requests are limited per client IP (
RATE_LIMIT_MAXperRATE_LIMIT_WINDOW_SEC), implemented with elysia-rate-limit. Exceeding the limit returns429withRetry-Afterand standardizedRateLimit-*headers. This also applies to requests with an invalid token, and no more thanMAX_CONCURRENT_QUERIESgame server queries run at the same time — extra requests get429. Request bodies larger than 64 KB are rejected with413.
Example query:
curl -X POST http://127.0.0.1:3000/api/query \
-H "Authorization: Bearer your_api_token" \
-H "Content-Type: application/json" \
-d '{"type": "counterstrike16", "host": "127.0.0.1", "port": 27015}'Other examples:
Example JSON Response:
{
"name": "Counter-Strike 1.6",
"map": "de_dust2",
"password": false,
"raw":
{
"protocol": 48,
"folder": "cstrike",
"game": "Counter-Strike",
"appId": 10,
"numplayers": 1,
"numbots": 0,
"listentype": "d",
"environment": "l",
"secure": 0,
"version": "1.1.2.7/Stdio"
},
"maxplayers": 16,
"players":
[
{
"name": "ufame",
"raw":
{
"score": 0,
"time": 144.923828125
}
}
],
"bots": [],
"connect": "127.0.0.1:27015",
"ping": 0
}