npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

cosmos-cloud-sdk

v0.22.18

Published

JavaScript/TypeScript SDK for the Cosmos Server API

Readme

cosmos-cloud-sdk

JavaScript/TypeScript SDK for the Cosmos Server API.

Install

npm install cosmos-cloud-sdk

Quick Start

const { createClient } = require('cosmos-cloud-sdk');
// or: import { createClient } from 'cosmos-cloud-sdk';

const cosmos = createClient({
  baseUrl: 'https://my-cosmos.example.com',
  token: 'cosmos_abc123...',
});

// List containers
const containers = await cosmos.docker.list();
console.log(containers.data);

// List users
const users = await cosmos.users.list();

// Get server status
const status = await cosmos.getStatus();

API Reference

createClient({ baseUrl, token })

Creates a Cosmos API client.

  • baseUrl — Your Cosmos server URL (e.g. https://my-cosmos.example.com)
  • token — API token (starts with cosmos_)

Returns an object with namespaced API methods:

Namespaces

| Namespace | Description | |-----------|-------------| | cosmos.docker | Containers, volumes, networks, images | | cosmos.users | User management, 2FA, notifications | | cosmos.config | Server configuration, routes, DNS | | cosmos.storage | Disks, mounts, RAID, SnapRAID | | cosmos.constellation | VPN devices, tunnels | | cosmos.cron | Job management | | cosmos.backups | Backup & restore | | cosmos.metrics | Metrics & events | | cosmos.market | Marketplace | | cosmos.rclone | Cloud storage (rclone) | | cosmos.apiTokens | API token management | | cosmos.auth | Login, logout, sudo |

Top-level methods

| Method | Description | |--------|-------------| | cosmos.getStatus() | Server status | | cosmos.isOnline() | Check connectivity | | cosmos.restartServer() | Restart server | | cosmos.forceAutoUpdate() | Force update | | cosmos.terminal(cmd?) | Host terminal (WebSocket) | | cosmos.uploadImage(file, name) | Upload image | | cosmos.checkHost(host) | DNS check | | cosmos.getDNS(host) | DNS lookup |

Examples

// Docker
const containers = await cosmos.docker.list();
await cosmos.docker.manageContainer('my-app', 'stop');
await cosmos.docker.manageContainer('my-app', 'start');
const logs = await cosmos.docker.getContainerLogs('my-app', 'error', 100);

// Streaming (image pull with progress)
await cosmos.docker.pullImage('nginx:latest', (line) => {
  console.log('Progress:', line);
});

// Users
await cosmos.users.create({ nickname: 'bob', password: '...' });
const user = await cosmos.users.get('bob');

// Config
const config = await cosmos.config.get();
await cosmos.config.set(config.data);
await cosmos.config.updateDNS({ dnsPort: '53' });

// API tokens
const tokens = await cosmos.apiTokens.list();
const newToken = await cosmos.apiTokens.create({
  name: 'my-automation',
  readOnly: true,
});

// Backups
const snapshots = await cosmos.backups.listSnapshots('daily');
await cosmos.backups.restoreBackup('daily', { snapshotId: 'abc', target: '/data' });

// WebSocket (terminal)
const ws = cosmos.docker.attachTerminal('my-container');
ws.onmessage = (e) => console.log(e.data);

More Examples

See the examples directory for full, runnable scripts covering dashboards, CI/CD deployments, container management, and backups.

Response Format

All methods return the raw API response:

{
  status: 'OK',
  data: { /* endpoint-specific data */ },
  message: '...'
}

On error, a CosmosError is thrown with message, status, and code properties.

Requirements

  • Node.js 18+ (uses built-in fetch)
  • Works in browsers too (bundled as ESM and CJS)
  • WebSocket support requires ws package in Node.js < 22

Version

The SDK version is synced with the Cosmos Server version.