e2b-desktop


Namee2b-desktop JSON
Version 2.0.0 PyPI version JSON
download
home_pagehttps://e2b.dev/
SummaryE2B Desktop Sandbox - Deskstop sandbox in cloud powered by E2B
upload_time2025-08-28 08:31:13
maintainerNone
docs_urlNone
authore2b
requires_python<4.0,>=3.9
licenseMIT
keywords
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # E2B Desktop Sandbox - Virtual Computer for Computer Use

E2B Desktop Sandbox is a secure virtual desktop ready for Computer Use. Powered by [E2B](https://e2b.dev).

Each sandbox is isolated from the others and can be customized with any dependencies you want.

![Desktop Sandbox](../../readme-assets/screenshot.png)

## Examples

### Open computer use

Check out the [example open-source app](https://github.com/e2b-dev/open-computer-use) in a separate repository.

### Basic SDK usage examples

Check out the examples directory for more examples on how to use the SDK:

- [Python](./examples/basic-python)
- [JavaScript](./examples/basic-javascript)

## 🚀 Getting started

The E2B Desktop Sandbox is built on top of [E2B Sandbox](https://e2b.dev/docs).

### 1. Get E2B API key

Sign up at [E2B](https://e2b.dev) and get your API key.
Set environment variable `E2B_API_KEY` with your API key.

### 2. Install SDK

```bash
pip install e2b-desktop
```

### 3. Create Desktop Sandbox

```python
from e2b_desktop import Sandbox

# Create a new desktop sandbox
desktop = Sandbox.create()

# Launch an application
desktop.launch('google-chrome')  # or vscode, firefox, etc.

# Wait 10s for the application to open
desktop.wait(10000)

# Stream the application's window
# Note: There can be only one stream at a time
# You need to stop the current stream before streaming another application
desktop.stream.start(
    window_id=desktop.get_current_window_id(), # if not provided the whole desktop will be streamed
    require_auth=True
)

# Get the stream auth key
auth_key = desktop.stream.get_auth_key()

# Print the stream URL
print('Stream URL:', desktop.stream.get_url(auth_key=auth_key))

# Kill the sandbox after the tasks are finished
# desktop.kill()
```

## Features

### Streaming desktop's screen

```python
from e2b_desktop import Sandbox
desktop = Sandbox.create()

# Start the stream
desktop.stream.start()

# Get stream URL
url = desktop.stream.get_url()
print(url)

# Stop the stream
desktop.stream.stop()
```

### Streaming with password protection

```python
from e2b_desktop import Sandbox
desktop = Sandbox.create()

# Start the stream
desktop.stream.start(
    require_auth=True  # Enable authentication with an auto-generated key
)

# Retrieve the authentication key
auth_key = desktop.stream.get_auth_key()

# Get stream URL
url = desktop.stream.get_url(auth_key=auth_key)
print(url)

# Stop the stream
desktop.stream.stop()
```

### Streaming specific application

> [!WARNING]
>
> - Will raise an error if the desired application is not open yet
> - The stream will close once the application closes
> - Creating multiple streams at the same time is not supported, you may have to stop the current stream and start a new one for each application

```python
from e2b_desktop import Sandbox
desktop = Sandbox.create()

# Get current (active) window ID
window_id = desktop.get_current_window_id()

# Get all windows of the application
window_ids = desktop.get_application_windows("Firefox")

# Start the stream
desktop.stream.start(window_id=window_ids[0])

# Stop the stream
desktop.stream.stop()
```

### Mouse control

```python
from e2b_desktop import Sandbox
desktop = Sandbox.create()

desktop.double_click()
desktop.left_click()
desktop.left_click(x=100, y=200)
desktop.right_click()
desktop.right_click(x=100, y=200)
desktop.middle_click()
desktop.middle_click(x=100, y=200)
desktop.scroll(10) # Scroll by the amount. Positive for up, negative for down.
desktop.move_mouse(100, 200) # Move to x, y coordinates
desktop.drag((100, 100), (200, 200)) # Drag using the mouse
desktop.mouse_press("left") # Press the mouse button
desktop.mouse_release("left") # Release the mouse button
```

### Keyboard control

```python
from e2b_desktop import Sandbox
desktop = Sandbox.create()

# Write text at the current cursor position with customizable typing speed
desktop.write("Hello, world!")  # Default: chunk_size=25, delay_in_ms=75
desktop.write("Fast typing!", chunk_size=50, delay_in_ms=25)  # Faster typing

# Press keys
desktop.press("enter")
desktop.press("space")
desktop.press("backspace")
desktop.press(["ctrl", "c"]) # Key combination
```

### Window control

```python
from e2b_desktop import Sandbox
desktop = Sandbox.create()

# Get current (active) window ID
window_id = desktop.get_current_window_id()

# Get all windows of the application
window_ids = desktop.get_application_windows("Firefox")

# Get window title
title = desktop.get_window_title(window_id)
```

### Screenshot

```python
from e2b_desktop import Sandbox
desktop = Sandbox.create()

# Take a screenshot and save it as "screenshot.png" locally
image = desktop.screenshot()
# Save the image to a file
with open("screenshot.png", "wb") as f:
    f.write(image)
```

### Open file

```python
from e2b_desktop import Sandbox
desktop = Sandbox.create()

# Open file with default application
desktop.files.write("/home/user/index.js", "console.log('hello')") # First create the file
desktop.open("/home/user/index.js") # Then open it
```

### Launch applications

```python
from e2b_desktop import Sandbox
desktop = Sandbox.create()

# Launch the application
desktop.launch('google-chrome')
```

### Run any bash commands

```python
from e2b_desktop import Sandbox
desktop = Sandbox.create()

# Run any bash command
out = desktop.commands.run("ls -la /home/user")
print(out)
```

### Wait

```python
from e2b_desktop import Sandbox
desktop = Sandbox.create()

desktop.wait(1000) # Wait for 1 second
```

## Under the hood

The desktop-like environment is based on Linux and [Xfce](https://www.xfce.org/) at the moment. We chose Xfce because it's a fast and lightweight environment that's also popular and actively supported. However, this Sandbox template is fully customizable and you can create your own desktop environment.
Check out the sandbox template's code [here](./template/).

            

Raw data

            {
    "_id": null,
    "home_page": "https://e2b.dev/",
    "name": "e2b-desktop",
    "maintainer": null,
    "docs_url": null,
    "requires_python": "<4.0,>=3.9",
    "maintainer_email": null,
    "keywords": null,
    "author": "e2b",
    "author_email": "hello@e2b.dev",
    "download_url": "https://files.pythonhosted.org/packages/51/4e/a7db8c9775da1ba7762841f727ad3dea7cbc808696df448d862ca6a40189/e2b_desktop-2.0.0.tar.gz",
    "platform": null,
    "description": "# E2B Desktop Sandbox - Virtual Computer for Computer Use\n\nE2B Desktop Sandbox is a secure virtual desktop ready for Computer Use. Powered by [E2B](https://e2b.dev).\n\nEach sandbox is isolated from the others and can be customized with any dependencies you want.\n\n![Desktop Sandbox](../../readme-assets/screenshot.png)\n\n## Examples\n\n### Open computer use\n\nCheck out the [example open-source app](https://github.com/e2b-dev/open-computer-use) in a separate repository.\n\n### Basic SDK usage examples\n\nCheck out the examples directory for more examples on how to use the SDK:\n\n- [Python](./examples/basic-python)\n- [JavaScript](./examples/basic-javascript)\n\n## \ud83d\ude80 Getting started\n\nThe E2B Desktop Sandbox is built on top of [E2B Sandbox](https://e2b.dev/docs).\n\n### 1. Get E2B API key\n\nSign up at [E2B](https://e2b.dev) and get your API key.\nSet environment variable `E2B_API_KEY` with your API key.\n\n### 2. Install SDK\n\n```bash\npip install e2b-desktop\n```\n\n### 3. Create Desktop Sandbox\n\n```python\nfrom e2b_desktop import Sandbox\n\n# Create a new desktop sandbox\ndesktop = Sandbox.create()\n\n# Launch an application\ndesktop.launch('google-chrome')  # or vscode, firefox, etc.\n\n# Wait 10s for the application to open\ndesktop.wait(10000)\n\n# Stream the application's window\n# Note: There can be only one stream at a time\n# You need to stop the current stream before streaming another application\ndesktop.stream.start(\n    window_id=desktop.get_current_window_id(), # if not provided the whole desktop will be streamed\n    require_auth=True\n)\n\n# Get the stream auth key\nauth_key = desktop.stream.get_auth_key()\n\n# Print the stream URL\nprint('Stream URL:', desktop.stream.get_url(auth_key=auth_key))\n\n# Kill the sandbox after the tasks are finished\n# desktop.kill()\n```\n\n## Features\n\n### Streaming desktop's screen\n\n```python\nfrom e2b_desktop import Sandbox\ndesktop = Sandbox.create()\n\n# Start the stream\ndesktop.stream.start()\n\n# Get stream URL\nurl = desktop.stream.get_url()\nprint(url)\n\n# Stop the stream\ndesktop.stream.stop()\n```\n\n### Streaming with password protection\n\n```python\nfrom e2b_desktop import Sandbox\ndesktop = Sandbox.create()\n\n# Start the stream\ndesktop.stream.start(\n    require_auth=True  # Enable authentication with an auto-generated key\n)\n\n# Retrieve the authentication key\nauth_key = desktop.stream.get_auth_key()\n\n# Get stream URL\nurl = desktop.stream.get_url(auth_key=auth_key)\nprint(url)\n\n# Stop the stream\ndesktop.stream.stop()\n```\n\n### Streaming specific application\n\n> [!WARNING]\n>\n> - Will raise an error if the desired application is not open yet\n> - The stream will close once the application closes\n> - Creating multiple streams at the same time is not supported, you may have to stop the current stream and start a new one for each application\n\n```python\nfrom e2b_desktop import Sandbox\ndesktop = Sandbox.create()\n\n# Get current (active) window ID\nwindow_id = desktop.get_current_window_id()\n\n# Get all windows of the application\nwindow_ids = desktop.get_application_windows(\"Firefox\")\n\n# Start the stream\ndesktop.stream.start(window_id=window_ids[0])\n\n# Stop the stream\ndesktop.stream.stop()\n```\n\n### Mouse control\n\n```python\nfrom e2b_desktop import Sandbox\ndesktop = Sandbox.create()\n\ndesktop.double_click()\ndesktop.left_click()\ndesktop.left_click(x=100, y=200)\ndesktop.right_click()\ndesktop.right_click(x=100, y=200)\ndesktop.middle_click()\ndesktop.middle_click(x=100, y=200)\ndesktop.scroll(10) # Scroll by the amount. Positive for up, negative for down.\ndesktop.move_mouse(100, 200) # Move to x, y coordinates\ndesktop.drag((100, 100), (200, 200)) # Drag using the mouse\ndesktop.mouse_press(\"left\") # Press the mouse button\ndesktop.mouse_release(\"left\") # Release the mouse button\n```\n\n### Keyboard control\n\n```python\nfrom e2b_desktop import Sandbox\ndesktop = Sandbox.create()\n\n# Write text at the current cursor position with customizable typing speed\ndesktop.write(\"Hello, world!\")  # Default: chunk_size=25, delay_in_ms=75\ndesktop.write(\"Fast typing!\", chunk_size=50, delay_in_ms=25)  # Faster typing\n\n# Press keys\ndesktop.press(\"enter\")\ndesktop.press(\"space\")\ndesktop.press(\"backspace\")\ndesktop.press([\"ctrl\", \"c\"]) # Key combination\n```\n\n### Window control\n\n```python\nfrom e2b_desktop import Sandbox\ndesktop = Sandbox.create()\n\n# Get current (active) window ID\nwindow_id = desktop.get_current_window_id()\n\n# Get all windows of the application\nwindow_ids = desktop.get_application_windows(\"Firefox\")\n\n# Get window title\ntitle = desktop.get_window_title(window_id)\n```\n\n### Screenshot\n\n```python\nfrom e2b_desktop import Sandbox\ndesktop = Sandbox.create()\n\n# Take a screenshot and save it as \"screenshot.png\" locally\nimage = desktop.screenshot()\n# Save the image to a file\nwith open(\"screenshot.png\", \"wb\") as f:\n    f.write(image)\n```\n\n### Open file\n\n```python\nfrom e2b_desktop import Sandbox\ndesktop = Sandbox.create()\n\n# Open file with default application\ndesktop.files.write(\"/home/user/index.js\", \"console.log('hello')\") # First create the file\ndesktop.open(\"/home/user/index.js\") # Then open it\n```\n\n### Launch applications\n\n```python\nfrom e2b_desktop import Sandbox\ndesktop = Sandbox.create()\n\n# Launch the application\ndesktop.launch('google-chrome')\n```\n\n### Run any bash commands\n\n```python\nfrom e2b_desktop import Sandbox\ndesktop = Sandbox.create()\n\n# Run any bash command\nout = desktop.commands.run(\"ls -la /home/user\")\nprint(out)\n```\n\n### Wait\n\n```python\nfrom e2b_desktop import Sandbox\ndesktop = Sandbox.create()\n\ndesktop.wait(1000) # Wait for 1 second\n```\n\n## Under the hood\n\nThe desktop-like environment is based on Linux and [Xfce](https://www.xfce.org/) at the moment. We chose Xfce because it's a fast and lightweight environment that's also popular and actively supported. However, this Sandbox template is fully customizable and you can create your own desktop environment.\nCheck out the sandbox template's code [here](./template/).\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "E2B Desktop Sandbox - Deskstop sandbox in cloud powered by E2B",
    "version": "2.0.0",
    "project_urls": {
        "Bug Tracker": "https://github.com/e2b-dev/desktop/issues",
        "Homepage": "https://e2b.dev/",
        "Repository": "https://github.com/e2b-dev/desktop/tree/main/packages/python-sdk"
    },
    "split_keywords": [],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "b0cc08fec8fae3dd88650b92a00c0895ca65e0387e08f2c34a3960a6ed8f8bf8",
                "md5": "558dc588042f9c0695f691797fae1a5d",
                "sha256": "4c8864485cf96cc004f828e9ca8d69a9a845b46b889942e2bb9a7cae2e7c5a78"
            },
            "downloads": -1,
            "filename": "e2b_desktop-2.0.0-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "558dc588042f9c0695f691797fae1a5d",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": "<4.0,>=3.9",
            "size": 9224,
            "upload_time": "2025-08-28T08:31:12",
            "upload_time_iso_8601": "2025-08-28T08:31:12.385454Z",
            "url": "https://files.pythonhosted.org/packages/b0/cc/08fec8fae3dd88650b92a00c0895ca65e0387e08f2c34a3960a6ed8f8bf8/e2b_desktop-2.0.0-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "514ea7db8c9775da1ba7762841f727ad3dea7cbc808696df448d862ca6a40189",
                "md5": "49e82b59be402e5eb7b243af6aa9007d",
                "sha256": "926a1c00edc65559a086bbf8c468a6f1b5c93bd6b16b2e219725cbded0f04b72"
            },
            "downloads": -1,
            "filename": "e2b_desktop-2.0.0.tar.gz",
            "has_sig": false,
            "md5_digest": "49e82b59be402e5eb7b243af6aa9007d",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": "<4.0,>=3.9",
            "size": 10111,
            "upload_time": "2025-08-28T08:31:13",
            "upload_time_iso_8601": "2025-08-28T08:31:13.568103Z",
            "url": "https://files.pythonhosted.org/packages/51/4e/a7db8c9775da1ba7762841f727ad3dea7cbc808696df448d862ca6a40189/e2b_desktop-2.0.0.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2025-08-28 08:31:13",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "e2b-dev",
    "github_project": "desktop",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "lcname": "e2b-desktop"
}
        
e2b
Elapsed time: 0.85750s