TypeScript SDK for managing sandboxes through the Buddy API
npm install @buddy-works/sandbox-sdkTypeScript SDK for managing Buddy sandboxes - isolated Ubuntu environments for running commands.
``bash`
npm install @buddy-works/sandbox-sdk
`typescript
import { Sandbox } from "@buddy-works/sandbox-sdk";
const identifier = "my-sandbox";
let sandbox: Sandbox;
try {
sandbox = await Sandbox.getByIdentifier(identifier);
} catch {
sandbox = await Sandbox.create({
identifier,
name: "My Sandbox",
os: "ubuntu:24.04",
});
}
await sandbox.start();
await sandbox.runCommand({
command: "ping -c 5 buddy.works",
});
await sandbox.stop();
`
Set required environment variables:
`bash`
export BUDDY_TOKEN="your-api-token"
export BUDDY_WORKSPACE="your-workspace"
export BUDDY_PROJECT="your-project"
export BUDDY_REGION="US" # Optional: US (default), EU, or AP
Configure the API region:
`bash`Via environment variable (recommended)
export BUDDY_REGION="EU"
`typescript`
// Or via connection config
const sandbox = await Sandbox.create({
identifier: "my-sandbox",
name: "My Sandbox",
os: "ubuntu:24.04",
connection: {
region: "EU" // US, EU, or AP
}
});
Override workspace/auth per call:
`typescript``
await Sandbox.create({
identifier: "my-sandbox",
name: "My Sandbox",
os: "ubuntu:24.04",
connection: {
workspace: "different-workspace",
project: "different-project",
token: "custom-token",
region: "EU"
}
});