Responses and Builders
This SDK returns typed responses and provides builder helpers to compose requests.
BaseResponse (common fields)
ok: bool
— HTTP status is 2xxstatus: int
— HTTP status codeheaders: array<string,string>
— flattened response headersdata: mixed
— normalized body payload (JSONdata
/attributes
or full decoded body)meta: mixed
— JSONmeta
when presenterror: ?string
— short error for non-2xx responsesraw: ?string
— raw response bodyerrors: array<int,array>
— Pterodactylerrors[]
when presentpayload: ?array
— full decoded JSON payload- Rate limits (when provided by panel):
rateLimit: ?int
rateRemaining: ?int
rateReset: ?int
retryAfter: ?int
retryAfterSeconds(): ?int
— recommended wait time
explain(): ?string
— human-friendly error summary usingerrors[]
and status fallback
ListResponse
Extends BaseResponse; represents collection endpoints.
data: array<int,mixed>
— list of itemspagination: array
— meta.pagination when provided (e.g.,current_page
,total_pages
,per_page
,total
)
Constructed internally via ListResponse::fromBase(...)
.
ItemResponse
Extends BaseResponse; represents single item endpoints.
data: array<string,mixed>
— item attributesid: ?int
— convenience field whendata['id']
is present
Constructed via ItemResponse::fromBase(...)
.
ActionResponse
Extends BaseResponse; represents mutation results.
ok: bool
message: ?string
— computed fromerror
ordata['message']
/data['meta']['message']
Constructed via ActionResponse::fromBase(...)
.
Builders
GetBuilder
param(string $key, mixed $value): self
— add query paramincludes(string|array|BackedEnum $includes): self
— set includes list (deduplicated)send(): BaseResponse
— performs the GET and returns typed response (using::fromBase
when available)
ListBuilder extends GetBuilder
Adds pagination helpers:
perPage(int $size): self
page(int $number): self
allPages(): self
— fetches all pages and returns a response withdata
set to the concatenated items
ItemBuilder extends GetBuilder
Represents /{id}
endpoints and holds id
as readonly
.
getId(): int|string
send(): ItemResponse
Notes
- All Client and Application modules follow the same patterns:
all()
returns aListBuilder
get(...)
returns anItemBuilder
- write operations return
ItemResponse
orActionResponse
- Use
->ok
to check success and->explain()
to get human-friendly error context.