Skip to main content

Python SDK for the Den sandbox API

Project description

den-sdk

Python SDK for Den — the self-hosted sandbox runtime for AI agents.

100 sandboxes on E2B = ~$600/hour. 100 sandboxes on Den = one $5/month server.

Installation

pip install den-sdk
# or
uv add den-sdk

Quick Start

from den import Den

client = Den("http://localhost:8080", api_key="your-key")

# Create a sandbox
sandbox = client.sandbox.create(image="ubuntu:22.04")

# Execute a command
result = sandbox.exec(["python3", "-c", "print('Hello from Den!')"])
print(result.stdout)  # Hello from Den!

# Read/write files
sandbox.write_file("/tmp/hello.py", "print('hello world')")
content = sandbox.read_file("/tmp/hello.py")

# List files
files = sandbox.list_files("/tmp")

# Clean up
sandbox.destroy()

Async Support

import asyncio
from den import Den

async def main():
    client = Den("http://localhost:8080", api_key="your-key")

    sandbox = await client.sandbox.acreate(image="ubuntu:22.04")
    result = await sandbox.aexec(["echo", "async works!"])
    print(result.stdout)
    await sandbox.adestroy()

asyncio.run(main())

Storage

from den import Den, StorageConfig, VolumeMount

client = Den("http://localhost:8080")

# Persistent volume
sandbox = client.sandbox.create(
    image="ubuntu:22.04",
    storage=StorageConfig(
        volumes=[VolumeMount(name="my-data", mount_path="/data")]
    ),
)

Snapshots

# Save state
snapshot = sandbox.snapshot(name="after-setup")

# Restore from snapshot
restored = client.sandbox.restore_snapshot(snapshot.id)

Sandbox Management

# List all sandboxes
sandboxes = client.sandbox.list()

# Get a specific sandbox
sb = client.sandbox.get("sandbox-id")

# Stop a sandbox
sandbox.stop()

# Get sandbox stats
stats = sandbox.stats()

Features

  • Sandbox lifecycle management (create, list, get, stop, destroy)
  • Command execution with timeout and environment variables
  • File operations (read, write, list, mkdir, delete)
  • Persistent volumes, shared volumes, tmpfs configuration
  • Snapshot/restore
  • Port forwarding
  • Async support via httpx
  • Type-safe with Pydantic models

Requirements

  • Python >= 3.10
  • Den server running (see Den repo)

License

MIT

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

den_sdk-0.0.6.tar.gz (30.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

den_sdk-0.0.6-py3-none-any.whl (9.1 kB view details)

Uploaded Python 3

File details

Details for the file den_sdk-0.0.6.tar.gz.

File metadata

  • Download URL: den_sdk-0.0.6.tar.gz
  • Upload date:
  • Size: 30.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.10.10 {"installer":{"name":"uv","version":"0.10.10","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for den_sdk-0.0.6.tar.gz
Algorithm Hash digest
SHA256 c0aef72ea40f2fd69df63877f6cac7587977aac436d20e500a002d64f5efc8ca
MD5 a9121bed56c9879105650b86b1a5ea02
BLAKE2b-256 eb5f22f992dc6b7a6fea418fac2367edea7f68a6cd401af1c5a0e741065b390e

See more details on using hashes here.

File details

Details for the file den_sdk-0.0.6-py3-none-any.whl.

File metadata

  • Download URL: den_sdk-0.0.6-py3-none-any.whl
  • Upload date:
  • Size: 9.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.10.10 {"installer":{"name":"uv","version":"0.10.10","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for den_sdk-0.0.6-py3-none-any.whl
Algorithm Hash digest
SHA256 f94ec90813b344765395a13c3f2633b3577dca99faddf9ca56d2416abf90660e
MD5 e45c442f1b96ab927ec572ceeeaac8f9
BLAKE2b-256 981ca082fdda183c25cd24f07850746526fb87f37185620589b25b0ecb8dbc5c

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page