HungerBridge is a lightweight HTTP agent that runs inside a Minecraft server process and exposes a REST API for automation.Documentation Index
Fetch the complete documentation index at: https://mintlify.com/iFamishedX/HungerLib/llms.txt
Use this file to discover all available pages before exploring further.
BridgeClient is HungerLib’s Python client for that API — it handles authentication, request routing, and response parsing so you can query player counts, read TPS metrics, run console commands, and write log entries with simple method calls. If you are using MinecraftServer, a BridgeClient is constructed and held internally; you only need to use BridgeClient directly when building lower-level tooling or working without the panel layer.
BridgeClient communicates with a separate HungerBridge agent running inside your Minecraft server, not the Pterodactyl panel. The bridge must be installed, configured, and reachable on its own port before any BridgeClient calls will succeed.Constructor
The base URL of the HungerBridge agent, including protocol and port — for example
http://mc.example.com:8080. Any trailing slash is stripped automatically. All requests are sent to <url>/v2/<endpoint>.The authentication token for this HungerBridge instance. It is sent as the
X-Auth-Key header on every request. This value must match the token configured in HungerBridge’s server-side settings.Connection & Info
Raw Endpoints
These methods map one-to-one onto the HungerBridge v2 REST endpoints and return the raw parsed JSON response. Use them when you need the full response payload; the convenience getters below extract individual fields for you.| Method | Endpoint | Description |
|---|---|---|
v2_ping() | GET /v2/ping | Liveness probe — confirms the bridge process is running |
v2_info() | GET /v2/info | Bridge and server metadata (version, platform, Minecraft version) |
v2_status() | GET /v2/status | Connection health check, returns {"ok": true/false} |
Convenience Getters
getPing() -> int
Measures the round-trip latency to the HungerBridge agent in milliseconds, timed client-side.
getVersion() -> str | None
Returns the HungerBridge software version string, extracted from the /v2/info response.
getPlatform() -> str | None
Returns the Minecraft server platform as reported by HungerBridge (e.g. "Paper", "Spigot").
getMinecraftVersion() -> str | None
Returns the Minecraft game version the server is running.
getStatus() -> bool
Returns True when HungerBridge reports a healthy connection status, False otherwise. Prefer this over v2_ping() when you need a simple boolean health check.
Commands & Logging
runCommand(command, show_console=False, silent=False, normalize=True)
Executes a console command on the Minecraft server and returns its output.
The console command to run. Do not include a leading
/ — bridge commands are issued as console commands, not player commands.When
True, the server echoes the command output to its own console in addition to returning it to the caller. Defaults to False.When
True, suppresses server-side console output for the command entirely. Defaults to False.When
True (default), the method joins the output array from the bridge response into a single newline-delimited string, making it easy to print() or log. Set to False to receive the raw response dict from the bridge.log(message, level='info') -> dict
Writes a message to the Minecraft server console log with an optional severity prefix.
The message string to write to the server log.
Log severity prefix. Valid values are
'info', 'warn', 'error', or None. Passing None omits the level prefix entirely. Any other value raises InvalidLevelError.Server Metrics
getTPS(mode='current') -> float
Fetches TPS (ticks per second) data from HungerBridge. The server tracks TPS using several exponential moving averages for different time windows.
mode | Field | Description |
|---|---|---|
'current' | tps | EMA20 — the instantaneous TPS reading, smoothed over 20 ticks |
'1m' | tps_1m | EMA1200 — rolling average over approximately one minute |
'5m' | tps_5m | EMA6000 — rolling average over approximately five minutes |
'tick_time' | tick_time_ms | Average server tick duration in milliseconds |
InvalidModeError for any value outside the table above.
getPlayers(mode='count') -> int | list
Queries the HungerBridge player endpoint.
mode | Returns | Description |
|---|---|---|
'count' | int | Number of players currently online |
'list' | list[str] | List of online player name strings |
InvalidModeError for any other value.
Exceptions
HungerLib defines three exception types thatBridgeClient may raise. Import them from hungerlib.utils.exceptions or catch the base class Exception.
HungerBridgeError
Raised whenever the bridge returns a non-2xx HTTP status code. The message includes the status code and response body for debugging.
InvalidLevelError
Raised by
log() when the level argument is not one of 'info', 'warn', 'error', or None.InvalidModeError
Raised by
getTPS() and getPlayers() when an unrecognised mode string is passed.