mojang.minecraft.query

mojang.minecraft.query.get_stats(addr: tuple[str, int], timeout: float | None = 3) ServerStats | None

Returns full stats about server using the Query protocol

Parameters:
  • addr (tuple) – tuple with the address and the port to connect to

  • timeout (int) – Time to wait before closing pending connection (default to 3)

Example:

>>> from mojang.minecraft import query
>>> query.get_stats(("localhost", 25585))
ServerStats(
    motd='A Minecraft Server',
    game_type='SMP',
    game_id='MINECRAFT',
    version='1.16.5',
    map='world',
    host=('localhost', 25585),
    players=(0, 20),
    player_list=[]
)
mojang.minecraft.query.read_null_terminated_string(buffer: IO, encoding: str = 'utf-8') str