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 a thin Python client for the HungerBridge v2 REST API. It handles authentication via the X-Auth-Key header and raises typed exceptions (HungerBridgeError, InvalidLevelError, InvalidModeError) on error conditions. Every MinecraftServer instance creates and owns a BridgeClient at self.bridge; you can also instantiate one directly for standalone bridge access.
Constructor
Base URL of the HungerBridge instance, e.g.
"http://mc.example.com:8080". Trailing slashes are stripped and /v2/ is appended automatically.The
X-Auth-Key authentication token configured in HungerBridge.Raw Endpoints
These methods call the HungerBridge v2 REST endpoints directly and return the raw parsed JSON response as adict. Use them when you need fields not exposed by the higher-level getters.
All raw endpoint methods raise HungerBridgeError if the HTTP response is not successful.
v2_ping()
GET /v2/ping. Used internally by getPing() to measure round-trip latency.
Returns dict — bridge ping response.
v2_info()
GET /v2/info. Returns version and platform metadata about the running bridge instance.
Returns dict containing a "bridge" object with "version", "platform", and "minecraft" keys.
v2_status()
GET /v2/status. Returns a simple health/connection status.
Returns dict with an "ok" boolean field.
v2_tps()
GET /v2/tps. Returns all TPS metrics from the server.
Returns dict with keys "tps", "tps_1m", "tps_5m", and "tick_time_ms".
v2_players()
GET /v2/players. Returns online player data.
Returns dict with keys "count" (int) and "players" (list of str).
Public API
runCommand()
POST /v2/run and returns the output.
The server command to execute, without a leading
/, e.g. "op Steve" or "whitelist add Alex".When
True, the command and its output are echoed to the server console log.When
True, the command runs without generating in-game feedback messages.When
True (default), output is returned as a single str with lines joined by \n. When False, the raw bridge response (dict or str) is returned as-is.str of normalised output when normalize=True, or the raw response object when normalize=False. Returns None if the bridge returns no output field.
Raises HungerBridgeError if the HTTP request fails.
log()
POST /v2/log.
The message text to log.
Log severity level. Must be one of
"info", "warn", "error", or None. Passing None strips the log level prefix from the output using a backspace sequence, producing unformatted console output.dict — the bridge’s response body.
Raises InvalidLevelError if level is not one of the four accepted values.
Getters
getPing()
v2_ping() call client-side.
Returns int — round-trip time in milliseconds.
Raises HungerBridgeError if the bridge is unreachable.
getVersion()
str — the HungerBridge plugin version string (e.g. "2.1.0"), or None if not present in the response.
Raises HungerBridgeError if the HTTP request fails.
getPlatform()
str — the server software platform (e.g. "Paper", "Spigot"), or None if not present.
Raises HungerBridgeError if the HTTP request fails.
getMinecraftVersion()
str — the Minecraft version string (e.g. "1.21.1"), or None if not present.
Raises HungerBridgeError if the HTTP request fails.
getStatus()
bool — the value of the "ok" field from v2_status(). True indicates the bridge is healthy and connected to the server.
Raises HungerBridgeError if the HTTP request fails.
getTPS()
v2_tps() endpoint.
Selects which metric to return:
| Mode | Field | Description |
|---|---|---|
"current" | tps | EMA20 — exponential moving average over the last 20 ticks. Reflects near-real-time server performance. |
"1m" | tps_1m | EMA1200 — smoothed average over approximately the last 1 minute of ticks. |
"5m" | tps_5m | EMA6000 — smoothed average over approximately the last 5 minutes of ticks. |
"tick_time" | tick_time_ms | Average tick duration in milliseconds. A healthy server targets ≤ 50 ms per tick. |
float — the requested TPS value.
Raises InvalidModeError if mode is not one of the four accepted values.
Raises HungerBridgeError if the HTTP request fails.
getPlayers()
Selects what to return:
"count"— returns the integer number of currently online players."list"— returns alist[str]of online player usernames.
int when mode="count", list[str] when mode="list".
Raises InvalidModeError if mode is not "count" or "list".
Raises HungerBridgeError if the HTTP request fails.
Exceptions
Raised by any method when the HungerBridge HTTP response has a non-2xx status code, or when a response cannot be parsed. Inherits from the base
Exception class directly (not HungerLibError).Raised by
log() when the supplied level argument is not "info", "warn", "error", or None.Raised by
getTPS() and getPlayers() when the mode argument is not a recognised value.