daytona
2.0.0rc1
2.0.0a5
2.0.0a4
2.0.0a3
2.0.0a2
1.0.1
0.28.0rc1
0.27.1
0.27.0rc1
0.27.0
0.26.0rc2
0.26.0rc1
0.26.0a12
0.26.0a11
0.26.0
0.25.6
0.25.5
0.25.4
0.25.3
0.25.2a1
0.25.2a0
0.25.1
0.25.0
0.24.5
0.24.4
0.24.2
0.24.1
0.24.0
0.23.0
0.227.0
0.226.1
0.226.0
0.225.0
0.224.1
0.224.0
0.223.1
0.223.0
0.222.0
0.220.0
0.22.2a0
0.22.1
0.22.0a6
0.22.0a5
0.22.0a4
0.22.0a3
0.22.0a2
0.22.0a1
0.22.0a0
0.22.0
0.218.0
0.217.0
0.216.1
0.216.0
0.215.0
0.214.0
0.211.2
0.210.0
0.21.8
0.21.7
0.21.6
0.21.5a8
0.21.5
0.21.4a5
0.21.4a16
0.21.4a15
0.21.4a14
0.21.4a12
0.21.4a11
0.21.4
0.21.3
0.21.2
0.21.1
0.21.0a2
0.21.0a1
0.21.0
0.207.1
0.207.0
0.205.1
0.205.0
0.204.0
0.203.0
0.202.0
0.201.0
0.200.2
0.200.1
0.200.0
0.20.2
0.20.0
0.199.0a1
0.199.0
0.198.0
0.197.0
0.196.0
0.195.0
0.194.0a2
0.194.0
0.193.0a1
0.193.0
0.192.0
0.191.0
0.190.1
0.190.0a3
0.190.0a1
0.190.0
0.19.0a2
0.19.0a0
0.19.0
0.189.0
0.187.0
0.186.0
0.185.0
0.184.0a2
0.184.0a1
0.184.0
0.183.0
0.182.0
0.181.0
0.180.0a1
0.180.0
0.18.2
0.18.1
0.18.0
0.179.0
0.178.0
0.176.1a1
0.176.0
0.175.0
0.173.0
0.172.1a1
0.172.0
0.171.0rc1
0.171.0
0.170.0
0.17.0
0.169a1
0.169.0a2
0.169.0
0.168.1a2
0.168.1a1
0.168.0
0.167.0a1
0.167.0
0.166.0
0.165.0
0.164.0a1
0.164.0
0.163.0a1
0.163.0
0.162.0
0.161.0
0.160.0
0.159.0a2
0.159.0
0.158.1
0.158.0
0.157.0
0.155.1a2
0.155.1a1
0.155.0
0.154.0
0.153.0
0.152.1
0.152.0
0.151.0
0.150.0
0.149.0rc2
0.149.0rc1
0.149.0a2
0.149.0a1
0.149.0
0.148.0
0.147.0
0.146.1rc3
0.146.1rc2
0.146.1rc1
0.146.0
0.145.0
0.144.0
0.143.0
0.142.0
0.141.0
0.140.0
0.139.0
0.138.0
0.136.0
0.135.0
0.134.0
0.133.0
0.132.0
0.131.0rc4
0.131.0rc3
0.131.0rc2
0.131.0rc1
0.131.0a3
0.131.0a2
0.131.0a1
0.130.0
0.129.0
0.128.2a1
0.128.1
0.128.0
0.127.0rc2
0.127.0rc1
0.127.0
0.125.1a3
0.125.1a2
0.125.1a1
0.125.0rc1
0.125.0
0.124.0
0.123.0
0.122.0
0.121.0
0.120.0
0.119.0
0.118.0a1
0.118.0
0.117.0
0.116.0a1
0.116.0
0.115.2
0.115.1a7
0.115.1
0.115.0
0.114.0a1
0.114.0
0.113.2
0.113.1
0.113.0
0.112.3a2
0.112.3a1
0.112.3
0.112.2rc1
0.112.2
0.112.1
0.112.0.dev462455
0.112.0.dev4317853
0.112.0
0.111.1
0.111.0
0.110.2
0.110.1
0.110.0
0.109.0a2
0.109.0a1
0.109.0
0.108.1rc1
0.108.1
0.108.0rc1
0.108.0
0.107.1
0.107.0rc2
0.107.0rc1
0.106.5
0.106.4
0.106.1
0.106.0a3
0.106.0a2
0.106.0a1
0.105.1
0.105.0
0.104.0rc2
0.104.0rc1
0.103.0rc3
0.103.0rc2
0.103.0rc1
0.103.0
0.102.0rc2
0.102.0rc1
0.102.0
0.1.0
2.0.0rc1
2.0.0a5
2.0.0a4
2.0.0a3
2.0.0a2
1.0.1
0.28.0rc1
0.27.1
0.27.0rc1
0.27.0
0.26.0rc2
0.26.0rc1
0.26.0a12
0.26.0a11
0.26.0
0.25.6
0.25.5
0.25.4
0.25.3
0.25.2a1
0.25.2a0
0.25.1
0.25.0
0.24.5
0.24.4
0.24.2
0.24.1
0.24.0
0.23.0
0.227.0
0.226.1
0.226.0
0.225.0
0.224.1
0.224.0
0.223.1
0.223.0
0.222.0
0.220.0
0.22.2a0
0.22.1
0.22.0a6
0.22.0a5
0.22.0a4
0.22.0a3
0.22.0a2
0.22.0a1
0.22.0a0
0.22.0
0.218.0
0.217.0
0.216.1
0.216.0
0.215.0
0.214.0
0.211.2
0.210.0
0.21.8
0.21.7
0.21.6
0.21.5a8
0.21.5
0.21.4a5
0.21.4a16
0.21.4a15
0.21.4a14
0.21.4a12
0.21.4a11
0.21.4
0.21.3
0.21.2
0.21.1
0.21.0a2
0.21.0a1
0.21.0
0.207.1
0.207.0
0.205.1
0.205.0
0.204.0
0.203.0
0.202.0
0.201.0
0.200.2
0.200.1
0.200.0
0.20.2
0.20.0
0.199.0a1
0.199.0
0.198.0
0.197.0
0.196.0
0.195.0
0.194.0a2
0.194.0
0.193.0a1
0.193.0
0.192.0
0.191.0
0.190.1
0.190.0a3
0.190.0a1
0.190.0
0.19.0a2
0.19.0a0
0.19.0
0.189.0
0.187.0
0.186.0
0.185.0
0.184.0a2
0.184.0a1
0.184.0
0.183.0
0.182.0
0.181.0
0.180.0a1
0.180.0
0.18.2
0.18.1
0.18.0
0.179.0
0.178.0
0.176.1a1
0.176.0
0.175.0
0.173.0
0.172.1a1
0.172.0
0.171.0rc1
0.171.0
0.170.0
0.17.0
0.169a1
0.169.0a2
0.169.0
0.168.1a2
0.168.1a1
0.168.0
0.167.0a1
0.167.0
0.166.0
0.165.0
0.164.0a1
0.164.0
0.163.0a1
0.163.0
0.162.0
0.161.0
0.160.0
0.159.0a2
0.159.0
0.158.1
0.158.0
0.157.0
0.155.1a2
0.155.1a1
0.155.0
0.154.0
0.153.0
0.152.1
0.152.0
0.151.0
0.150.0
0.149.0rc2
0.149.0rc1
0.149.0a2
0.149.0a1
0.149.0
0.148.0
0.147.0
0.146.1rc3
0.146.1rc2
0.146.1rc1
0.146.0
0.145.0
0.144.0
0.143.0
0.142.0
0.141.0
0.140.0
0.139.0
0.138.0
0.136.0
0.135.0
0.134.0
0.133.0
0.132.0
0.131.0rc4
0.131.0rc3
0.131.0rc2
0.131.0rc1
0.131.0a3
0.131.0a2
0.131.0a1
0.130.0
0.129.0
0.128.2a1
0.128.1
0.128.0
0.127.0rc2
0.127.0rc1
0.127.0
0.125.1a3
0.125.1a2
0.125.1a1
0.125.0rc1
0.125.0
0.124.0
0.123.0
0.122.0
0.121.0
0.120.0
0.119.0
0.118.0a1
0.118.0
0.117.0
0.116.0a1
0.116.0
0.115.2
0.115.1a7
0.115.1
0.115.0
0.114.0a1
0.114.0
0.113.2
0.113.1
0.113.0
0.112.3a2
0.112.3a1
0.112.3
0.112.2rc1
0.112.2
0.112.1
0.112.0.dev462455
0.112.0.dev4317853
0.112.0
0.111.1
0.111.0
0.110.2
0.110.1
0.110.0
0.109.0a2
0.109.0a1
0.109.0
0.108.1rc1
0.108.1
0.108.0rc1
0.108.0
0.107.1
0.107.0rc2
0.107.0rc1
0.106.5
0.106.4
0.106.1
0.106.0a3
0.106.0a2
0.106.0a1
0.105.1
0.105.0
0.104.0rc2
0.104.0rc1
0.103.0rc3
0.103.0rc2
0.103.0rc1
0.103.0
0.102.0rc2
0.102.0rc1
0.102.0
0.1.0
توضیحات
Python SDK for Daytona
| ویژگی | مقدار |
|---|---|
| سیستم عامل | - |
| نام فایل | daytona-2.0.0rc1 |
| نام | daytona |
| نسخه کتابخانه | 2.0.0rc1 |
| نگهدارنده | [] |
| ایمیل نگهدارنده | [] |
| نویسنده | Daytona Platforms Inc. |
| ایمیل نویسنده | support@daytona.io |
| آدرس صفحه اصلی | - |
| آدرس اینترنتی | https://pypi.org/project/daytona/ |
| مجوز | Apache-2.0 |
# Daytona Python SDK
The official Python SDK for [Daytona](https://daytona.io), a secure and elastic infrastructure for running AI-generated code. Daytona provides full composable computers — [sandboxes](https://www.daytona.io/docs/en/sandboxes/) — that you can manage programmatically using the Daytona SDK.
The SDK provides an interface for sandbox management, file system operations, Git operations, language server protocol support, process and code execution, and computer use. For more information, see the [documentation](https://www.daytona.io/docs/en/python-sdk/).
## Installation
Install the package using **pip**:
```bash
pip install daytona
```
## Get API key
Generate an API key from the [Daytona Dashboard ↗](https://app.daytona.io/dashboard/keys) to authenticate SDK requests and access Daytona services. For more information, see the [API keys](https://www.daytona.io/docs/en/api-keys/) documentation.
## Configuration
Configure the SDK using [environment variables](https://www.daytona.io/docs/en/configuration/#environment-variables) or by passing a [configuration object](https://www.daytona.io/docs/en/configuration/#configuration-in-code):
- `DAYTONA_API_KEY`: Your Daytona [API key](https://www.daytona.io/docs/en/api-keys/)
- `DAYTONA_API_URL`: The Daytona [API URL](https://www.daytona.io/docs/en/tools/api/)
- `DAYTONA_TARGET`: Default [region](https://www.daytona.io/docs/en/regions/) for sandboxes and snapshots (e.g. `us`, `eu`); a per-call `target` / `region_id` overrides it
```python
from daytona import Daytona, DaytonaConfig
# Initialize with environment variables
daytona = Daytona()
# Initialize with configuration object
config = DaytonaConfig(
api_key="YOUR_API_KEY",
api_url="YOUR_API_URL",
target="us"
)
```
## Create a sandbox
Create a sandbox to run your code securely in an isolated environment.
```python
from daytona import Daytona, DaytonaConfig
config = DaytonaConfig(api_key="YOUR_API_KEY")
daytona = Daytona(config)
sandbox = daytona.create()
response = sandbox.process.code_run('print("Hello World")')
```
## Examples and guides
Daytona provides [examples](https://www.daytona.io/docs/en/getting-started/#examples) and [guides](https://www.daytona.io/docs/en/guides/) for common sandbox operations, best practices, and a wide range of topics, from basic usage to advanced topics, showcasing various types of integrations between Daytona and other tools.
### Create a sandbox or snapshot in a specific region
Pass `target` in the sandbox create params, or `region_id` in `CreateSnapshotParams`, to choose the [region](https://www.daytona.io/docs/en/regions/) for that call. The region is resolved per call: the per-call value, then the client-level `target` (or `DAYTONA_TARGET`), then the organization's default region.
```python
from daytona import CreateSandboxFromSnapshotParams, CreateSnapshotParams, Daytona
daytona = Daytona()
sandbox = daytona.create(CreateSandboxFromSnapshotParams(target="eu"))
snapshot = daytona.snapshot.create(CreateSnapshotParams(name="my-snapshot", image="python:3.12", region_id="eu"))
```
### Create a sandbox with custom resources
Create a sandbox with [custom resources](https://www.daytona.io/docs/en/sandboxes/#resources) (CPU, memory, disk).
```python
from daytona import Daytona, CreateSandboxFromImageParams, Image, Resources
daytona = Daytona()
sandbox = daytona.create(
CreateSandboxFromImageParams(
image=Image.debian_slim("3.12"),
resources=Resources(cpu=2, memory=4, disk=8)
)
)
```
### Create an ephemeral sandbox
Create an [ephemeral sandbox](https://www.daytona.io/docs/en/sandboxes/#ephemeral-sandboxes) that is automatically deleted when stopped.
```python
from daytona import Daytona, CreateSandboxFromSnapshotParams
daytona = Daytona()
sandbox = daytona.create(
CreateSandboxFromSnapshotParams(ephemeral=True, auto_stop_interval=5)
)
```
### Create a sandbox from a snapshot
Create a sandbox from a [snapshot](https://www.daytona.io/docs/en/snapshots/).
```python
from daytona import Daytona, CreateSandboxFromSnapshotParams
daytona = Daytona()
sandbox = daytona.create(
CreateSandboxFromSnapshotParams(
snapshot="my-snapshot-name",
language="python"
)
)
```
### Execute Commands
Execute commands in the sandbox.
```python
# 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, download, and search files in the sandbox.
```python
# 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, list branches, and add files to the sandbox.
```python
# 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 to get code completions, document symbols, and more.
```python
# Create and start a language server
lsp = sandbox.create_lsp_server('python', 'path/to/project')
lsp.start()
# Notify the lsp for the file
lsp.did_open('path/to/file.py')
# Get document symbols
symbols = lsp.document_symbols('path/to/file.py')
# Get completions
completions = lsp.completions('path/to/file.py', {"line": 10, "character": 15})
```
Code in [\_sync](./src/daytona/_sync/) directory shouldn't be edited directly. It should be generated from the corresponding async code in the [\_async](./src/daytona/_async/) directory using the SDK generation scripts in the [scripts](./scripts/) directory.
## List method return shapes
Each `list` method returns a different shape depending on the resource. The table below shows the exact return type and how to access the elements.
| Method | Return type (sync) | Return type (async) | Shape | Access elements |
| --- | --- | --- | --- | --- |
| `daytona.snapshot.list(page?, limit?)` | `PaginatedSnapshots` | `PaginatedSnapshots` | Paginated wrapper | `result.items` |
| `daytona.secret.list(cursor?, limit?, ...)` | `ListSecretsResponse` | `ListSecretsResponse` | Cursor-paginated wrapper | `page.items` |
| `daytona.volume.list()` | `list[Volume]` | `list[Volume]` | Bare list | iterate directly |
| `daytona.list(query?)` | `Iterator[Sandbox]` | `AsyncIterator[Sandbox]` | Lazy iterator | `for sandbox in daytona.list()` |
`PaginatedSnapshots` and `ListSecretsResponse` are **wrapper objects**, not lists. Calling list methods like `.append()` directly on them raises `AttributeError`. Always go through `.items`:
```python
# snapshots — page-number pagination
result = daytona.snapshot.list(page=1, limit=20)
# result.items → list[Snapshot]
# result.total → int (total across all pages)
# result.page → int (current page, 1-indexed)
# result.total_pages → int
for snapshot in result.items:
print(snapshot.name)
# secrets — cursor pagination
cursor = None
while True:
page = daytona.secret.list(cursor=cursor, limit=50)
# page.items → list[Secret]
# page.total → int
# page.next_cursor → str | None (None = no more pages)
for secret in page.items:
print(secret.name)
if page.next_cursor is None:
break
cursor = page.next_cursor
# volumes — bare list, iterate directly
volumes = daytona.volume.list()
for vol in volumes:
print(vol.name)
# sandboxes — lazy iterator, fetches pages on demand
from daytona import ListSandboxesQuery
for sandbox in daytona.list(ListSandboxesQuery(labels={"env": "dev"})):
print(sandbox.id)
```
The async client (`AsyncDaytona`) uses the same field names. Replace `for sandbox in` with `async for sandbox in` for the sandbox iterator.
نیازمندی
| مقدار | نام |
|---|---|
| - | Deprecated<2.0.0,>=1.2.18 |
| - | aiofiles<25.2.0,>=24.1.0 |
| - | aiohttp<4.0.0,>=3.14.1 |
| - | daytona-analytics-api-client==0.227.0 |
| - | daytona-analytics-api-client-async==0.227.0 |
| - | daytona-api-client==0.227.0 |
| - | daytona-api-client-async==0.227.0 |
| - | daytona-toolbox-api-client==0.227.0 |
| - | daytona-toolbox-api-client-async==0.227.0 |
| - | httpx<0.29.0,>=0.28.0 |
| - | httpx-ws<1.0.0,>=0.7.0 |
| - | obstore<0.12.0,>=0.8.0 |
| - | opentelemetry-api<2.0.0,>=1.27.0 |
| - | opentelemetry-exporter-otlp-proto-http<2.0.0,>=1.27.0 |
| - | opentelemetry-instrumentation-aiohttp-client>=0.59b0 |
| - | opentelemetry-sdk<2.0.0,>=1.27.0 |
| - | pydantic<3.0.0,>=2.4.2 |
| - | python-dotenv<2.0.0,>=1.0.0 |
| - | python-multipart<0.1.0,>=0.0.31 |
| - | python-socketio[asyncio-client,client]<6.0.0,>=5.0.0 |
| - | toml<0.11.0,>=0.10.0 |
| - | typing-extensions>=4.0.0 |
| - | urllib3<3.0.0,>=2.1.0 |
| - | wsproto<2.0.0,>=1.2.0 |
زبان مورد نیاز
| مقدار | نام |
|---|---|
| <4.0,>=3.10 | Python |
نحوه نصب
نصب پکیج whl daytona-2.0.0rc1:
pip install daytona.whl
نصب پکیج tar.gz daytona-2.0.0rc1:
pip install daytona.tar.gz