Packagist
linkskipper/sdk · v0.2.1GitHub
Source, issues, and changelog.
Install
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
Your
sk_live_… key. Throws ConfigurationException if empty.Override the API base URL.
Per-request timeout in milliseconds.
Default poll interval for
resolveAndWait.Default overall deadline for
resolveAndWait.Retry tuning. Retries
429 and 5xx, honoring Retry-After, with exponential backoff.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
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 anApiException subclass keyed to the response
error code, under the LinkSkipper\Exception namespace. All extend
LinkSkipperException.
| Exception | Triggered by |
|---|---|
InvalidRequestException | invalid_request (400) |
InvalidKeyException | invalid_key (401) |
OutOfCreditsException | out_of_credits (402) — balance() |
ForbiddenScopeException | forbidden_scope (403) |
NotFoundException | not_found (404) |
LinkRemovedException | link_removed (410) |
UnsupportedLinkException | unsupported_link (422) |
RateLimitedException | rate_limited (429) — retryAfter() |
QuotaExceededException | quota_exceeded (429) — retryAfter() |
ResolveFailedException | resolve_failed (502) |
ProviderDownException | provider_down (503) |
JobFailedException | A polled job ended failed/invalid — $reason, $job |
TimeoutException | resolveAndWait deadline passed — $jobId |
NetworkException | Transport failure after retries |
ConfigurationException | Bad client configuration (e.g. empty key) |
WebhookVerificationException | Webhook::verify rejected a payload |
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.
WebhookEvent exposes event (a WebhookEventName enum), createdAt, jobId,
status (a JobStatus enum), targetUrl, provider, tier, error, creditsCharged,
and balance.
