Documentation for the Client API
The Pterodactyl Client API is a RESTful API designed for users to programmatically manage their servers hosted on a Pterodactyl instance. It allows end-users to perform actions like server control, file management, and monitoring resource usage. This documentation provides an overview of the API, authentication setup, endpoint details, and examples to get started.
Written By Cptcr
Last updated About 1 year ago
1. Introduction
The Pterodactyl Client API is a user-facing API that allows individuals to interact with their servers hosted on panel.cptcr.cc. It is ideal for automating tasks, integrating servers into third-party systems, or building custom tools for server management.
Base URL
The base URL for the Client API is:
https://panel.cptcr.cc/api/client All endpoints provided in this guide are relative to the base URL.
2. Authentication
The Client API uses API keys for authentication. These keys are specific to the user and grant access to their own servers. API keys must be included in the headers of each request.
Generating an API Key
Visit panel.cptcr.cc and log in.
Navigate to Account Settings by clicking on your profile in the top-right corner.
Select the API Keys tab.
Click Create API Key, give it a name, and define its expiry date (optional).
Copy the generated key and store it securely. You will not be able to view it again.
Using an API Key
Include the API key in the Authorization header of each request, like this:
Authorization: Bearer <API_KEY> Example cURL request:
curl -X GET "https://panel.cptcr.cc/api/client" \ -H "Authorization: Bearer YOUR_API_KEY" \ -H "Content-Type: application/json" 3. API Endpoints Overview
Below is a summary of the main endpoints provided by the Pterodactyl Client API. Detailed explanations and examples are included in the following sections.
4. Detailed Endpoint Reference
1. Retrieve Account Information
Retrieve details about the authenticated user, such as their email and username.
Endpoint:
GET /account Example Request:
curl -X GET "https://panel.cptcr.cc/api/client/account" \ -H "Authorization: Bearer YOUR_API_KEY" Example Response:
{ "object": "user", "attributes": { "id": 1, "admin": false, "username": "exampleuser", "email": "user@example.com", "language": "en" } } 2. List Servers
Retrieve a list of all servers accessible to the authenticated user.
Endpoint:
GET /servers Example Request:
curl -X GET "https://panel.cptcr.cc/api/client/servers" \ -H "Authorization: Bearer YOUR_API_KEY" Example Response:
{ "object": "list", "data": [ { "object": "server", "attributes": { "server_owner": true, "identifier": "abcd1234", "name": "My Minecraft Server", "node": "Node 1", "sftp_details": { "ip": "123.45.67.89", "port": 2022 }, "limits": { "memory": 4096, "disk": 10000, "cpu": 200 }, "is_suspended": false } } ] } 3. Server Power Management
Start, stop, restart, or kill a server.
Endpoint:
POST /servers/{server_id}/power Request Body:
{ "signal": "start" } Signals Available:
startstoprestartkill
Example Request:
curl -X POST "https://panel.cptcr.cc/api/client/servers/abcd1234/power" \ -H "Authorization: Bearer YOUR_API_KEY" \ -H "Content-Type: application/json" \ -d '{"signal": "start"}' Example Response:
{ "object": "task", "status": "success", "message": "Power action sent successfully." } 4. File Management
List Files
Retrieve a list of files and directories in a specific directory.
Endpoint:
GET /servers/{server_id}/files/list Query Parameters:
directory(optional): Specify the directory to list files from. Default is/.
Example Request:
curl -X GET "https://panel.cptcr.cc/api/client/servers/abcd1234/files/list?directory=/" \ -H "Authorization: Bearer YOUR_API_KEY" Example Response:
{ "object": "list", "data": [ { "name": "server.jar", "mode": "rw-r--r--", "size": 2048, "is_file": true, "is_symlink": false, "mime": "application/java-archive" }, { "name": "logs", "mode": "rwxr-xr-x", "size": 4096, "is_file": false, "is_symlink": false, "mime": "inode/directory" } ] } 5. Monitoring Resources
Retrieve real-time resource usage data for a server, such as CPU, RAM, and disk usage.
Endpoint:
GET /servers/{server_id}/resources Example Request:
curl -X GET "https://panel.cptcr.cc/api/client/servers/abcd1234/resources" \ -H "Authorization: Bearer YOUR_API_KEY" Example Response:
{ "object": "stats", "attributes": { "state": "running", "resources": { "memory_bytes": 2147483648, "cpu_absolute": 50.5, "disk_bytes": 5242880000, "network_rx_bytes": 1048576, "network_tx_bytes": 2048576 } } } 5. Error Handling
The API returns standard HTTP status codes to indicate success or failure.
6. Best Practices
Secure Your API Key: Treat your API key like a password. Never expose it in public repositories.
Rate Limiting: Avoid sending too many requests in a short time to prevent rate-limiting issues.
Error Handling: Always handle errors gracefully and log error messages for debugging.
Test in a Safe Environment: Before automating tasks, test your scripts on non-critical servers.
7. FAQ
Q: Can I access servers I don’t own?
A: No, the Client API only provides access to servers assigned to your account.
Q: How can I regenerate an API key?
A: Delete the old API key and create a new one from the API Keys section in your account.
Q: Is there a limit to how many requests I can send?
A: Some hosts may impose rate limits. Contact your host for specific details.
For more assistance, visit panel.cptcr.cc or contact support.