niiko/developers

Packages TypeScript Latest 0.3.0

@vorluno/niiko-sdk

The TypeScript client. One typed method per action and per read, a Result union with the outcomes, zero dependencies.

Last updated

Runtime
Node 18+
License
Apache-2.0
Source
vorluno/niiko-sdk-typescript
Registry
www.npmjs.com/package/@vorluno/niiko-sdk

Install

npm install @vorluno/niiko-sdk

Use

One method per action and per read, typed input and output, and a Result<T> union you branch on once — ReadResult<T> for reads, with two outcomes. Pass accessToken to read. Zero dependencies: fetch ships with Node 18+.

npm install @vorluno/niiko-sdk

import { Niiko } from "@vorluno/niiko-sdk";

const niiko = new Niiko({ apiKey: process.env.NIIKO_API_KEY! });

// The second argument is the idempotency key: keep it if you retry.
const r = await niiko.createLead({
  submissionId: "01890a5d-ac96-774b-bcce-b302099a8057",
  source: "web_form",
}, crypto.randomUUID());

// Branch once on status: a refusal is a state, not an exception.
if (r.status === "done") console.log(r.output);
else if (r.status === "refused") console.error(r.reason, r.detail?.message);
else console.log("waiting for a human signature", r.proposalId);
Two permissions, not one

Both are needed: a key with that scope, and the workspace owner having switched the permission on. Holding the key is not enough — they are two decisions made by different people.

What it does not do

  • Validate your input — the server does, and its refusal travels with a name.
  • Read tables — only the declared reads, each with its contract, and only with an OAuth token.
  • Retry on its own — a retry is a decision about your idempotency key.

Versions

Every version published to the registry, newest first, with the moment it became installable. Each one has its own page.