Skip to main content
Pre-release

This release is a pre-release and may not be stable for production use.

Daytona SDK for Python

A Python SDK for interacting with the Daytona API, providing a simple interface for Daytona Sandbox management, Git operations, file system operations, and language server protocol support.

Installation

You can install the package using pip:

pip install daytona

Quick Start

Here's a simple example of using the SDK:

from daytona import Daytona

# Initialize using environment variables
daytona = Daytona()

# Create a sandbox
sandbox = daytona.create()

# Run code in the sandbox
response = sandbox.process.code_run('print("Hello World!")')
print(response.result)

# Clean up when done
daytona.delete(sandbox)

Configuration

The SDK can be configured using environment variables or by passing a configuration object:

from daytona import Daytona, DaytonaConfig

# Initialize with configuration
config = DaytonaConfig(
    api_key="your-api-key",
    api_url="your-api-url",
    target="us"
)
daytona = Daytona(config)

Or using environment variables:

  • DAYTONA_API_KEY: Your Daytona API key
  • DAYTONA_API_URL: The Daytona API URL
  • DAYTONA_TARGET: Your target environment

You can also customize sandbox creation:

sandbox = daytona.create(CreateSandboxFromSnapshotParams(
    language="python",
    env_vars={"PYTHON_ENV": "development"},
    auto_stop_interval=60,  # Auto-stop after 1 hour of inactivity
    auto_archive_interval=60,  # Auto-archive after a Sandbox has been stopped for 1 hour
    auto_delete_interval=120 # Auto-delete after a Sandbox has been stopped for 2 hours
))

Features

  • Sandbox Management: Create, manage and remove sandboxes
  • Git Operations: Clone repositories, manage branches, and more
  • File System Operations: Upload, download, search and manipulate files
  • Language Server Protocol: Interact with language servers for code intelligence
  • Process Management: Execute code and commands in sandboxes

Examples

Execute Commands

# Execute a shell command
response = sandbox.process.exec('echo "Hello, World!"')
print(response.result)

# Run Python code
response = sandbox.process.code_run('''
x = 10
y = 20
print(f"Sum: {x + y}")
''')
print(response.result)

File Operations

# Upload a file
sandbox.fs.upload_file(b'Hello, World!', 'path/to/file.txt')

# Download a file
content = sandbox.fs.download_file('path/to/file.txt')

# Search for files
matches = sandbox.fs.find_files(root_dir, 'search_pattern')

Git Operations

# Clone a repository
sandbox.git.clone('https://github.com/example/repo', 'path/to/clone')

# List branches
branches = sandbox.git.branches('path/to/repo')

# Add files
sandbox.git.add('path/to/repo', ['file1.txt', 'file2.txt'])

Language Server Protocol

# Create and start a language server
lsp = sandbox.create_lsp_server('typescript', 'path/to/project')
lsp.start()

# Notify the lsp for the file
lsp.did_open('path/to/file.ts')

# Get document symbols
symbols = lsp.document_symbols('path/to/file.ts')

# Get completions
completions = lsp.completions('path/to/file.ts', {"line": 10, "character": 15})

Contributing

Daytona is Open Source under the Apache License 2.0, and is the copyright of its contributors. If you would like to contribute to the software, read the Developer Certificate of Origin Version 1.1 (https://developercertificate.org/). Afterwards, navigate to the contributing guide to get started.

Code in _sync directory shouldn't be edited directly. It should be generated from the corresponding async code in the _async directory using the sync_generator.py script.

Metadata

Release files for daytona 0.112.0.dev4317853

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for daytona 0.112.0.dev4317853
File Size Uploaded
daytona-0.112.0.dev4317853.tar.gz 108.5 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for daytona 0.112.0.dev4317853
File Interpreter ABI Platform
daytona-0.112.0.dev4317853-py3-none-any.whl Python 3 none any Details

Total release size: 243.1 kB

Release files / daytona-0.112.0.dev4317853.tar.gz

Download URL daytona-0.112.0.dev4317853.tar.gz
Size 108.5 kB
Tags Source
SHA-256 checksum
How to use checksums
097d6e653d72ef906cea48828fe5b424566c332281ea111435d55bd8df2b4cf0
BLAKE2b-256 checksum
How to use checksums
c8d1c81f5a265c79a2fcaedc8313a43080788f3e299737a4a333eaba4e26b61b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/2.1.3 CPython/3.10.12 Linux/6.10.14-linuxkit

Release files / daytona-0.112.0.dev4317853-py3-none-any.whl

Download URL daytona-0.112.0.dev4317853-py3-none-any.whl
Size 134.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
8381de24162d9adac9dfb80caab1a4ac590e0c0007b84743e334f89a690f4479
BLAKE2b-256 checksum
How to use checksums
2110da9aaab870229abb0cd3393f3138638580ad33d737225687f69e900dbad6
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/2.1.3 CPython/3.10.12 Linux/6.10.14-linuxkit

Release history Release notifications | RSS feed

This release

0.27.1

2 release files

0.25.6

2 release files

0.25.1

2 release files

0.25.0

2 release files

0.24.5

2 release files

0.24.4

2 release files

0.24.2

2 release files

0.24.1

2 release files

0.24.0

2 release files

0.23.0

2 release files

0.22.1

2 release files

0.21.5

2 release files

0.21.4

2 release files

0.21.3

2 release files

0.21.2

2 release files

0.21.1

2 release files

0.21.0

2 release files

0.18.2

2 release files

0.18.1

2 release files

0.18.0

2 release files

0.17.0

2 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page