Skip to main content

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.

DatabasesAPI wraps the Pterodactyl database management endpoints. It is available as panel.databases on every Panel instance and is also called internally by GenericServer methods. All methods accept server_id as their first argument and return a raw requests.Response. Pterodactyl creates MySQL databases scoped to a server. Each database gets its own username, password, and remote access rule. Use rotate_password() to cycle credentials without recreating the database, or delete() to remove it entirely.
from hungerlib import Panel

panel = Panel("https://panel.example.com", "ptlc_yourtoken")

# Direct usage via panel.databases
response = panel.databases.list("abc123")
print(response.json())

list

Returns all databases attached to a server. Endpoint: GET /api/client/servers/{server_id}/databases
panel.databases.list(server_id)
server_id
str
required
The short identifier of the target server (e.g. "abc123").
Returns: requests.Response — JSON body contains a data array of database objects. Each entry includes id, host (with address and port), name, username, password, connections_from, and max_connections.
response = panel.databases.list("abc123")
for db in response.json()["data"]:
    attrs = db["attributes"]
    print(attrs["name"], attrs["username"], attrs["host"]["address"])

create

Creates a new database for the server. Pterodactyl automatically generates a username and password. Endpoint: POST /api/client/servers/{server_id}/databases
panel.databases.create(server_id, name, remote="%", host=None)
server_id
str
required
The short identifier of the target server.
name
str
required
The name to give the new database. Sent as the "database" key in the JSON request body. Pterodactyl may prefix it with the server identifier automatically.
remote
str
default:"%"
The remote host from which connections are permitted. Defaults to "%", which allows connections from any host. Pass a specific IP or hostname to restrict access.
host
str
The database host ID to use when multiple database hosts are configured on the panel. Only included in the request payload when truthy — if None or falsy (the default), the host key is omitted entirely and Pterodactyl uses the panel’s default database host.
Returns: requests.Response — JSON body describes the newly created database, including its auto-generated username, password, and connection details.
response = panel.databases.create("abc123", "mydb", remote="10.0.0.1")
attrs = response.json()["attributes"]
print(f"DB: {attrs['name']}  User: {attrs['username']}  Pass: {attrs['password']}")

rotate_password

Generates a new random password for an existing database without altering the database or its permissions. Endpoint: POST /api/client/servers/{server_id}/databases/{db_id}/rotate-password
panel.databases.rotate_password(server_id, db_id)
server_id
str
required
The short identifier of the target server.
db_id
str
required
The identifier of the database whose password should be rotated. Obtain this from list() via db["attributes"]["id"].
Returns: requests.Response — JSON body contains the updated database object with the new password field.
response = panel.databases.rotate_password("abc123", "s1_12345")
new_password = response.json()["attributes"]["password"]
print(f"New password: {new_password}")

delete

Permanently deletes a database and all data it contains. Endpoint: DELETE /api/client/servers/{server_id}/databases/{db_id}
panel.databases.delete(server_id, db_id)
server_id
str
required
The short identifier of the target server.
db_id
str
required
The identifier of the database to delete.
Returns: requests.Response — A 204 No Content response on success.
This action is irreversible. All data stored in the database will be permanently destroyed.
panel.databases.delete("abc123", "s1_12345")

Build docs developers (and LLMs) love