@fwd-ad/sdk
v3.0.0
Published
Official fwd.ad API client — create & manage short links and read click stats. Types generated from the OpenAPI spec.
Maintainers
Readme
@fwd-ad/sdk
Official TypeScript client for the fwd.ad API — create & manage
short links and read click statistics. Fully typed; the types are generated
from the OpenAPI spec (openapi.json).
npm install @fwd-ad/sdkUsage
import { FwdClient } from "@fwd-ad/sdk";
const fwd = new FwdClient({ apiKey: "fwd_..." }); // Ayarlar → API
// Create
const link = await fwd.links.create({
target: "https://brand.com/launch",
customurl: "launch", // optional — random if omitted
description: "Spring campaign",
expire_in: "30 days", // optional
});
console.log(link.link); // https://app.fwd.ad/launch
// List (paginated)
const { total, data } = await fwd.links.list({ limit: 20, skip: 0 });
// Get / update / delete
await fwd.links.get(link.id);
await fwd.links.update(link.id, { description: "Updated" });
await fwd.links.remove(link.id);
// Stats
const stats = await fwd.links.stats(link.id);
console.log(stats.total);Options
new FwdClient({
apiKey: "fwd_...", // required
baseUrl: "https://go.brand.com/api/v2", // optional — your custom domain
fetch: customFetch, // optional — for Node < 18
});Errors
Non-2xx responses throw FwdError with a .status:
import { FwdError } from "@fwd-ad/sdk";
try {
await fwd.links.create({ target: "not-a-url" });
} catch (e) {
if (e instanceof FwdError && e.status === 429) { /* rate limited */ }
}Auth & rate limits
Authenticate with the x-api-key header (the SDK sets it for you). Keys are
workspace-scoped. Rate limits are per-minute by plan: Free 3, Pro 120,
Business 600, Enterprise 3000.
Develop
npm run generate # regenerate src/types.gen.ts from openapi.json
npm run build # tsc → dist/