-
-
Notifications
You must be signed in to change notification settings - Fork 4
Home
Cptcr edited this page Feb 15, 2025
·
2 revisions
To install the pterodactyl-api-wrapper package, use npm:
npm install pterodactyl-api-wrapperOr using yarn:
yarn add pterodactyl-api-wrapperBefore using the API, you must configure the panel URL using the Setup class:
const { Setup } = require("pterodactyl-api-wrapper");
Setup.setPanel("https://panel.example.com");After installing the package and configuring the panel, you can use it as follows:
const { Client } = require("pterodactyl-api-wrapper");
const client = new Client("YOUR_API_KEY");
async function main() {
const servers = await client.servers.list();
console.log("Servers:", servers);
}
main();constructor(apiKey: string)- apiKey: The API key used for authentication.
-
panel: The panel URL fetched from the
Setupclass.
- getDetails(): Retrieves account details.
- enable2FA(codes: string[]): Enables two-factor authentication.
- disable2FA(tokens: string[]): Disables two-factor authentication.
- updateEmail(email: string, password: string): Updates the account email.
- updatePassword(current_password: string, new_password: string): Updates the account password.
- createApiKey(description: string, allowed_ips: string[]): Creates an API key.
- deleteApiKey(key_id: string): Deletes an API key.
- listApiKeys(): Lists API keys associated with the account.
Example Usage:
const account = await client.account.getDetails();
await client.account.updateEmail("new@example.com", "currentPassword");
await client.account.createApiKey("My Key", ["192.168.1.1"]);- list(): Retrieves a list of all servers.
- showPermissions(server_id): Displays server permissions.
- sendCommand(server_id, commandStr): Sends a command to a server.
- powerAction(server_id, signal): Sends a power action (start, stop, restart, kill) to a server.
- getConsoleDetails(server_id): Retrieves console details.
- getResources(server_id): Fetches server resource usage.
- getDetails(server_id): Retrieves server details.
Example Usage:
const servers = await client.servers.list();
await client.servers.powerAction("5", "restart");