Skip to documentation
Browse documentation

Build with LinkDevi

View Markdown ↗

TypeScript SDK

Use local campaign helpers and a typed HTTPS client in your server-side application.

English · Updated 2026-11-27

Install the package

bash
npm install @kgma/linkdevi-tools@0.1.0

Node.js 22+ is required. The package includes compiled ESM JavaScript and TypeScript declarations. Local preview helpers need no key; authenticated operations belong on your server or a protected local runtime.

Save the intent, preview it, then opt into creation

typescript
import { readFileSync } from "node:fs";
import { LinkDeviClient, previewCampaign, type CampaignRequest } from "@kgma/linkdevi-tools";

// Generate this file with the CLI, edit it, and retain its UUID.
const intent: CampaignRequest = JSON.parse(readFileSync("campaign.json", "utf8"));
console.log(previewCampaign(intent)); // Local; creates nothing.

const client = new LinkDeviClient({ apiKey: process.env.LINKDEVI_API_KEY ?? "" });
console.log(await client.capabilities());

// Set this flag only after reviewing the intent and available allowance.
if (process.env.LINKDEVI_CREATE === "1") {
  const result = await client.createCampaign(intent);
  console.log(result.campaign.id);
}

Do not generate a fresh UUID every time a failed creation is retried. Load the persisted intent and preserve its payload. Local validation is not server authorization or quota reservation.

Client methods

MethodPurpose
capabilities()Inspect workspace access and limits
previewCampaign(intent)Authenticated remote preview
createCampaign(intent)Create/replay a saved campaign
listCampaigns(page)Read saved campaigns
campaignStats(campaignId)Read lifetime recorded redirect counters
linkQr(linkId, size)Render PNG for a saved link

previewCampaign imported as a standalone helper is offline. client.previewCampaign is an authenticated API request. The client rejects redirects, uses bounded request timeouts and does not automatically retry. LinkDeviError exposes status, code, retryAfter and ambiguous; do not infer success from a network failure.