Skip to main content

A library to query Minecraft Servers for their status and capabilities.

Project description

MCStatus

discord chat supported python versions current PyPI version Validation Tox test

Mcstatus provides an easy way to query Minecraft servers for any information they can expose.
It includes three modes of access (query, status and ping), the differences of which are listed below in usage.

Usage

We provide both an API which you can use in your projects, and a command line script, to quickly query a server.

Python API

Java Edition

from mcstatus import JavaServer

# You can pass the same address you'd enter into the address field in minecraft into the 'lookup' function
# If you know the host and port, you may skip this and use JavaServer("example.org", 1234)
server = JavaServer.lookup("example.org:1234")

# 'status' is supported by all Minecraft servers that are version 1.7 or higher.
status = server.status()
print(f"The server has {status.players.online} players and replied in {status.latency} ms")

# 'ping' is supported by all Minecraft servers that are version 1.7 or higher.
# It is included in a 'status' call, but is also exposed separate if you do not require the additional info.
latency = server.ping()
print(f"The server replied in {latency} ms")

# 'query' has to be enabled in a servers' server.properties file!
# It may give more information than a ping, such as a full player list or mod information.
query = server.query()
print(f"The server has the following players online: {', '.join(query.players.names)}")

Bedrock Edition

from mcstatus import BedrockServer

# You can pass the same address you'd enter into the address field in minecraft into the 'lookup' function
# If you know the host and port, you may skip this and use MinecraftBedrockServer("example.org", 19132)
server = BedrockServer.lookup("example.org:19132")

# 'status' is the only feature that is supported by Bedrock at this time.
# In this case status includes players_online, latency, motd, map, gamemode, and players_max. (ex: status.gamemode)
status = server.status()
print(f"The server has {status.players_online} players online and replied in {status.latency} ms")

Command Line Interface

At present time, this only works with Java servers, Bedrock is not yet supported.

$ mcstatus
Usage: mcstatus [OPTIONS] ADDRESS COMMAND [ARGS]...

  mcstatus provides an easy way to query Minecraft servers for any
  information they can expose. It provides three modes of access: query,
  status, and ping.

  Examples:

  $ mcstatus example.org ping
  21.120ms

  $ mcstatus example.org:1234 ping
  159.903ms

  $ mcstatus example.org status
  version: v1.8.8 (protocol 47)
  description: "A Minecraft Server"
  players: 1/20 ['Dinnerbone (61699b2e-d327-4a01-9f1e-0ea8c3f06bc6)']

  $ mcstatus example.org query
  host: 93.148.216.34:25565
  software: v1.8.8 vanilla
  plugins: []
  motd: "A Minecraft Server"
  players: 1/20 ['Dinnerbone (61699b2e-d327-4a01-9f1e-0ea8c3f06bc6)']

Options:
  -h, --help  Show this message and exit.

Commands:
  json    combination of several other commands with json formatting
  ping    prints server latency
  query   detailed server information
  status  basic server information

Installation

Mcstatus is available on PyPI, and can be installed trivially with:

python3 -m pip install mcstatus

Alternatively, just clone this repo!

License

Mcstatus is licensed under the Apache 2.0 license.

Project details


Release history Release notifications | RSS feed

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

mcstatus-9.4.2.tar.gz (24.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

mcstatus-9.4.2-py3-none-any.whl (26.2 kB view details)

Uploaded Python 3

File details

Details for the file mcstatus-9.4.2.tar.gz.

File metadata

  • Download URL: mcstatus-9.4.2.tar.gz
  • Upload date:
  • Size: 24.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.1.15 CPython/3.8.12 Linux/5.19.3-arch1-1

File hashes

Hashes for mcstatus-9.4.2.tar.gz
Algorithm Hash digest
SHA256 44f435f5334ad17b7c0156de1d02524a60a7af716c5731da7f5f6054058d0b83
MD5 fa7e6af600a92de7ec0f95be14353acf
BLAKE2b-256 e312585714215bcdf7eb333f098fc3a2ca37828efb6eeb96901a079aa2ea6e2d

See more details on using hashes here.

File details

Details for the file mcstatus-9.4.2-py3-none-any.whl.

File metadata

  • Download URL: mcstatus-9.4.2-py3-none-any.whl
  • Upload date:
  • Size: 26.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.1.15 CPython/3.8.12 Linux/5.19.3-arch1-1

File hashes

Hashes for mcstatus-9.4.2-py3-none-any.whl
Algorithm Hash digest
SHA256 9081e402e3782284d15a804af5170738d79bf44cb14e0beeaa5d5c36ab42eff9
MD5 4a4d06bf80013f12cf9c69ea3961d9c5
BLAKE2b-256 7f87964cb5b173936e50c4a09e6f688727622135f285308f9e9b8ceb73fdc4c8

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page