Skip to main content
The official PHP SDK wraps the REST API with typed models, automatic retries, a resolve-and-wait helper, a per-code exception hierarchy, and webhook verification.

Packagist

linkskipper/sdk · v0.2.1

GitHub

Source, issues, and changelog.

Install

Requires PHP 8.1+ (the SDK uses enums and readonly properties). It works with the built-in cURL transport out of the box, or any PSR-18 HTTP client.
Use the SDK from your server, never client-side, so your API key stays secret. See Authentication.

Initialize

LinkSkipper::create(string $apiKey, string $baseUrl = …) is the quick constructor. For full control over timeouts, polling defaults, retry policy, transport, or clock, build a Config and pass it to new LinkSkipper($config):

Config options

string
required
Your sk_live_… key. Throws ConfigurationException if empty.
string
default:"https://api.linkskipper.app"
Override the API base URL.
int
default:"30000"
Per-request timeout in milliseconds.
int
default:"2000"
Default poll interval for resolveAndWait.
int
default:"120000"
Default overall deadline for resolveAndWait.
RetryPolicy
Retry tuning. Retries 429 and 5xx, honoring Retry-After, with exponential backoff.
Transport
HTTP transport. Defaults to CurlTransport; pass Psr18Transport to use your own client.

Methods

resolve

resolve(string $url, ?string $idempotencyKey = null): ResolveResult Submits a URL to POST /v1/resolve. Returns immediately — a cached link comes back with status === ResolveStatus::Done, a new one queued with a jobId.
ResolveResult exposes jobId, status, url, targetUrl, provider, tier, creditsCharged, cached, balance, queuePosition, pollUrl, and an isDone() helper.

resolveAndWait

The high-level helper: submits the resolve, polls the job until terminal, and returns the resolved link. A cached hit returns without polling.
ResolvedLink has a guaranteed targetUrl plus jobId, provider, tier, creditsCharged, balance, and cached.

getJob

getJob(string $jobId): Job Reads GET /v1/jobs/{jobId} once. The returned Job has a JobStatus enum status with an isTerminal() helper.

account

account(): Account Reads GET /v1/account: telegramId, balance, subscriptionUntil, and providers.

providers

providers(): array — a list<ProviderEntry> Reads GET /v1/providers. Each ProviderEntry has provider, label, hosts, tier (enum), and latency.

Errors

Every failed API call throws an ApiException subclass keyed to the response error code, under the LinkSkipper\Exception namespace. All extend LinkSkipperException. Every ApiException exposes the parsed problem via methods: status(), errorCode() (an ErrorCode enum), detail(), retryAfter(), balance(), and the raw $exception->problem.

Webhook verification

Webhook::verify(string $payload, string $signatureHeader, string $secret, int $toleranceSeconds = 300): WebhookEvent checks the X-LinkSkipper-Signature header, the timestamp tolerance, and the HMAC, then returns a typed WebhookEvent. It throws WebhookVerificationException on any failure.
The WebhookEvent exposes event (a WebhookEventName enum), createdAt, jobId, status (a JobStatus enum), targetUrl, provider, tier, error, creditsCharged, and balance.
Read the raw request body with php://input before any JSON parsing, or the signature won’t match. See Webhooks.