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.git
Move to GameDig API directory:
cd gamedig-api
install dependencies:
bun install
Run:
bun run start
Run dev
bun run dev
You 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.APP_PORT
: The port on which the API will run.
- Bearer Token: a required in header for API authentication.
- Content-Type: the request must have the type
application/json
.
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
}