Daytona Client for Rust
A client library for the Daytona API, providing secure sandbox environments for code execution and development.
Features
- Complete API Coverage: Full implementation of the Daytona REST API
- Secure Sandboxes: Create isolated environments for code execution
- File Management: Upload, download, and manage files in sandboxes
- Process Execution: Run commands and code in multiple languages
- Git Integration: Clone repos, commit, push, pull, and manage branches
- Workspace Management: Create and manage persistent development environments
- Real-time Support: WebSocket connections for live updates (coming soon)
- Type Safety: Strongly typed API with comprehensive error handling
Installation
Add this to your Cargo.toml:
[]
= "0.1"
Quick Start
use ;
async
Environment Variables
The client can be configured using environment variables:
DAYTONA_API_KEY— Daytona API key (required)DAYTONA_BASE_URL— API base URL (default:https://app.daytona.io/api)DAYTONA_ORGANIZATION_ID— Organization ID for multi-org accounts (optional)
API Coverage
Core Operations
- ✅ Sandboxes: Create, list, get, delete, start, stop
- ✅ Workspaces: Full workspace lifecycle management
- ✅ Files: Upload, download, delete, list, copy, move
- ✅ Process: Execute commands, run code, install packages
- ✅ Git: Clone, commit, push, pull, branch management
Advanced Features
- ✅ Organizations: Member and role management
- ✅ Backups: Create and restore workspace backups
- ✅ Port Forwarding: Create public URLs for services
- 🚧 WebSockets: Real-time terminal and logs (coming soon)
- 🚧 LSP: Language Server Protocol support (coming soon)
Examples
File Operations
// Upload a file
client.files
.upload_text
.await?;
// Download a file
let content = client.files
.download_text
.await?;
// List files
let files = client.files
.list
.await?;
Git Operations
use GitCloneRequest;
// Clone a repository
client.git
.clone
.await?;
// Get status
let status = client.git
.status
.await?;
// Commit changes
client.git
.commit
.await?;
Workspace Management
use CreateWorkspaceParams;
// Create a workspace
let workspace = client.workspaces
.create
.await?;
// Wait for it to start
let workspace = client.workspaces
.wait_for_state
.await?;
// Create a port preview
let preview = client.workspaces
.create_port_preview
.await?;
println!;
Session-based Execution
// Create a stateful session for multiple executions
let session_id = "my-session";
// First execution — set a variable
client.process
.execute_code_with_session
.await?;
// Second execution — use the variable
let result = client.process
.execute_code_with_session
.await?;
Error Handling
The client provides comprehensive error types:
use ;
match client.sandboxes.create.await
Contributing
Contributions are welcome. Please feel free to submit a Pull Request.
License
This project is licensed under either of:
- Apache License, Version 2.0 (LICENSE-APACHE)
- MIT license (LICENSE-MIT)
at the option of the licensee.
Acknowledgments
This client is not officially affiliated with Daytona. For official SDKs, visit Daytona's documentation.