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.
GenericServer is the base class for all HungerLib server objects. It wraps the Pterodactyl Client API for a single server identifier and provides resource monitoring, power control, file management, backup and database operations, startup variable configuration, and schedule management. For Minecraft-specific functionality — TPS, player queries, and console commands via HungerBridge — see MinecraftServer, which extends this class.
Constructor
A human-readable label for this server. Used in logging and display only.
The Pterodactyl server identifier (short UUID), found in the panel URL or API response.
self._cached_resources is None. It is populated on the first call to resources() or refresh().
Resources
These methods read live or cached resource data from the Pterodactyl API.refresh()
GET /api/client/servers/{id}/resources, caches the result in self._cached_resources, and returns it.
Returns dict containing raw resource fields from the Pterodactyl API (memory_bytes, cpu_absolute, disk_bytes, network_rx_bytes, network_tx_bytes, uptime).
resources()
refresh() first.
Returns dict — same shape as refresh().
getRAM()
Number of decimal places to round the result to.
When
True, returns the value in gigabytes. When False (default), returns megabytes.float | None — current RAM usage in MB (or GB if gb=True), or None if the metric is unavailable.
getCPU()
Number of decimal places to round the result to.
float | None — current CPU usage as an absolute percentage (e.g. 45.67), or None if unavailable.
getDisk()
Number of decimal places to round the result to.
When
True, returns the value in gigabytes. When False, returns megabytes.float | None — current disk usage in MB or GB, or None if unavailable.
getNetworkIn()
Number of decimal places to round the result to.
When
True, returns the value in gigabytes. When False, returns megabytes.float | None — cumulative inbound network usage in MB or GB, or None if unavailable.
getNetworkOut()
Number of decimal places to round the result to.
When
True, returns the value in gigabytes. When False, returns megabytes.float | None — cumulative outbound network usage in MB or GB, or None if unavailable.
getUptime()
When
False (default), returns uptime as raw seconds. When True, returns a human-readable string such as "2h 15m", "45m 30s", or "12s".int (seconds) when formatted=False, str when formatted=True, or None if the server has not reported an uptime value.
Status
getStatus()
str — Pterodactyl state string, typically one of "running", "offline", "starting", or "stopping".
isOnline()
True if getStatus() returns "running", False otherwise.
isOffline()
True if getStatus() returns "offline", False otherwise.
Power
powerAction()
POST /api/client/servers/{id}/power.
The power signal to send. Must be one of
"start", "stop", "restart", or "kill".tuple — (status_code, response_body).
Raises ValueError if action is not one of the four valid values.
start()
powerAction("start"). Sends the start signal to a stopped server.
Returns tuple — (status_code, response_body).
stop()
powerAction("stop"). Sends a graceful stop signal.
Returns tuple — (status_code, response_body).
restart()
powerAction("restart"). Sends a restart signal.
Returns tuple — (status_code, response_body).
kill()
powerAction("kill"). Immediately terminates the server process without a graceful shutdown.
Returns tuple — (status_code, response_body).
Files
All file methods delegate topanel.files (FileManagerAPI).
listFiles()
Server-relative directory path to list, e.g.
"/plugins".requests.Response from GET /api/client/servers/{id}/files/list.
downloadFile()
Server-relative path to the file, e.g.
"/server.properties".requests.Response containing a signed download URL.
uploadFile()
Destination directory on the server, e.g.
"/plugins".A
files dict suitable for requests multipart upload, e.g. {"files": ("name.jar", open(..., "rb"))}.requests.Response.
deleteFiles()
Root directory for the operation.
List of filenames (relative to
root) to delete.requests.Response.
renameFiles()
Root directory for the operation.
List of rename objects with
"from" and "to" keys.requests.Response.
copyFiles()
Root directory for the operation.
List of file paths to copy.
requests.Response.
moveFiles()
Root directory for the operation.
List of move objects with
"from" and "to" keys.requests.Response.
createFolder()
Parent directory in which to create the new folder.
Name of the new folder.
requests.Response.
compress()
Root directory for the operation.
List of file or directory names (relative to
root) to include in the archive.requests.Response.
decompress()
Server-relative path to the archive to decompress.
requests.Response.
Backups
listBackups()
requests.Response containing the list of all backups for this server.
createBackup()
Display name for the new backup.
requests.Response.
deleteBackup()
Numeric ID of the backup to delete.
requests.Response.
downloadBackup()
Numeric ID of the backup to download.
requests.Response containing a signed download URL.
Databases
listDatabases()
requests.Response containing all databases attached to this server.
createDatabase()
Name for the new database.
Remote host pattern that is allowed to connect. Defaults to
"%" (any host).Optional database host override. When
None, the panel’s default database host is used.requests.Response.
rotateDatabasePassword()
The database identifier string as returned by
listDatabases().requests.Response containing the new password.
deleteDatabase()
The database identifier string to delete.
requests.Response.
Startup
getStartupVariables()
requests.Response containing all startup environment variables defined for this server.
updateStartupVariable()
The environment variable name, e.g.
"SERVER_JARFILE".The new value to set.
requests.Response.
Schedules
listSchedules()
requests.Response containing all schedules for this server.
createSchedule()
Schedule creation payload as expected by the Pterodactyl API, including cron fields (
minute, hour, day_of_month, month, day_of_week) and optionally name, is_active, and only_when_online.requests.Response.
updateSchedule()
The schedule identifier to update.
Payload of fields to update on the schedule.
requests.Response.
deleteSchedule()
The schedule identifier to delete.
requests.Response.
runSchedule()
The schedule identifier to run.
requests.Response.
enableSchedule()
updateSchedule(schedule_id, {"is_active": True}).
The schedule identifier to enable.
requests.Response.
disableSchedule()
updateSchedule(schedule_id, {"is_active": False}).
The schedule identifier to disable.
requests.Response.
getSchedule()
None if no schedule with the given ID is found.
Numeric ID of the schedule to retrieve.
dict | None with the following keys:
Numeric schedule identifier.
Display name of the schedule.
Optional description set on the schedule.
Whether the schedule is currently enabled.
Raw cron object from the API.
Cron minute field, e.g.
"*/5".Cron hour field, e.g.
"*".Cron day-of-month field.
Cron month field.
Cron day-of-week field.
ISO 8601 timestamp for the next scheduled run.
ISO 8601 timestamp of the most recent run, or
null if never run.When
true, the schedule only runs while the server is in the running state.Whether the schedule is currently executing.
ISO 8601 creation timestamp.
ISO 8601 last-updated timestamp.
List of task objects belonging to this schedule, sourced from the
relationships.tasks.data array in the Pterodactyl response.