Back up to your Drive from anywhere
Plain HTTP and an API key. No browser, no sign-in. Protection, trash and storage choices work like they do in the app.
Scoped keys
One folder, chosen storages, optional expiry.
Trash, not delete
Overwrites and deletes are always recoverable.
Node SDK
npm install @hsonidev/artemis
Quick start
- 1
Create a key
In the app:
Settings → API keys. The vault must be unlocked. - 2
Copy it once
Shown a single time. Export it as
ARTEMIS_KEY. - 3
Send a file
Use the SDK or four plain HTTP calls.
- 4
Check your Drive
It lands in the key's folder.
import { Artemis } from "@hsonidev/artemis";
const artemis = new Artemis({
apiKey: process.env.ARTEMIS_KEY,
baseUrl: "https://artemis.hsoni.dev", // optional: defaults to ARTEMIS_PUBLIC_DOMAIN
});
await artemis.put("backups/hello.txt", "hello, drive");More in the SDK guide.
Authentication
Send Authorization: Bearer artm_… over HTTPS. Never in a URL.
One folder
Paths are relative to the key's folder. Nothing else is reachable.
Three permissions
write, read, delete. New keys get write only.
Chosen storages
Copies from Protection go only to the storages you ticked. Box and OneDrive are not supported.
Optional limits
Expiry, size cap, IP allow-list, rate limit (120/min by default).
Instant revoke
Also stops if a storage login changes or the folder becomes encrypted.
Recognisable
Keys look like artm_<id>_<secret>, so scanners catch leaks.
Upload a file
Four calls. The SDK does them for you; the HTTP sample below shows each one.
- 1
Ask
POST /uploadswith path, size and SHA-256. - 2
Send
PUTthe bytes to the address returned. No key on this call. - 3
Complete
POST /uploads/{id}/complete - 4
Wait
Poll
GET /uploads/{id}untildone.
Replaces safely
The old version moves to the trash, so you can restore it.
Failures add nothing
Unfinished uploads expire within a day.
Open uploads
5 per key, 10 per account. Abort with DELETE /uploads/{id}.
Recipes
HEAD returns X-Artemis-SHA256. Compare it with your local hash and skip matches, so nightly jobs send only what changed.
import { createHash } from "node:crypto";
import { readFile } from "node:fs/promises";
const BASE = "https://artemis.hsoni.dev/api/v1/drive";
const auth = { Authorization: `Bearer ${process.env.ARTEMIS_KEY}` };
const sleep = (seconds) => new Promise((resolve) => setTimeout(resolve, seconds * 1000));
// The four upload steps from the previous section.
async function upload(remotePath, body, sha256) {
let res = await fetch(`${BASE}/uploads`, {
method: "POST",
headers: { ...auth, "Content-Type": "application/json" },
body: JSON.stringify({ path: remotePath, size: body.length, sha256 }),
});
if (!res.ok) throw new Error(`Could not start the upload: ${res.status} ${await res.text()}`);
const { uploadId, upload: ticket } = await res.json();
res = await fetch(ticket.url, { method: ticket.method, headers: ticket.headers, body });
if (!res.ok) throw new Error(`Upload failed: ${res.status}`);
res = await fetch(`${BASE}/uploads/${uploadId}/complete`, { method: "POST", headers: auth });
if (res.status !== 202 && res.status !== 200) throw new Error(`Could not finish: ${res.status}`);
for (;;) {
const status = await (await fetch(`${BASE}/uploads/${uploadId}`, { headers: auth })).json();
if (status.state === "done") return;
if (status.state === "failed") throw new Error(status.error);
await sleep(2);
}
}
async function backupIfChanged(remotePath, localFile) {
const body = await readFile(localFile);
const sha256 = createHash("sha256").update(body).digest("hex");
// HEAD reports the SHA-256 of files uploaded through the API.
const head = await fetch(`${BASE}/files/${remotePath}`, { method: "HEAD", headers: auth });
if (head.status !== 200 && head.status !== 404) throw new Error(`HEAD failed: ${head.status}`);
if (head.ok && head.headers.get("x-artemis-sha256") === sha256) return "unchanged";
await upload(remotePath, body, sha256);
return "uploaded";
}
console.log(await backupIfChanged("backups/db.sql", "db.sql"));Files
Files under a prefix, sorted by path. Send nextCursor back as cursor for the next page.
const BASE = "https://artemis.hsoni.dev/api/v1/drive";
const auth = { Authorization: `Bearer ${process.env.ARTEMIS_KEY}` };
async function* listFiles(prefix = "") {
let cursor = null;
do {
const params = new URLSearchParams({ prefix, limit: "100" });
if (cursor) params.set("cursor", cursor);
const res = await fetch(`${BASE}/files?${params}`, { headers: auth });
if (!res.ok) throw new Error(`List failed: ${res.status} ${await res.text()}`);
const page = await res.json();
yield* page.files; // { path, size, sha256, etag, modifiedAt }
cursor = page.nextCursor;
} while (cursor);
}
for await (const file of listFiles("backups/")) {
console.log(file.path, file.size);
}WebDAV
Mount the key's folder in Finder, Windows, or rclone. The same key, over a protocol those programs already speak.
Address
https://artemis.hsoni.dev/api/webdav
User name
Anything. Artemis ignores it.
Password
The API key.
What you see
Only the key's folder. A read permission lists and opens files. Write saves them. Delete moves them to the trash.
rclone config create artemis webdav \
url=https://artemis.hsoni.dev/api/webdav vendor=other user=artemis \
pass="$(rclone obscure "$ARTEMIS_KEY")"A save writes the file through Artemis, so it follows the folder's storage and protection. Files over 100 MB, and anything in an encrypted folder, are refused. Listing one folder at a time is supported (Depth: 0 or Depth: 1).
Limits
300 MiB
Per file. At least 1 byte.
No encrypted folders
Writes return 409 ENCRYPTED_SCOPE.
Paths
32 deep, 1024 characters, names up to 255.
Size cap
Counts bytes you send, not Protection copies.
Protection
Follows the folder. Extra copies are made in the background.
Names
Matched without regard to case.