Node.js SDK

@hsonidev/artemis

Typed, dependency-free client for Node 18+. Hashing, the four upload steps and retries are handled for you.

npm@hsonidev/artemisMITNo dependenciesTypeScript types

Install

terminal
npm install @hsonidev/artemis

Usage

Create a key in Settings → API keys first.

backup.mjs
import { Artemis } from "@hsonidev/artemis";

const artemis = new Artemis({
  apiKey: process.env.ARTEMIS_KEY, // artm_<id>_<secret>
  baseUrl: "https://artemis.hsoni.dev",             // optional: defaults to ARTEMIS_PUBLIC_DOMAIN
});

await artemis.put("backups/db.sql", "select 1;");
await artemis.putFile("backups/backup.tar", "./backup.tar");
await artemis.putIfChanged("backups/db.sql", data); // null if unchanged

const stat = await artemis.stat("backups/db.sql");  // null if missing
await artemis.download("backups/db.sql", "./restore.sql");

for await (const file of artemis.listAll({ prefix: "backups/" })) {
  console.log(file.path, file.size);
}

await artemis.mkdir("backups/2026");
await artemis.move("backups/db.sql", "backups/2026/db.sql");
const hits = await artemis.search("db");              // names inside the key's folder
const trashed = await artemis.listTrash();
await artemis.restore(trashed[0].id);

await artemis.delete("backups/old.sql"); // to the trash

Methods

MethodKey needsDoes
put(path, body, opts?)writeUpload a string or bytes. Resolves once stored.
putFile(path, localPath)writeUpload a local file, up to 300 MiB.
putIfChanged(path, body)writeSkips the upload when the hash matches; returns null.
stat(path)write | readSize, ETag, SHA-256. null if missing.
get(path, { range }?)readBytes, streamed. getText() for strings.
download(path, localPath)readSaves to disk in ranges.
list() / listAll()readOne page, or an async iterator over all.
delete(path)deleteMoves to the Drive trash.
tree(path?)readOne level of a folder, folders included.
search(query)readSearch names inside the key's folder.
protection(path?) / quota()readCopies wanted and held; capacity of the key's storages.
mkdir(path)writeCreate a folder and its parents.
move(from, to)writeRename or move. EXISTS if the target is taken.
listTrash() / restore(id)read / writeSee what was trashed and undo it.
searchIndex(opts) / indexStatus()index:readSearch every storage's index (whole account).
listNodes()nodes:readYour storages and their status, no logins.
me()any keyWhat this key may do.

put takes ifNoneMatch, ifMatch, sha256 and contentType, and returns { path, size, sha256, etag, protection, created }.

Errors

Failures throw ArtemisError. Rate limits, 5xx and network errors are retried for you (3 times, honouring Retry-After).

import { ArtemisError } from "@hsonidev/artemis";

try {
  await artemis.put("a.txt", "x", { ifNoneMatch: true });
} catch (e) {
  if (e instanceof ArtemisError && e.code === "EXISTS") {
    // already there; e.status, e.code, e.retryAfter are available
  }
}

Client options

maxRetries

Default 3.

pollIntervalMs

Default 2000. How often to check a large upload.

largeUploadTimeoutMs

Default 15 min. UPLOAD_TIMEOUT means it may still finish.

uploadTimeoutMs

Default 10 min, for sending the bytes.

timeoutMs

Default 60 s per request.

fetch

Bring your own, mainly for tests.

API v1Updated 6 Nov 2026 · 2c2d87f