Go to file
2014-02-01 09:46:07 -06:00
bin Super mega-commit 2014-01-31 16:27:52 -06:00
games Add Gamespy 1 and 2 protocol support 2014-02-01 09:46:07 -06:00
lib Super mega-commit 2014-01-31 16:27:52 -06:00
.gitignore Super mega-commit 2014-01-31 16:27:52 -06:00
LICENSE initial commit 2013-07-10 05:02:48 -05:00
package.json bump version to 0.2.0 2014-01-31 17:39:58 -06:00
README.md Update README.md 2014-02-01 02:39:06 -06:00

node-GameDig - Game Server Query Library

Usage from Node.js

npm install gamedig
var Gamedig = require('gamedig');
Gamedig.query(
	{
		type: 'minecraft',
		host: 'mc.example.com'
	},
	function(state) {
		if(state.error) console.log("Server is offline");
		else console.log(state);
	}
);

Input Parameters

  • type: One of the game IDs listed in the game list below
  • host
  • port: (optional) Uses the protocol default if not set
  • notes: (optional) Passed through to output

###Callback Function

The callback function is "guaranteed" to be called exactly once.

If an error occurs, the returned object will contain an "error" key, indicating the issue. If the error key exists, it should be assumed that the game server is offline or unreachable.

Otherwise, the returned object is guaranteed to contain the following keys:

Stable, always present:

  • name
  • map
  • password: Boolean
  • maxplayers
  • players: (array of objects) Each object may contain name, ping, score, team, address
  • bots: Same schema as players
  • notes: Passed through from the input

Unstable, not guaranteed:

  • raw: Contains all information received from the server
  • query: Details about the query performed

It can usually be assumed that the number of players online is equal to the length of the players array. Some servers may return an additional player count number, which may be present in the unstable raw object.

Supported Games

  • Alien Swarm (alienswarm)
  • Armagetron (armagetron)
  • Build and Shoot (buildandshoot)
  • Counter-Strike 1.6 (cs16)
  • Counter-Strike: Source (css)
  • Counter-Strike: Global Offensive (csgo)
  • Dino D-Day (dinodday)
  • Garry's Mod (garrysmod)
  • The Hidden: Source (hidden)
  • Just Cause Multiplayer (jcmp)
  • Killing Floor (killingfloor)
  • KzMod (kzmod)
  • Left 4 Dead (left4dead)
  • Left 4 Dead 2 (left4dead2)
  • Minecraft (minecraft) [Additional Notes]
  • Mutant Factions (mutantfactions)
  • Natural Selection (ns)
  • Natural Selection 2 (ns2)
  • No More Room in Hell (nmrih)
  • Nuclear Dawn (nucleardawn)
  • Quake 2 (quake2)
  • Quake 3 (quake3)
  • Ricochet (ricochet)
  • Rust (rust)
  • The Ship (ship)
  • ShootMania (shootmania) [Additional Notes]
  • Starbound (starbound)
  • Suicide Survival (suicidesurvival)
  • Sven Coop (svencoop)
  • Synergy (synergy)
  • Team Fortress 2 (tf2)
  • Terraria (terraria) [Additional Notes]
  • TrackMania 2 (trackmania2) [Additional Notes]
  • TrackMania Forever (trackmaniaforever) [Additional Notes]
  • Unreal Tournament 2004 (ut2004)
  • Unreal Tournament 3 (ut3)
  • Warsow (warsow)

Don't see your game listed here?

  1. Let us know so we can fix it
  2. You can try using some common query protocols directly by using one of these server types:
  • protocol-gamespy3
  • protocol-nadeo
  • protocol-quake2
  • protocol-quake3
  • protocol-unreal2
  • protocol-valve
  • protocol-valvegold

Games with Additional Notes

Minecraft

Some minecraft servers may not respond to a typical status query. If this is the case, try using the 'minecraftping' server type instead, which uses a less accurate but more reliable solution.

Nadeo (ShootMania / TrackMania / etc)

To query a nadeo game, you must have a user account on the server with access level User or higher. Pass the login into to GameDig with the additional options: login, password

Terraria

Requires tshock server mod, and a REST user token, which can be passed to GameDig with the additional option: token

Usage from Command Line

Want to integrate server queries from a batch script or other programming language? You'll still need npm to install gamedig:

npm install gamedig -g

After installing gamedig globally, you can call gamedig via the command line using the same parameters mentioned in the API above:

gamedig --type minecraft --host mc.example.com --port 11234

The output of the command will be in JSON format.