Skip to main content

Library to query Minecraft server data

Project description

RStatus

RStatus is a Python library designed to query Minecraft server data, supporting both Java and Bedrock servers. It provides a unified API to retrieve server information, including server status, player counts, MOTD, version details, and more. The library also features DNS resolution and proxy support, making it easy to handle both domain names and direct IP addresses.

Features

  • Unified API: Retrieve data from both Java and Bedrock servers.
  • Automatic DNS Resolution: Resolve domain names to IP addresses with custom port detection.
  • Proxy Support: Connect via SOCKS4/5 proxies for enhanced network flexibility.
  • Bot Response: Get the server's bot response (Java only) to retrieve additional status details.
  • Customizable Settings: Configure timeouts, enable BungeeCord compatibility, and debug mode for troubleshooting.

Installation

Install RStatus using pip:

pip install RStatus

Note: RStatus depends on external libraries PySocks and dnspython. These will be installed automatically.

Usage

Below is a basic example of how to use RStatus to query a Minecraft server:

from rstatus import RStatusClient

# Create a client instance for the target server (domain or IP:port)
client = RStatusClient("example.com:25565", debug=True)

# Get the server status (tries Java first, falls back to Bedrock)
server_data = client.get_server_data(bot=True)

if server_data:
    print("Server Data:", server_data)
else:
    print("Failed to retrieve server data.")

Querying Specific Server Types

  • Java Server Data

    To query data specifically from a Java server, use:

    java_data = client.get_java_server_data(bot=True)
    
    if java_data:
        print("Java Server Data:", java_data)
    else:
        print("Java server query failed.")
    
  • Bedrock Server Data

    For Bedrock servers, use:

    bedrock_data = client.get_bedrock_server_data()
    
    if bedrock_data:
        print("Bedrock Server Data:", bedrock_data)
    else:
        print("Bedrock server query failed.")
    
  • Bot Response (Java Only)

    Retrieve the bot response from a Java server with an optional version parameter:

    bot_response = client.get_bot_response(version="1.16")
    print("Bot Response:", bot_response)
    

API Reference

RStatusClient

The main class provided by RStatus is RStatusClient, which inherits functionality from the underlying MinecraftClient, JavaHandler, and BedrockHandler.

Constructor

RStatusClient(
    target: str,
    timeout: int = 5,
    bungeehack: bool = False,
    proxy_type: Optional[str] = None,
    proxy_address: Optional[str] = None,
    proxy_port: Optional[int] = None,
    debug: bool = False,
) -> None
  • target: The target server address. It can be a domain (e.g., "example.com") or include a port (e.g., "example.com:25565").
  • timeout: Connection timeout in seconds (default is 5).
  • bungeehack: Enable compatibility with BungeeCord (default is False).
  • proxy_type, proxy_address, proxy_port: Settings to connect via a proxy (supports SOCKS4/SOCKS5).
  • debug: Enable debug logging for troubleshooting.

Methods

  • get_server_data(bot: bool = True) -> Union[JavaServerResponse, BedrockServerResponse, None]
    Retrieves the status of the server. It first attempts a Java server query and, if unsuccessful, falls back to querying a Bedrock server.

  • get_java_server_data(bot: bool = True) -> Optional[JavaServerResponse]
    Specifically queries a Java server for its status data.

  • get_bedrock_server_data() -> Optional[BedrockServerResponse]
    Queries a Bedrock server for its status data. (Note: If the port is set to 25565, it automatically switches to the default Bedrock port 19132.)

  • get_bot_response(version: Union[str, int, None] = None) -> str
    Retrieves the server’s bot response for Java servers. You can optionally specify a server version.

Contributing

Contributions are welcome! If you find any issues or have suggestions for improvements, feel free to open an issue or submit a pull request.

License

This project is licensed under the MIT License. See the LICENSE file for details.

Project details


Download files

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

Source Distribution

rstatus-0.0.1.tar.gz (15.2 kB view details)

Uploaded Source

Built Distribution

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

rstatus-0.0.1-py3-none-any.whl (20.5 kB view details)

Uploaded Python 3

File details

Details for the file rstatus-0.0.1.tar.gz.

File metadata

  • Download URL: rstatus-0.0.1.tar.gz
  • Upload date:
  • Size: 15.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.2

File hashes

Hashes for rstatus-0.0.1.tar.gz
Algorithm Hash digest
SHA256 c73c51dc3493fce04f9123bbbfa44d86a68ad96fc57ce004f5743b3ca59c3364
MD5 8c33b5b08e8ae2e1faf18e17888fe46a
BLAKE2b-256 9dcff72e71848e86d6ccc07397a306e7c29bac27a3bec4e8c394b88332bf262b

See more details on using hashes here.

File details

Details for the file rstatus-0.0.1-py3-none-any.whl.

File metadata

  • Download URL: rstatus-0.0.1-py3-none-any.whl
  • Upload date:
  • Size: 20.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.2

File hashes

Hashes for rstatus-0.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 683d6eee9f2bc4543feef5ec1c214ce7a46c63be122e3b5377e2fdd35cef299e
MD5 3a576e0873fcd32b045d40f46d2abd3d
BLAKE2b-256 6de7a82b9f35c551d889e763453e1688f4327979651a1903520770ccaed54d29

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