Indiwtf Links SDK
A tiny, typed client for resolving a short link's currently active destination, straight from your own website, app, or workflow. Read-only, and it never touches your check quota.
import { IndiwtfLinks } from "@indiwtf/links";
const client = new IndiwtfLinks({ token: TOKEN });
const link = await client.get(42);
link.destination;
// "https://backup.example.net/launch"Overview
Introduction
Indiwtf Links picks the topmost destination that's actually reachable from the Indonesian network and serves your visitors there. The SDK lets you read that decision yourself, so you can render the right link in your UI, redirect server-side, or sync it into your own system.
It wraps the read-only Links REST API and authenticates with the same Indiwtf API token. Available on Business and Enterprise plans.
Setup
Install
npm install @indiwtf/links # or: bun add @indiwtf/links # or: pnpm add @indiwtf/links
Keep your token server-side. Store it in an environment variable like INDIWTF_TOKEN, never in client-side bundles.
Setup
Quickstart
import { IndiwtfLinks } from "@indiwtf/links";
const client = new IndiwtfLinks({ token: process.env.INDIWTF_TOKEN! });
// List every link and where it currently points.
const { links } = await client.list();
for (const link of links) {
console.log(link.short_url, "→", link.destination);
}
// Or resolve one link by id.
const link = await client.get(42);
console.log(link.destination);Reference
Creating a client
new IndiwtfLinks(options) returns a client bound to your token.
| Option | Type | Description |
|---|---|---|
| token | string | Required. Your Indiwtf API token. |
| baseUrl | string | Optional. Defaults to https://indiwtf.com/api. |
| fetch | typeof fetch | Optional. Custom fetch implementation (edge, tests). |
Reference
Methods
client.list()
Resolves to { links: Link[] } — all your enabled links with their active destination.
client.get(id)
Resolves to a single Link, or throws IndiwtfError with status 404 when the id isn't yours or doesn't exist.
The Link type
type Link = {
id: number;
domain: string; // "go.example.net"
slug: string; // "launch"
short_url: string; // "https://go.example.net/launch"
destination: string | null; // active candidate, null before first check
destination_count: number;
is_stale: boolean; // all destinations down → last known-good
updated_at: string; // ISO 8601
};Snippets
Examples
Next.js — server-side redirect
import { redirect } from "next/navigation";
import { IndiwtfLinks } from "@indiwtf/links";
const client = new IndiwtfLinks({ token: process.env.INDIWTF_TOKEN! });
export default async function Go({ params }: { params: { id: string } }) {
const link = await client.get(Number(params.id));
redirect(link.destination ?? "/");
}No SDK — plain fetch
The SDK is a thin wrapper; you can call the API directly with any HTTP client.
const res = await fetch("https://indiwtf.com/api/links/42", {
headers: { Authorization: `Bearer ${process.env.INDIWTF_TOKEN}` },
});
const link = await res.json();
console.log(link.destination);Error handling
import { IndiwtfLinks, IndiwtfError } from "@indiwtf/links";
const client = new IndiwtfLinks({ token: process.env.INDIWTF_TOKEN! });
try {
const link = await client.get(42);
console.log(link.destination);
} catch (err) {
if (err instanceof IndiwtfError && err.status === 404) {
// unknown link
} else {
throw err;
}
}Build on your own links
Indiwtf Links is included on Business and Enterprise plans. Grab a token and resolve destinations from anywhere.