@trimlynk/sdk v1.1.2
TrimLynk Node.js & TypeScript SDK (@trimlynk/sdk)
Official Node.js / TypeScript SDK and CLI for the TrimLynk Developer API v1.
- Zero runtime dependencies (built on native Node.js
fetch,node:crypto,node:util,node:fs) - Node.js
>=22.0.0with dual ESM & CommonJS exports and full TypeScript declarations - Bundled
trimlynkCLI with native OS keychain support (macOS Keychain, Linux Secret Service, Windows DPAPI) +0600file fallback
API Reference: Browse the generated TypeDoc Markdown documentation at docs/README.md.
Installation
bash
npm install @trimlynk/sdkOr install globally for the trimlynk CLI:
bash
npm install -g @trimlynk/sdkQuick Start
ts
import { TrimLynk } from "@trimlynk/sdk";
const client = new TrimLynk({
apiKey: process.env.TRIMLYNK_API_KEY,
});
const link = await client.links.create({
originalUrl: "https://example.com/pricing",
customSlug: "pricing-2026",
title: "Pricing Page",
tags: ["marketing", "q4"],
utmSource: "newsletter",
autoDecorateUtm: true,
});
console.log(link.shortUrl);CommonJS is also supported:
js
const { TrimLynk } = require("@trimlynk/sdk");Features
- Resources:
client.links,client.analytics,client.conversions,client.campaigns,client.webhooks - Auto-Pagination:
for await (const link of client.links.iter()) { ... }orawait client.links.iter().toArray() - Bulk Concurrency:
await client.links.createMany(items, { concurrency: 5 }) - QR Code Saving:
await client.links.downloadQr(linkId, "./qr.png") - Idempotency: Pass
idempotencyKeyoncreate()calls and inspectresult.idempotentReplay - Typed Error Hierarchy:
AuthenticationError,InvalidRequestError,NotFoundError,RateLimitError,IdempotencyConflictError,TimeoutError,NetworkError,SignatureVerificationError - Webhook Verification:
client.webhooks.constructEvent({ payload, signatureHeader, secret })andTrimLynk.verifyWebhookSignature(...) - UTM Builder:
buildUtmUrl("https://example.com", { source: "twitter", medium: "social" })
CLI Usage
bash
trimlynk auth login
trimlynk links create https://example.com --slug demo --quiet
trimlynk links list --all --json
trimlynk analytics summary
trimlynk webhooks listen --tunnel-url https://your-tunnel.ngrok-free.dev