Node.js SDK
@hsonidev/artemis
Typed, dependency-free client for Node 18+. Hashing, the four upload steps and retries are handled for you.
Install
terminal
npm install @hsonidev/artemisUsage
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 trashMethods
| Method | Key needs | Does |
|---|---|---|
put(path, body, opts?) | write | Upload a string or bytes. Resolves once stored. |
putFile(path, localPath) | write | Upload a local file, up to 300 MiB. |
putIfChanged(path, body) | write | Skips the upload when the hash matches; returns null. |
stat(path) | write | read | Size, ETag, SHA-256. null if missing. |
get(path, { range }?) | read | Bytes, streamed. getText() for strings. |
download(path, localPath) | read | Saves to disk in ranges. |
list() / listAll() | read | One page, or an async iterator over all. |
delete(path) | delete | Moves to the Drive trash. |
tree(path?) | read | One level of a folder, folders included. |
search(query) | read | Search names inside the key's folder. |
protection(path?) / quota() | read | Copies wanted and held; capacity of the key's storages. |
mkdir(path) | write | Create a folder and its parents. |
move(from, to) | write | Rename or move. EXISTS if the target is taken. |
listTrash() / restore(id) | read / write | See what was trashed and undo it. |
searchIndex(opts) / indexStatus() | index:read | Search every storage's index (whole account). |
listNodes() | nodes:read | Your storages and their status, no logins. |
me() | any key | What 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.