TypeScript SDK
revolink is a typed client for API v2. It has no dependencies and needs Node 18+ (or any runtime with a global fetch).
bash
npm install revolink
ts
import {Revolink} from 'revolink';
const revolink = new Revolink({
apiKey: process.env.REVOLINK_API_KEY!,
workspaceId: process.env.REVOLINK_WORKSPACE_ID!,
});
const {shortLink} = await revolink.links.create({url: 'https://example.com'});
Keep the key on your server. Anyone who has it can act on your workspace within the key's permissions.
Resources
| Resource | Methods |
|---|---|
revolink.links | list, iterate, get, create, upsert, update, delete, createMany, updateMany, deleteMany |
revolink.tags | list, get, create, update, delete |
revolink.domains | list, get, create, delete |
revolink.analytics | link, workspace |
for await (const link of revolink.links.iterate()) walks through all links page by page.
Errors and retries
Every failed request throws a RevolinkError with status, code, message, and, when they apply, licenseLimitReached, requiredPermission and retryAfter. The codes are the same as in Errors.
A 429 is always retried (after Retry-After). Network errors and 5xx are retried only for GET, PUT and DELETE, so a link is never created twice. Options: baseUrl, timeout (ms per attempt), maxRetries (0 turns retries off) and fetch.
Links
- Package: npmjs.com/package/revolink
- Source and full README: github.com/maximyaroshchuk/revolink-sdk-js