@zodedev/sdk wraps the Zode API for Node. Version 0.2.0 is on npm. It is ESM only, needs Node 22 or later, and has no runtime dependencies.
Python SDK: coming soon.
Install
import, not require.
Get an API key
Create a key in the console under API keys (console.zode.dev/tokens), or withPOST /v1/tokens (see the API reference). A key starts with zode_tok_ and belongs to one workspace.
zode login saves for the CLI. It does read ZODE_TOKEN, so a shell set up for the CLI with that variable works for the SDK too.
Configure the client
new Zode(options) makes a client. Every option is optional.
orgis a workspace id, sent as theX-Zode-Orgheader. You do not need it with an API key.timeoutMsapplies to each HTTP call. It is long by default because a create waits for the VM to boot. It does not limit streamed commands; those take their owntimeoutMs(see Run commands).fetchlets you swap in another implementation, for a proxy or tests.- An environment variable set to an empty string counts as unset.
Static helpers or a client
There are two ways to reach sandboxes:- Static helpers on
Sandbox:Sandbox.create(opts),Sandbox.get(id)andSandbox.list(filters). Each call builds a client from the environment unless you passclient, which takes aZodeinstance orZodeOptions. - A client:
zode.sandboxes.create / get / listdo the same thing. Snapshots (zode.snapshots) and environments (zode.environments) are only on the client.
Sandbox keeps the client that loaded it as sbx.client.
For routes the SDK does not wrap, zode.request(method, path, body?, query?) sends a JSON request to any /v1 path and throws ZodeError on a non-2xx answer.
Records use the API’s field names
sbx.id, sbx.name and sbx.status are shortcuts. sbx.record returns a copy of the full API record, in the API’s snake_case:
feature_error. The record updates after every call that returns a sandbox: refresh, stop, start, restore, and switching the browser or desktop. Options you pass in are camelCase (gitRepo, maxCostMicros); results such as exec’s exit_code keep the API’s names.
End-to-end example
Sandbox.create resolves once the VM is running. The fork is a second running sandbox, so this example needs room for two; the Free plan runs at most 2 at once.
Reference
- Sandboxes: create, list, stop, start, fork, delete
- Run commands:
exec,spawnand streaming - Files, Snapshots, Browser and desktop, Environments
- Errors:
ZodeErrorcodes and retries