For the complete documentation index, see llms.txt. This page is also available as Markdown.

VergeOS TypeScript SDK (tsvergeos)

tsvergeos is a TypeScript SDK for managing VergeOS through the REST API, offering a zero-dependency, tree-shakeable, typed interface for automating VMs, networking, storage, tenants, and multi-site.

Overview

tsvergeos is a TypeScript SDK for managing VergeOS infrastructure through the REST API. It provides a zero-dependency, tree-shakeable, fully typed interface for automating VM lifecycle, networking, storage, multi-tenant operations, and multi-site management, making it ideal for automation scripts, tooling development, and integrations.

Key Features

  • Zero Dependencies: Nothing to audit, nothing to break

  • Tree-Shakeable: Import only the services you use; unused services are dead-code eliminated

  • Full Type Coverage: Every resource, parameter, and response is typed with TSDoc documentation

  • 93 Services: Complete coverage of every VergeOS API endpoint

  • Multi-Site Built In: Query and manage multiple VergeOS deployments from a single SiteManager

  • Cross-Platform: Works in Node.js 20+, Deno, Bun, and modern browsers

  • Filtering: OData filter support with both a fluent Filter builder and a functional buildFilter shorthand

Requirements

  • Node.js 20+ (also supports Deno and Bun)

  • VergeOS 6.x (API v4)

Installation

Using pnpm / yarn / bun

Authentication

The SDK supports multiple authentication methods:

SSL Certificate Verification

Set verifySsl: false only for environments with self-signed certificates. For production environments with valid certificates, omit this parameter or set it to true.

Username / Password

Environment Variables

Using environment variables keeps credentials out of your source code and makes it easy to use different credentials across environments.

Service Registration

The SDK uses tree-shakeable imports — services are registered via side-effect imports so unused services are dead-code eliminated from your bundle.

Three Import Levels

The default import does not include every service. If you access a service that isn't registered (e.g., client.alarms without importing it), you'll get undefined. For dashboards, admin tools, or backend scripts where bundle size doesn't matter, use import '@vergeio/tsvergeos/full' to register everything.

Type-Only Imports

Type imports have zero bundle impact regardless of which services are registered:

Available Resources

The SDK provides access to 93 services covering the full VergeOS API:

Category
Resources

Compute

VMs, drives, devices, NICs, machine snapshots, stats

Networking

Networks, rules, aliases, addresses, hosts, DNS zones/records/views

VPN

WireGuard interfaces and peers, IPSec connections and phases

Storage

Volumes, volume snapshots, CIFS/NFS shares, syncs, browser, storage tiers

NAS

NAS services, users, files

Tenants

Tenants, nodes, storage, snapshots, Layer 2

Recipes

VM and tenant recipes, instances, catalogs, repositories

Snapshots

Snapshot profiles, periods, cloud snapshots

Sites

API sites service — incoming/outgoing syncs, sync profile periods (distinct from the SDK's SiteManager)

System

System, clusters, nodes, settings, logs, tasks

Monitoring

Alarms, alarm types, webhooks, webhook URLs

Auth

Users, groups, members, permissions, API keys

Tags

Tags, categories, members

Updates

Update settings, sources, packages, branches

Other

Certificates, cloud-init, resource groups

Usage Examples

Managing Virtual Machines

Reliable Power State

The powerstate field on a VM resource is often omitted by the API. For authoritative live power state, query the machine status service:

Console Access

getConsoleInfo() returns connection details for opening a direct WebSocket console to a VM. Three auth methods are supported — pick based on where the console is rendered:

The browser WebSocket API does not support custom headers — use username/password or a pre-existing token in browsers. For a no-API-call shortcut to the web UI console, use client.vms.getConsoleURL(42).

Filtering Resources

The SDK supports multiple filtering approaches:

Multi-Site Management

Manage multiple VergeOS deployments from a single entry point:

The SiteManager fans out read queries across all registered sites in parallel and returns aggregated results along with any per-site errors. Use manager.tagged(tag) to scope the fan-out to a subset of sites. Mutations always go through a named site (manager.site("dc-east").vms.create(...)); the cross-site proxy exposes only list().

Error Handling

All errors extend VergeError with typed subclasses and type guard functions:

Available Error Types

Error Class
Description

VergeError

Base error for all SDK errors

ApiError

Any HTTP error from the API

NotFoundError

Resource not found (404)

AuthError

Authentication failure (401/403)

ConflictError

Resource state conflict (409)

ValidationError

Invalid client-side input

UnsupportedVersionError

Server version too old

TaskError

Async task failed

TaskTimeoutError

Task exceeded wait timeout

SiteError

Multi-site operation failure

Client Configuration

The full set of configuration options:

Common Use Cases

  • Infrastructure automation: Provision VMs, networks, and storage programmatically

  • CI/CD integration: Create and destroy test environments in pipelines

  • Monitoring and reporting: Query resource status and generate inventory reports

  • Backup automation: Schedule and manage snapshots and cloud backups

  • Multi-tenant provisioning: Automate tenant creation and resource allocation

  • Multi-site orchestration: Manage and query across multiple VergeOS deployments

Documentation and Resources

For complete documentation, including the full API reference and detailed usage examples, visit the official repository:

Support

If you encounter issues or have feature requests, please open an issue on the GitHub repository:

Additional Resources

Last updated

Was this helpful?