API Client SDK

The @allternit/api-client package is the official JavaScript/TypeScript client for the Allternit platform API. It wraps the Allternit REST API with a small, type-safe surface for managing workspaces, plugins, and tasks, executing plugin actions, and handling errors consistently across Node.js, browser, and edge runtimes.

Overview

Use this SDK when you want to:
  • Manage Allternit workspaces, plugins, and tasks from a TypeScript or JavaScript application.
  • Execute installed plugins programmatically.
  • Handle platform API errors with structured AllternitApiError objects.
  • Run in environments that support the standard fetch API (Node.js 18+, modern browsers, Deno, Cloudflare Workers, etc.).

Installation

For Yarn, pnpm, or bun, use the equivalent command for your package manager.

Quick start

Client configuration

For local development, point baseUrl to your local Allternit API instance, for example http://127.0.0.1:8013.

Key concepts

Resource namespaces

The client groups related API operations under namespace objects:
  • client.workspaces — list, get, create, and delete workspaces.
  • client.plugins — list, get, install, and uninstall plugins.
  • client.tasks — list, get, create, and cancel tasks.

Direct execution helper

The top-level client.execute(pluginId, params) method invokes a plugin action without needing to manage plugin state manually.

Structured errors

All network and HTTP failures are normalized to AllternitApiError, which exposes a machine-readable code, a human-readable message, and optional details.

Workspaces

Plugins

Tasks

For more details on the Tasks API, see the Tasks API reference.

Execute a plugin

Health check

Core methods

Error handling

Common error codes:
Never commit your Allternit API key to version control. Load it from an environment variable or secrets manager.

Types

All SDK types are exported for TypeScript users:

Alternative constructor

You can also create a client with the createClient factory: