SDKs

TypeScript and Python: every method, what it returns, and the errors.

Both SDKs open one drive with a key and give you files by path. Writes are verified before they count, a write to an existing file makes a new version, and nothing a key does deletes for good.

TypeScript

phantomdisk is one file with no dependencies. It runs wherever fetch and Web Crypto do (Node 20 and later, Deno, Bun, Workers), so it works in a sandbox where nothing can be installed or mounted. Encryption runs in your process.

MethodWhat it does
PhantomDisk.open({ key?, drive?, apiUrl? })Connects and loads the drive’s tree. key defaults to PHANTOMDISK_KEY
list(path?)Entries in a folder: path, name, kind, size, modified, id, versionId
stat(path)One entry, or null
read(path, { offset?, length?, version? })Bytes: the whole file, or a part (only the blocks that hold it are fetched)
readText(path, { version? })A text file’s content
write(path, data)Writes a string, bytes or a Blob, making the folders above it
mkdir(path)Makes a folder and the folders above it
move(from, to)Renames and moves in one call
remove(path)Moves to Recently Deleted
copy(from, to)Copies a file or folder inside the drive; no data is copied
fork(name)A new drive with everything in this one; returns it, open
history(path)Versions, newest first: id, size, createdAt, current, purgeAt
restore(path, versionId)Makes an old version current again
writable, encrypted, driveIdWhat this key may do, and which drive it is in

Errors are PhantomDiskError with a code (NOT_FOUND, KEY_READ_ONLY, QUOTA_EXCEEDED, READ_ONLY, LOCKED…), a sentence fit to show, and the HTTP status.

Python

phantomdisk needs Python 3.9 or later and nothing but the standard library. Each call runs the phantomdisk tool, so it reads and writes exactly what the Mac app does, encryption included. A call takes a second or two.

MethodWhat it does
PhantomDisk.open(key=None, drive=None)Connects and checks the key. key defaults to PHANTOMDISK_KEY
list(path='')Entries in a folder: path, name, kind, size, modified, id, version_id
stat(path)One entry, or None
read(path, version=None)The whole file as bytes
read_text(path, version=None)A text file’s content
download(path, local)Saves a file to disk, whatever its size
write(path, data)Writes a string or bytes, making the folders above it
upload(local, folder='')Sends a file from disk under its own name; resumable
mkdir(path)Makes a folder and the folders above it
move(src, dst)Renames or moves; onto an existing folder it moves into it
remove(path)Moves to Recently Deleted
fork(name)A new drive with everything in this one; returns it
history(path)Versions, newest first: id, size, created_at, current
restore(path, version_id)Makes an old version current again

Errors are PhantomDiskError with a code (NOT_FOUND, USAGE, NO_TOOL, FAILED) and a sentence fit to show.

Next: Linux mount