Retrieve advanced information about a Java Edition Minecraft server.
Overview
Query is a new protocol introduced in version 1.9 that allows services such as Minecraft server listings to better retrieve information about servers, including more information than a regular status method would return. It also uses UDP instead of the TCP format which helps separate the main connection protocol and the status retrieval protocol.
Methods
queryBasic()
This method will return some basic information about the server, but still more than a status method would return. Query has to be enabled on the server for this to work, by setting enable-query to true in the server.properties file.
constutil=require('minecraft-server-util');constoptions= { sessionID:1,// a random 32-bit signed number, optional enableSRV:true// SRV record lookup};// The port and options arguments are optional, the// port will default to 25565 and the options will// use the default options.util.queryBasic('localhost',25565, options).then((result) =>console.log(result)).catch((error) =>console.error(error));
This method will return the most information about a Java Edition Minecraft server. Query has to be enabled on the server for this to work, by setting enable-query to true in the server.properties file.
constutil=require('minecraft-server-util');constoptions= { sessionID:1,// a random 32-bit signed number, optional enableSRV:true// SRV record lookup};// The port and options arguments are optional, the// port will default to 25565 and the options will// use the default options.util.queryFull('localhost',25565, options).then((result) =>console.log(result)).catch((error) =>console.error(error));