{"id":13210,"library":"gamedig","title":"GameDig Game Server Query Library","description":"GameDig is a robust Node.js library engineered for querying the status of a vast array of game and voice servers. The current stable version, 5.3.2, offers an extensive solution for developers needing to fetch public status information from over 320 different game titles and services, along with general protocols. The library is actively maintained, with updates and breaking changes between major versions (e.g., v4 to v5) well-documented in `MIGRATE_IDS.md` and `CHANGELOG.md`. Its key differentiators include broad game support, a straightforward API compatible with both CommonJS and ESM environments, and its dual functionality as a command-line executable. It's a reliable choice for integrating game server status monitoring into applications, supported by an active community on Discord and GitHub.","status":"active","version":"5.3.2","language":"javascript","source_language":"en","source_url":"https://github.com/gamedig/node-gamedig","tags":["javascript","srcds","query","game","utility","util","server","gameserver","game-server-query"],"install":[{"cmd":"npm install gamedig","lang":"bash","label":"npm"},{"cmd":"yarn add gamedig","lang":"bash","label":"yarn"},{"cmd":"pnpm add gamedig","lang":"bash","label":"pnpm"}],"dependencies":[],"imports":[{"note":"GameDig is a named export, not a default export. Incorrectly using a default import will result in `undefined` or runtime errors.","wrong":"import GameDig from 'gamedig';","symbol":"GameDig","correct":"import { GameDig } from 'gamedig';"},{"note":"For CommonJS, `GameDig` is a named property on the module export. Direct require without destructuring will return the module object.","wrong":"const GameDig = require('gamedig');","symbol":"GameDig (CommonJS)","correct":"const { GameDig } = require('gamedig');"},{"note":"The `query` method is static and called directly on the `GameDig` export, not on an instance. While `new GameDig()` might technically work depending on internal implementation, it's not the intended or documented pattern.","wrong":"new GameDig().query(...);","symbol":"GameDig Query Method","correct":"GameDig.query({ type: 'game', host: 'ip' });"}],"quickstart":{"code":"import { GameDig } from 'gamedig';\n\n// Example: Query a Minecraft server\nGameDig.query({\n    type: 'minecraft',\n    host: 'mc.hypixel.net'\n}).then((state) => {\n    console.log('Server Status:', state);\n    // Example of accessing state data\n    console.log(`Players online: ${state.players.length}/${state.maxplayers}`);\n    console.log(`Map: ${state.map}`);\n}).catch((error) => {\n    console.log(`Server is offline or unreachable, error: ${error.message || error}`);\n});\n\n// Example: Query a different game (e.g., Counter-Strike: Global Offensive)\nGameDig.query({\n    type: 'csgo',\n    host: '192.168.1.100', // Replace with an actual CS:GO server IP/hostname\n    port: 27015 // Default query port for CS:GO, often the game port\n}).then((state) => {\n    console.log('CS:GO Server Status:', state);\n}).catch((error) => {\n    console.log(`CS:GO server query failed: ${error.message || error}`);\n});","lang":"javascript","description":"Demonstrates how to query the status of a game server (e.g., Minecraft, CS:GO) using GameDig's static `query` method, including success and error handling."},"warnings":[{"fix":"Consult the `MIGRATE_IDS.md` document in the repository to update game IDs in your application. Also, review the `CHANGELOG.md` for other API adjustments.","message":"A significant breaking change occurred between v4 and v5, primarily affecting game IDs. Many game identifiers were renamed or consolidated.","severity":"breaking","affected_versions":">=5.0.0"},{"fix":"Always refer to the `GAMES_LIST.md` file for details on required fields and notes specific to each game. If a query fails, try explicitly setting the `port` option.","message":"Some game types require additional specific parameters beyond just `type` and `host` for successful querying, or might use a non-standard query port.","severity":"gotcha","affected_versions":">=4.0.0"},{"fix":"If queries aren't working as expected, attempt to specify the server's dedicated query port (if known and different from the game port) using the `port` option in the query configuration.","message":"Using a server's game port instead of its dedicated query port can lead to failed queries for certain protocols or games.","severity":"gotcha","affected_versions":">=4.0.0"},{"fix":"To bypass DNS resolution and connect directly to an IP, use `address: '192.168.1.1'` instead of or in conjunction with `host` (as some protocols still use `host` for other reasons).","message":"The `host` field will be resolved via DNS by default. If you need to connect to a specific IP address without DNS resolution, you must use the `address` option.","severity":"gotcha","affected_versions":">=4.0.0"}],"env_vars":null,"last_verified":"2026-04-19T00:00:00.000Z","next_check":"2026-07-18T00:00:00.000Z","problems":[{"fix":"Verify the server's status and network connectivity. Double-check the `host` and `port` parameters for correctness. Ensure no firewalls are blocking the outbound connection.","cause":"The game server is either genuinely offline, unreachable due to network issues (e.g., firewall), or the specified host/port is incorrect.","error":"Server is offline, error: Timeout"},{"fix":"Consult the `MIGRATE_IDS.md` and `GAMES_LIST.md` files to find the current and correct game identifier for the server you are trying to query.","cause":"Attempting to query a game using an outdated or incorrect game ID, often encountered during migration from GameDig v4 to v5.","error":"Game type 'old_game_id' not found."},{"fix":"Ensure the `type` field corresponds to a valid game ID from `GAMES_LIST.md` or a supported `protocol-[name]` as defined in the library's `protocols/index.js`.","cause":"The `type` field in the query options specified an unrecognized game ID or an unsupported direct protocol name.","error":"Error: Protocol not found: unknown-protocol"}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null,"pypi_latest":null,"cli_name":"gamedig"}