# 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:
```bash
pip install daytona
```
## Quick Start
Here's a simple example of using the SDK:
```python
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:
```python
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:
```python
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
```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
```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
```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
```python
# 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](/libs/sdk-python/LICENSE), and is the [copyright of its contributors](/NOTICE). 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](/CONTRIBUTING.md) to get started.
Code in [\_sync](/libs/sdk-python/src/daytona/_sync/) directory shouldn't be edited directly. It should be generated from the corresponding async code in the [\_async](/libs/sdk-python/src/daytona/_async/) directory using the [sync_generator.py](/libs/sdk-python/scripts/sync_generator.py) script.
Raw data
{
"_id": null,
"home_page": null,
"name": "daytona_sdk",
"maintainer": null,
"docs_url": null,
"requires_python": "<4.0,>=3.9",
"maintainer_email": null,
"keywords": "daytona, sdk",
"author": "Daytona Platforms Inc.",
"author_email": "support@daytona.io",
"download_url": "https://files.pythonhosted.org/packages/e7/ba/98b45f9eeb2078b2d9d3f779a4c0c02de0198bd2f7f3234c458a098f73d8/daytona_sdk-0.24.1.tar.gz",
"platform": null,
"description": "# Daytona SDK for Python\n\nA 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.\n\n## Installation\n\nYou can install the package using pip:\n\n```bash\npip install daytona\n```\n\n## Quick Start\n\nHere's a simple example of using the SDK:\n\n```python\nfrom daytona import Daytona\n\n# Initialize using environment variables\ndaytona = Daytona()\n\n# Create a sandbox\nsandbox = daytona.create()\n\n# Run code in the sandbox\nresponse = sandbox.process.code_run('print(\"Hello World!\")')\nprint(response.result)\n\n# Clean up when done\ndaytona.delete(sandbox)\n```\n\n## Configuration\n\nThe SDK can be configured using environment variables or by passing a configuration object:\n\n```python\nfrom daytona import Daytona, DaytonaConfig\n\n# Initialize with configuration\nconfig = DaytonaConfig(\n api_key=\"your-api-key\",\n api_url=\"your-api-url\",\n target=\"us\"\n)\ndaytona = Daytona(config)\n```\n\nOr using environment variables:\n\n- `DAYTONA_API_KEY`: Your Daytona API key\n- `DAYTONA_API_URL`: The Daytona API URL\n- `DAYTONA_TARGET`: Your target environment\n\nYou can also customize sandbox creation:\n\n```python\nsandbox = daytona.create(CreateSandboxFromSnapshotParams(\n language=\"python\",\n env_vars={\"PYTHON_ENV\": \"development\"},\n auto_stop_interval=60, # Auto-stop after 1 hour of inactivity\n auto_archive_interval=60, # Auto-archive after a Sandbox has been stopped for 1 hour\n auto_delete_interval=120 # Auto-delete after a Sandbox has been stopped for 2 hours\n))\n```\n\n## Features\n\n- **Sandbox Management**: Create, manage and remove sandboxes\n- **Git Operations**: Clone repositories, manage branches, and more\n- **File System Operations**: Upload, download, search and manipulate files\n- **Language Server Protocol**: Interact with language servers for code intelligence\n- **Process Management**: Execute code and commands in sandboxes\n\n## Examples\n\n### Execute Commands\n\n```python\n# Execute a shell command\nresponse = sandbox.process.exec('echo \"Hello, World!\"')\nprint(response.result)\n\n# Run Python code\nresponse = sandbox.process.code_run('''\nx = 10\ny = 20\nprint(f\"Sum: {x + y}\")\n''')\nprint(response.result)\n```\n\n### File Operations\n\n```python\n# Upload a file\nsandbox.fs.upload_file(b'Hello, World!', 'path/to/file.txt')\n\n# Download a file\ncontent = sandbox.fs.download_file('path/to/file.txt')\n\n# Search for files\nmatches = sandbox.fs.find_files(root_dir, 'search_pattern')\n```\n\n### Git Operations\n\n```python\n# Clone a repository\nsandbox.git.clone('https://github.com/example/repo', 'path/to/clone')\n\n# List branches\nbranches = sandbox.git.branches('path/to/repo')\n\n# Add files\nsandbox.git.add('path/to/repo', ['file1.txt', 'file2.txt'])\n```\n\n### Language Server Protocol\n\n```python\n# Create and start a language server\nlsp = sandbox.create_lsp_server('typescript', 'path/to/project')\nlsp.start()\n\n# Notify the lsp for the file\nlsp.did_open('path/to/file.ts')\n\n# Get document symbols\nsymbols = lsp.document_symbols('path/to/file.ts')\n\n# Get completions\ncompletions = lsp.completions('path/to/file.ts', {\"line\": 10, \"character\": 15})\n```\n\n## Contributing\n\nDaytona is Open Source under the [Apache License 2.0](/libs/sdk-python/LICENSE), and is the [copyright of its contributors](/NOTICE). 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](/CONTRIBUTING.md) to get started.\n\nCode in [\\_sync](/libs/sdk-python/src/daytona/_sync/) directory shouldn't be edited directly. It should be generated from the corresponding async code in the [\\_async](/libs/sdk-python/src/daytona/_async/) directory using the [sync_generator.py](/libs/sdk-python/scripts/sync_generator.py) script.\n",
"bugtrack_url": null,
"license": "Apache-2.0",
"summary": "Python SDK for Daytona",
"version": "0.24.1",
"project_urls": null,
"split_keywords": [
"daytona",
" sdk"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "d8c1e601e8f01298e414e379d0687ee4eb75d57e8a3e915cfa8249a7df23a7f4",
"md5": "29fb9ac82fc3789ce669e31833439ff1",
"sha256": "a9b06efd98bdcae87da9b612247212f8c6ca87c1140d33835c521878511a5dca"
},
"downloads": -1,
"filename": "daytona_sdk-0.24.1-py3-none-any.whl",
"has_sig": false,
"md5_digest": "29fb9ac82fc3789ce669e31833439ff1",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": "<4.0,>=3.9",
"size": 114946,
"upload_time": "2025-07-16T08:34:02",
"upload_time_iso_8601": "2025-07-16T08:34:02.525808Z",
"url": "https://files.pythonhosted.org/packages/d8/c1/e601e8f01298e414e379d0687ee4eb75d57e8a3e915cfa8249a7df23a7f4/daytona_sdk-0.24.1-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "e7ba98b45f9eeb2078b2d9d3f779a4c0c02de0198bd2f7f3234c458a098f73d8",
"md5": "8b6b2b4cbefe33bf64a1c9d2b3c15600",
"sha256": "ae46bc8a4783d0a60e7283e762e73f11f7a5e04fbc3769fcd95fc84e1de52903"
},
"downloads": -1,
"filename": "daytona_sdk-0.24.1.tar.gz",
"has_sig": false,
"md5_digest": "8b6b2b4cbefe33bf64a1c9d2b3c15600",
"packagetype": "sdist",
"python_version": "source",
"requires_python": "<4.0,>=3.9",
"size": 91636,
"upload_time": "2025-07-16T08:34:04",
"upload_time_iso_8601": "2025-07-16T08:34:04.316250Z",
"url": "https://files.pythonhosted.org/packages/e7/ba/98b45f9eeb2078b2d9d3f779a4c0c02de0198bd2f7f3234c458a098f73d8/daytona_sdk-0.24.1.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2025-07-16 08:34:04",
"github": false,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"lcname": "daytona_sdk"
}