@invinite-org/api-client
v0.7.0
Published
Typed TypeScript/JavaScript client for the Invinite Web API
Readme
@invinite-org/api-client
Typed TypeScript / JavaScript client for the Invinite
Web API — the workspace REST API at api.invinite.com. It is generated from the
same endpoint registry that powers the REST API and the inv CLI, so its
request and response models always match the
reference.
The client uses typescript-fetch (native fetch, zero runtime dependencies)
and works in Node.js 18+ and modern browsers.
The generated surface includes the curated team activity stream and its full-fidelity per-entity history, plus alert fire-history time ranges, per-alert events, and summary counts.
Install
npm install @invinite-org/api-clientAuthentication
Create a Configuration with your invw_ Web API token as the access token.
The client sends it as an Authorization: Bearer <token> header on every
request.
import { Configuration } from "@invinite-org/api-client";
const config = new Configuration({
accessToken: process.env.INVINITE_CLI_TOKEN
});Team-scoped endpoints take the team as a per-method xTeamId argument — not a
global default header.
Quickstart
Configure the client, call users/me to discover your team id, then make a
team-scoped list call.
import { Configuration, UsersApi, WorkspaceApi } from "@invinite-org/api-client";
const config = new Configuration({
accessToken: process.env.INVINITE_CLI_TOKEN
});
// 1. Find the team to operate on.
const me = await new UsersApi(config).usersMe();
const teamId = me.data.teams[0].id;
// 2. Make a team-scoped list call.
const spaces = await new WorkspaceApi(config).spacesList({
xTeamId: teamId,
limit: 50
});
for (const space of spaces.data.items) {
console.log(space);
}Pagination
List methods return data.items plus data.nextCursor. Pass the cursor back on
the next call until it is null.
const api = new WorkspaceApi(config);
let cursor: string | undefined = undefined;
do {
const page = await api.spacesList({ xTeamId: teamId, limit: 50, cursor });
for (const space of page.data.items) {
// process space ...
}
cursor = page.data.nextCursor ?? undefined;
} while (cursor);Error handling
On a non-2xx response the client throws ResponseError. Read the standard
{ ok: false, error, code } envelope from the response:
import { ResponseError } from "@invinite-org/api-client";
try {
await new WorkspaceApi(config).spacesList({ xTeamId: teamId });
} catch (error) {
if (error instanceof ResponseError) {
const body = await error.response.json(); // { ok: false, error, code }
console.error(error.response.status, body.code, body.error);
} else {
throw error;
}
}Regeneration
This client is a generated artifact. If an endpoint's types look wrong, the fix
belongs in the endpoint registry rather than in hand-written client code —
regenerating re-derives every model from the schema. Releases are published on
sdk-v* tags.
Links
- Web API docs
- SDKs page — install, auth, and quickstarts for both languages
- Repository
