Application API (src/Applications)
Administrative (panel) API to manage servers, users, nodes, locations, nests/eggs, and allocations.
Setup
use Gigabait93\Pterodactyl;
$p = Pterodactyl::make('https://panel.example.com', 'ptlc_xxx'); // Client Admin token
Conventions
- List endpoints return a
...ListBuilder; call->send()to get aListResponse. - Item endpoints return a
...ItemBuilder; call->send()to get anItemResponse. - Create/Update/Destroy methods return
ItemResponseorActionResponsedirectly. - See Responses and Builders for response fields and helper methods.
Filters & Sort
- Filters use
filter[<key>]under the hood; SDK надає зручні методиfilterXxx(...)на відповідних ListBuilder. - Sort приймає назву поля, опціонально напрямок:
->sort('id')або->sort('id', true)(desc). - Дозволені поля для сортування (може відрізнятися залежно від версії панелі):
- Users:
id, uuid, username, email, created_at, updated_at - Servers:
id, uuid, name, created_at, updated_at - Nodes:
id, uuid, name, created_at, updated_at - Locations:
id, short, long, created_at, updated_at
- Users:
Servers (admin)
Detailed documentation and DTOs are in Servers (admin).
Key entry points:
all(): ServersListBuilderget(int $id): ServersItemBuilderexternal(string $externalId): ServersItemBuildercreate(CreateServerParams): ItemResponseupdate(int $id, ServerDetailsParams): ItemResponsebuild(int $id, ServerBuildParams): ItemResponsestartup(int $id, ServerStartupParams): ItemResponsesuspend(int $id): ActionResponseunsuspend(int $id): ActionResponsereinstall(int $id): ActionResponsedestroy(int $id): ActionResponseforceDelete(int $id): ActionResponsegetUuid(string $uuid): ItemResponse
Filters & sort
$servers = $p->servers->all()
->filterName('prod')
->filterUuid('54f52795-...')
->filterExternalId('ext-123')
->filterImage('ghcr.io/...')
->sort('name') // asc
// ->sort('name', true) // desc
->send();
Users (admin)
Namespace: Gigabait93\Applications\Users\Users
all(): UsersListBuilder→ListResponseget(int $id): UsersItemBuilder→ItemResponseexternal(string $externalId): UsersItemBuildercreate(UserCreateParams $params): ItemResponseupdate(int $id, UserUpdateParams $params): ItemResponsedestroy(int $id): ActionResponse
DTOs
UserCreateParams(required):email, username, firstName, lastName- Optional:
password(?), externalId(?), language(?), rootAdmin(?)
- Optional:
UserUpdateParams(all optional setters):email, username, firstName, lastName, password(?), externalId(?), language(?), rootAdmin(?)
Example
$params = (new \Gigabait93\Applications\Users\Params\UserCreateParams(
email: 'john@example.com',
username: 'john',
firstName: 'John',
lastName: 'Doe',
))->password('secret')->rootAdmin(false);
$create = $p->users->create($params);
$upd = (new \Gigabait93\Applications\Users\Params\UserUpdateParams())
->firstName('Johnny')->language('en');
$update = $p->users->update(42, $upd);
// Filters & sort
$users = $p->users->all()
->filterEmail('john@example.com')
->filterUsername('john')
->sort('created_at', true)
->send();
Nodes (admin)
Namespace: Gigabait93\Applications\Nodes\Nodes
all(): NodesListBuilder→ListResponseget(int $id): NodesItemBuilder→ItemResponsecreate(NodeCreateParams $params): ItemResponseupdate(int $id, NodeUpdateParams $params): ItemResponsedestroy(int $id): ActionResponse
DTOs
NodeCreateParams(name, locationId, fqdn, memory, memoryOver, disk, diskOver)- Optional setters:
scheme(), behindProxy(), maintenance(), uploadSize(), daemon(listen,sftp), description(?)
- Optional setters:
NodeUpdateParams— all fields optional via setters:name, locationId, fqdn, scheme, behindProxy, maintenance, memory, memoryOver, disk, diskOver, uploadSize, daemon(listen,sftp), description(?)
Example
$create = new \Gigabait93\Applications\Nodes\Params\NodeCreateParams(
name: 'eu-1', locationId: 1, fqdn: 'node1.example.com',
memory: 32768, memoryOver: 0, disk: 500000, diskOver: 0,
);
$p->nodes->create($create);
$upd = (new \Gigabait93\Applications\Nodes\Params\NodeUpdateParams())
->maintenance(true)->uploadSize(200);
$p->nodes->update(10, $upd);
// Filters & sort
$nodes = $p->nodes->all()
->filterName('eu-')
->filterFqdn('node1.example.com')
->sort('name')
->send();
Locations (admin)
Namespace: Gigabait93\Applications\Locations\Locations
all(): LocationsListBuilder→ListResponseget(int $id): LocationsItemBuilder→ItemResponsecreate(LocationParams $params): ItemResponseupdate(int $id, LocationParams $params): ItemResponsedestroy(int $id): ActionResponse
DTO
LocationParams(short, long)
$loc = $p->locations->all()
->filterShort('EU')
->sort('created_at', true)
->send();
Nests (admin)
Namespace: Gigabait93\Applications\Nests\Nests
all(): NestsListBuilder→ListResponseget(int $id): NestsItemBuilder→ItemResponse
Eggs (admin)
Namespace: Gigabait93\Applications\Eggs\Eggs
all(int $nestId): EggsListBuilder→ListResponseget(int $nestId, int $eggId): EggsItemBuilder→ItemResponse
Allocations (admin)
Namespace: Gigabait93\Applications\Allocations\Allocations
all(int $nodeId): ListBuilder(returnsListResponse)create(int $nodeId, AllocationCreateParams $params): ActionResponsedestroy(int $nodeId, int $allocationId): ActionResponse
DTO
AllocationCreateParams(ip, array<int,int> ports)
Includes and pagination
- Use
->includes(...)on anyListBuilder/ItemBuilderthat accepts includes (see enums insrc/Enums). - For lists:
->perPage(n),->page(n),->allPages()to aggregate all items. ListResponse->paginationcontainscurrent_page,total_pages,per_page,totalwhen provided by the panel.
Error handling and rate limits
All responses share fields:
ok,status,headers,error,errors[],data,meta- Rate-limit hints:
rateLimit,rateRemaining,rateReset,retryAfterandretryAfterSeconds()helper. explain()returns a concise, human-friendly error summary.