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 Docs Validation Tox test

Mcstatus provides an API and command line script to fetch publicly available data from Minecraft servers. Specifically, mcstatus retrieves data by using these protocols: Server List Ping and Query. Because of mcstatus, you do not need to fully understand those protocols and can instead skip straight to retrieving minecraft server data quickly in your own programs.

Installation

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

python3 -m pip install mcstatus

Usage

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.
# Don't expect the player list to always be complete, because many servers run
# plugins that hide this information or limit the number of players returned or even
# alter this list to contain fake players for purposes of having a custom message here.
status = server.status()
print(f"The server has {status.players.online} player(s) online 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 server's 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 BedrockServer("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")

See the documentation to find what you can do with our library!

Command Line Interface

This only works with Java servers; Bedrock is not yet supported. Use mcstatus -h to see helpful information on how to use this script.

License

Mcstatus is licensed under the Apache 2.0 license. See LICENSE for full text.

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-11.1.1.tar.gz (32.9 kB view details)

Uploaded Source

Built Distribution

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

mcstatus-11.1.1-py3-none-any.whl (37.4 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: mcstatus-11.1.1.tar.gz
  • Upload date:
  • Size: 32.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/4.0.2 CPython/3.11.7

File hashes

Hashes for mcstatus-11.1.1.tar.gz
Algorithm Hash digest
SHA256 b2856ee4032faf810b0c6af10a141381e6115caf14a7348c47edc8e3da84f5d4
MD5 77e917af65a9ff6e872111143086775c
BLAKE2b-256 ffad2d0b0cdde02cb505221d5078c91c8123fbc5e467b56983b2321e45bb1858

See more details on using hashes here.

File details

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

File metadata

  • Download URL: mcstatus-11.1.1-py3-none-any.whl
  • Upload date:
  • Size: 37.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/4.0.2 CPython/3.11.7

File hashes

Hashes for mcstatus-11.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 7f5f7f44fa1d17c4e05c0ae94ecc114d9d146ef572e7dd9f2d9da72771ce135c
MD5 a275e2265d38c16f0764855e5521f002
BLAKE2b-256 ebf2a39110f7982e5903314cb73912541932b13b9f95b010a81173854350121d

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