Quickstart
From install to a live short link and its QR code.
import OptoLink from "@optomatica/optolink-sdk";
const client = new OptoLink({ apiKey: "opl_api_…" });
// 1. Create a link — `path` is the only required field.
const link = await client.links.create({ path: "/premium/upgrade" });
// 2. The shareable short URL, computed for you.
console.log(link.url); // e.g. https://links.yourdomain.com/acme/premium-3x9f
// 3. A QR code pointing at it — SVG markup, ready to embed or save.
const svg = await client.links.qrSvg(link.id);
console.log(svg.slice(0, 60)); // <?xml … <svg …
That's the core loop. link.url is https://{domain}/{orgKey}/{shortCode} — the API returns it on every link response, ready to share; you never assemble it yourself.
What create returns
create always resolves the full, uniform Link — the same shape as links.get(id). Under the hood the backend's create response is a partial shape, so the SDK automatically follows up with a fetch of the final record and hands you that. It costs one extra request you don't see or configure. The same applies to update.
A round-trip
// Update a field — all update fields are optional.
await client.links.update(link.id, { title: "Premium upgrade" });
// List with pagination.
const page = await client.links.list({ page: 1, limit: 20 });
console.log(page.data.length, "of", page.total);
// Delete when done.
await client.links.delete(link.id); // { deleted: true }
Every method's exact signature lives in the API reference. Anything non-2xx throws — see errors & retries for the shape of failures and what the SDK retries for you.