Python & TypeScript SDKs
Relevant source files
The following files were used as context for generating this wiki page:
The Daytona Python and TypeScript SDKs provide a programmatic interface for interacting with the Daytona API. These SDKs enable developers to manage the lifecycle of secure, isolated infrastructure known as "sandboxes," which are designed to run AI-generated code. They offer a unified set of capabilities across different programming environments, including sandbox management, file system manipulation, Git operations, and Language Server Protocol (LSP) support.
Sources: libs/sdk-python/README.md:1-5, libs/sdk-typescript/README.md:3-7, README.md:30-35
Core Capabilities and Architecture
The SDKs act as a wrapper around the Daytona API, abstracting complex infrastructure management into high-level classes and methods. Both SDKs follow a similar architectural pattern where a central client (Daytona) is used to authenticate and create Sandbox instances.
Shared Feature Set
| Feature | Description |
|---|---|
| Sandbox Management | Create, manage, and delete isolated execution environments. |
| Process Execution | Run shell commands or execute code snippets (Python/TS) with real-time output. |
| File System (FS) | Upload, download, search, and manipulate files within the sandbox. |
| Git Operations | Clone repositories, manage branches, and perform staging (add) operations. |
| LSP Support | Interact with language servers for code intelligence (completions, symbols). |
Sources: libs/sdk-python/README.md:41-47, libs/sdk-typescript/README.md:118-125, README.md:43-50
Sandbox Lifecycle Flow
The typical workflow involves initializing the client with credentials, requesting a sandbox, performing operations, and optionally deleting the environment.
Configuration and Initialization
Both SDKs can be configured via environment variables or a configuration object passed during instantiation.
Environment Variables
DAYTONA_API_KEY: Required for authentication.DAYTONA_API_URL: The endpoint for the Daytona API.DAYTONA_TARGET: Target region (e.g.,us,eu).
Sources: libs/sdk-python/README.md:31-35, libs/sdk-typescript/README.md:29-33
Python Implementation
In Python, the DaytonaConfig class is used for manual configuration.
from daytona import Daytona, DaytonaConfig
config = DaytonaConfig(api_key="your-api-key")
daytona = Daytona(config)
Sources: libs/sdk-python/README.md:27-38, README.md:55-60
TypeScript Implementation
The TypeScript SDK accepts a configuration object directly in the constructor.
import { Daytona } from '@daytonaio/sdk'
const daytona = new Daytona({
apiKey: 'YOUR_API_KEY',
target: 'us',
});
Sources: libs/sdk-typescript/README.md:35-43, README.md:65-71
Sandbox Operations
Process and Code Execution
The process module allows for running arbitrary shell commands or specific code blocks. Python uses code_run and exec, while TypeScript uses codeRun and executeCommand.
File System and Git
The fs and git modules provide methods for environment setup and data management.
| Module | Key Methods (Python) | Key Methods (TS) |
|---|---|---|
| FS | upload_file, download_file, find_files | uploadFile, downloadFile, findFiles |
| Git | clone, branches, add | clone, branches, add |
Sources: libs/sdk-python/README.md:66-85, libs/sdk-typescript/README.md:90-112
Development and Distribution
The SDKs are developed as part of a monorepo and distributed through standard package registries.
Publishing Workflow
Release management is handled via GitHub Actions and Nx.
- Python: Published to PyPI as
daytona. - TypeScript: Published to npm as
@daytonaio/sdk.
Versioning Rules
The project follows Semantic Versioning (SemVer), but prerelease formats differ:
- TypeScript: Uses standard SemVer (e.g.,
0.126.0-alpha.1). - Python: Follows PEP 440 (e.g.,
1.2.0a1).
Sources: PUBLISHING.md:73-98
Summary
The Python and TypeScript SDKs serve as the primary programmatic entry points for the Daytona platform. They provide a high-level abstraction for managing isolated sandboxes, allowing developers to execute AI-generated code securely. Both SDKs share a consistent feature set across process execution, file system management, and Git operations, while adhering to the idiomatic standards of their respective languages.
Sources: README.md:1-15, libs/sdk-python/README.md:1-10, libs/sdk-typescript/README.md:1-10