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
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
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.
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.
WebhookEvent exposes event (a WebhookEventName enum), createdAt, jobId,
status (a JobStatus enum), targetUrl, provider, tier, error, creditsCharged,
and balance.
