Skip to content

armgit / E2B

Public Imported from GitHub
0

Open-source, secure environment with real-world tools for enterprise-grade agents.

updated mdx pages

0divcfef1ddf78dc
diff --git a/apps/web/src/app/(docs)/docs/api-reference/js-sdk/v1.0.5/sandbox/page.mdx b/apps/web/src/app/(docs)/docs/api-reference/js-sdk/v1.0.5/sandbox/page.mdx
index 60c5d97f2..099b14853 100644
--- a/apps/web/src/app/(docs)/docs/api-reference/js-sdk/v1.0.5/sandbox/page.mdx
+++ b/apps/web/src/app/(docs)/docs/api-reference/js-sdk/v1.0.5/sandbox/page.mdx
@@ -81,7 +81,7 @@ const sandbox = await Sandbox.create()
await sandbox.commands.exec('python3 -m http.server 3000')
// Get the hostname of the HTTP server
const serverURL = sandbox.getHost(3000)
-``
+```
### isRunning()
diff --git a/apps/web/src/app/(docs)/docs/api-reference/page.mdx b/apps/web/src/app/(docs)/docs/api-reference/page.mdx
new file mode 100644
index 000000000..d6b231b22
--- /dev/null
+++ b/apps/web/src/app/(docs)/docs/api-reference/page.mdx
@@ -0,0 +1,5 @@
+# API Reference
+
+This is the API reference for the E2B CLI, JS & Python packages, which allows you to run AI-generated code in secure isolated sandboxes in the cloud.
+
+The reference is intended to be limited to low-level descriptions of various programmatic functionality. If you’re just getting started with E2B, we would instead recommend looking at the [documentation](../docs) first or to get started quickly with an example.
diff --git a/apps/web/src/app/(docs)/docs/api-reference/python-sdk/v1.0.3/sandbox_async/page.mdx b/apps/web/src/app/(docs)/docs/api-reference/python-sdk/v1.0.3/sandbox_async/page.mdx
index 57bbc0ea5..e0973fd00 100644
--- a/apps/web/src/app/(docs)/docs/api-reference/python-sdk/v1.0.3/sandbox_async/page.mdx
+++ b/apps/web/src/app/(docs)/docs/api-reference/python-sdk/v1.0.3/sandbox_async/page.mdx
@@ -1,264 +1,24 @@
-
-
-## AsyncSandbox
-
-```python
-class AsyncSandbox(SandboxSetup, SandboxApi)
-```
-
-E2B cloud sandbox is a secure and isolated cloud environment.
-
-The sandbox allows you to:
-- Access Linux OS
-- Create, list, and delete files and directories
-- Run commands
-- Run isolated code
-- Access the internet
-
-Check docs [here](https://e2b.dev/docs).
-
-Use the `AsyncSandbox.create()` to create a new sandbox.
-
-**Example**:
-
-```python
-from e2b import AsyncSandbox
-
-sandbox = await AsyncSandbox.create()
-```
-
-
-#### files
-
-```python
-@property
-def files() -> Filesystem
-```
-
-Module for interacting with the sandbox filesystem.
-
-
-#### commands
-
-```python
-@property
-def commands() -> Commands
-```
-
-Module for running commands in the sandbox.
-
-
-#### pty
-
-```python
-@property
-def pty() -> Pty
-```
-
-Module for interacting with the sandbox pseudo-terminal.
-
-
-#### sandbox\_id
-
-```python
-@property
-def sandbox_id() -> str
-```
-
-Unique identifier of the sandbox.
-
-
-#### \_\_init\_\_
-
-```python
-def __init__(**opts: Unpack[AsyncSandboxOpts])
-```
-
-Use `AsyncSandbox.create()` to create a new sandbox instead.
-
-
-#### is\_running
-
-```python
-async def is_running(request_timeout: Optional[float] = None) -> bool
-```
-
-Check if the sandbox is running.
-
-**Arguments**:
-
-- `request_timeout`: Timeout for the request in **seconds**
-
-**Returns**:
-
-`True` if the sandbox is running, `False` otherwise
-Example
-```python
-sandbox = await AsyncSandbox.create()
-await sandbox.is_running() # Returns True
-
-await sandbox.kill()
-await sandbox.is_running() # Returns False
-```
-
-
-#### create
-
-```python
-@classmethod
-async def create(cls,
- template: Optional[str] = None,
- timeout: Optional[int] = None,
- metadata: Optional[Dict[str, str]] = None,
- envs: Optional[Dict[str, str]] = None,
- api_key: Optional[str] = None,
- domain: Optional[str] = None,
- debug: Optional[bool] = None,
- request_timeout: Optional[float] = None)
-```
-
-Create a new sandbox.
-
-By default, the sandbox is created from the default `base` sandbox template.
-
-**Arguments**:
-
-- `template`: Sandbox template name or ID
-- `timeout`: Timeout for the sandbox in **seconds**, default to 300 seconds. Maximum time a sandbox can be kept alive is 24 hours (86_400 seconds) for Pro users and 1 hour (3_600 seconds) for Hobby users.
-- `metadata`: Custom metadata for the sandbox
-- `envs`: Custom environment variables for the sandbox
-- `api_key`: E2B API Key to use for authentication, defaults to `E2B_API_KEY` environment variable
-- `request_timeout`: Timeout for the request in **seconds**
-
-**Returns**:
-
-sandbox instance for the new sandbox
-Use this method instead of using the constructor to create a new sandbox.
-
-
-#### connect
-
-```python
-@classmethod
-async def connect(cls,
- sandbox_id: str,
- api_key: Optional[str] = None,
- domain: Optional[str] = None,
- debug: Optional[bool] = None)
-```
-
-Connect to an existing sandbox.
-
-With sandbox ID you can connect to the same sandbox from different places or environments (serverless functions, etc).
-
-**Arguments**:
-
-- `sandbox_id`: Sandbox ID
-- `api_key`: E2B API Key to use for authentication, defaults to `E2B_API_KEY` environment variable
-
-**Returns**:
-
-sandbox instance for the existing sandbox
-@example
-```python
-sandbox = await AsyncSandbox.create()
-sandbox_id = sandbox.sandbox_id
-
-same_sandbox = await AsyncSandbox.connect(sandbox_id)
-
-
-#### kill
-
-```python
-@overload
-async def kill(request_timeout: Optional[float] = None) -> bool
-```
-
-Kill the sandbox.
-
-**Arguments**:
-
-- `request_timeout`: Timeout for the request in **seconds**
-
-**Returns**:
-
-`True` if the sandbox was killed, `False` if the sandbox was not found
-
-
-#### kill
-
-```python
-@overload
-@staticmethod
-async def kill(sandbox_id: str,
- api_key: Optional[str] = None,
- domain: Optional[str] = None,
- debug: Optional[bool] = None,
- request_timeout: Optional[float] = None) -> bool
-```
-
-Kill the sandbox specified by sandbox ID.
-
-**Arguments**:
-
-- `sandbox_id`: Sandbox ID
-- `api_key`: E2B API Key to use for authentication, defaults to `E2B_API_KEY` environment variable
-- `request_timeout`: Timeout for the request in **seconds**
-
-**Returns**:
-
-`True` if the sandbox was killed, `False` if the sandbox was not found
-
-
-#### set\_timeout
+## AsyncWatchHandle
```python
-@overload
-async def set_timeout(timeout: int,
- request_timeout: Optional[float] = None) -> None
+class AsyncWatchHandle()
```
-Set the timeout of the sandbox.
-
-After the timeout expires the sandbox will be automatically killed.
-This method can extend or reduce the sandbox timeout set when creating the sandbox or from the last call to `.set_timeout`.
-
-Maximum time a sandbox can be kept alive is 24 hours (86_400 seconds) for Pro users and 1 hour (3_600 seconds) for Hobby users.
-
-**Arguments**:
+Handle for watching a directory in the sandbox filesystem.
-- `timeout`: Timeout for the sandbox in **seconds**
-- `request_timeout`: Timeout for the request in **seconds**
+Use `.stop()` to stop watching the directory.
-#### set\_timeout
+### stop
```python
-@overload
-@staticmethod
-async def set_timeout(sandbox_id: str,
- timeout: int,
- api_key: Optional[str] = None,
- domain: Optional[str] = None,
- debug: Optional[bool] = None,
- request_timeout: Optional[float] = None) -> None
+async def stop()
```
-Set the timeout of the specified sandbox.
-
-After the timeout expires the sandbox will be automatically killed.
-This method can extend or reduce the sandbox timeout set when creating the sandbox or from the last call to `.set_timeout`.
-
-Maximum time a sandbox can be kept alive is 24 hours (86_400 seconds) for Pro users and 1 hour (3_600 seconds) for Hobby users.
-
-**Arguments**:
-
-- `sandbox_id`: Sandbox ID
-- `timeout`: Timeout for the sandbox in **seconds**
-- `request_timeout`: Timeout for the request in **seconds**
+Stop watching the directory.
@@ -272,7 +32,7 @@ class Filesystem()
Module for interacting with the filesystem in the sandbox.
-#### read
+### read
```python
@overload
@@ -296,7 +56,7 @@ Read file content as a `str`.
File content as a `str`
-#### read
+### read
```python
@overload
@@ -320,7 +80,7 @@ Read file content as a `bytearray`.
File content as a `bytearray`
-#### read
+### read
```python
@overload
@@ -345,7 +105,7 @@ Read file content as a `AsyncIterator[bytes]`.
File content as an `AsyncIterator[bytes]`
-#### write
+### write
```python
async def write(path: str,
@@ -374,7 +134,7 @@ Writing to a file at path that doesn't exist creates the necessary directories.
Information about the written file
-#### list
+### list
```python
async def list(path: str,
@@ -395,7 +155,7 @@ List entries in a directory.
List of entries in the directory
-#### exists
+### exists
```python
async def exists(path: str,
@@ -416,7 +176,7 @@ Check if a file or a directory exists.
`True` if the file or directory exists, `False` otherwise
-#### remove
+### remove
```python
async def remove(path: str,
@@ -433,7 +193,7 @@ Remove a file or a directory.
- `request_timeout`: Timeout for the request in **seconds**
-#### rename
+### rename
```python
async def rename(old_path: str,
@@ -456,7 +216,7 @@ Rename a file or directory.
Information about the renamed file or directory
-#### make\_dir
+### make\_dir
```python
async def make_dir(path: str,
@@ -477,7 +237,7 @@ Create a new directory and all directories along the way if needed on the specif
`True` if the directory was created, `False` if the directory already exists
-#### watch\_dir
+### watch\_dir
```python
async def watch_dir(path: str,
@@ -506,26 +266,38 @@ Watch directory for filesystem events.
-## AsyncWatchHandle
-
-```python
-class AsyncWatchHandle()
-```
-
-Handle for watching a directory in the sandbox filesystem.
-
-Use `.stop()` to stop watching the directory.
-#### stop
+## SandboxApi
```python
-async def stop()
+class SandboxApi(SandboxApiBase)
```
-Stop watching the directory.
-
-
+
+### list
+
+```python
+@classmethod
+async def list(cls,
+ api_key: Optional[str] = None,
+ domain: Optional[str] = None,
+ debug: Optional[bool] = None,
+ request_timeout: Optional[float] = None) -> List[SandboxInfo]
+```
+
+List all running sandboxes.
+
+**Arguments**:
+
+- `api_key`: API key to use for authentication, defaults to `E2B_API_KEY` environment variable
+- `request_timeout`: Timeout for the request in **seconds**
+
+**Returns**:
+
+List of running sandboxes
+
+
## Commands
@@ -537,7 +309,7 @@ class Commands()
Module for executing commands in the sandbox.
-#### list
+### list
```python
async def list(request_timeout: Optional[float] = None) -> List[ProcessInfo]
@@ -554,7 +326,7 @@ Lists all running commands and PTY sessions.
List of running commands and PTY sessions
-#### kill
+### kill
```python
async def kill(pid: int, request_timeout: Optional[float] = None) -> bool
@@ -574,7 +346,7 @@ It uses `SIGKILL` signal to kill the command.
`True` if the command was killed, `False` if the command was not found
-#### send\_stdin
+### send\_stdin
```python
async def send_stdin(pid: int,
@@ -590,7 +362,7 @@ Send data to command stdin.
-#### run
+### run
```python
@overload
@@ -624,7 +396,7 @@ Start a new command and wait until it finishes executing.
`CommandResult` result of the command execution
-#### run
+### run
```python
@overload
@@ -658,7 +430,7 @@ Start a new command and return a handle to interact with it.
`AsyncCommandHandle` handle to interact with the running command
-#### connect
+### connect
```python
async def connect(
@@ -689,6 +461,115 @@ You can use `AsyncCommandHandle.wait()` to wait for the command to finish and ge
+## AsyncCommandHandle
+
+```python
+class AsyncCommandHandle()
+```
+
+Command execution handle.
+
+It provides methods for waiting for the command to finish, retrieving stdout/stderr, and killing the command.
+
+
+### pid
+
+```python
+@property
+def pid()
+```
+
+Command process ID.
+
+
+### stdout
+
+```python
+@property
+def stdout()
+```
+
+Command stdout output.
+
+
+### stderr
+
+```python
+@property
+def stderr()
+```
+
+Command stderr output.
+
+
+### error
+
+```python
+@property
+def error()
+```
+
+Command execution error message.
+
+
+### exit\_code
+
+```python
+@property
+def exit_code()
+```
+
+Command execution exit code.
+
+`0` if the command finished successfully.
+
+It is `None` if the command is still running.
+
+
+### disconnect
+
+```python
+async def disconnect() -> None
+```
+
+Disconnects from the command.
+
+The command is not killed, but SDK stops receiving events from the command.
+You can reconnect to the command using `sandbox.commands.connect` method.
+
+
+### wait
+
+```python
+async def wait() -> CommandResult
+```
+
+Wait for the command to finish and return the result.
+
+If the command exits with a non-zero exit code, it throws a `CommandExitException`.
+
+**Returns**:
+
+`CommandResult` result of command execution
+
+
+### kill
+
+```python
+async def kill() -> bool
+```
+
+Kills the command.
+
+It uses `SIGKILL` signal to kill the command
+
+**Returns**:
+
+`True` if the command was killed successfully, `False` if the command was not found
+
+
+
+
## Pty
```python
@@ -698,7 +579,7 @@ class Pty()
Module for interacting with PTYs (pseudo-terminals) in the sandbox.
-#### kill
+### kill
```python
async def kill(pid: int, request_timeout: Optional[float] = None) -> bool
@@ -716,7 +597,7 @@ Kill PTY.
`true` if the PTY was killed, `false` if the PTY was not found
-#### send\_stdin
+### send\_stdin
```python
async def send_stdin(pid: int,
@@ -733,7 +614,7 @@ Send input to a PTY.
- `request_timeout`: Timeout for the request in **seconds**
-#### create
+### create
```python
async def create(
@@ -763,7 +644,7 @@ Start a new PTY (pseudo-terminal).
Handle to interact with the PTY
-#### resize
+### resize
```python
async def resize(pid: int,
@@ -784,141 +665,260 @@ Call this when the terminal window is resized and the number of columns and rows
-## AsyncCommandHandle
+## AsyncSandbox
```python
-class AsyncCommandHandle()
+class AsyncSandbox(SandboxSetup, SandboxApi)
```
-Command execution handle.
+E2B cloud sandbox is a secure and isolated cloud environment.
-It provides methods for waiting for the command to finish, retrieving stdout/stderr, and killing the command.
+The sandbox allows you to:
+- Access Linux OS
+- Create, list, and delete files and directories
+- Run commands
+- Run isolated code
+- Access the internet
+Check docs [here](https://e2b.dev/docs).
-#### pid
+Use the `AsyncSandbox.create()` to create a new sandbox.
+
+**Example**:
```python
-@property
-def pid()
-```
+from e2b import AsyncSandbox
-Command process ID.
+sandbox = await AsyncSandbox.create()
+```
-#### stdout
+### files
```python
@property
-def stdout()
+def files() -> Filesystem
```
-Command stdout output.
+Module for interacting with the sandbox filesystem.
-#### stderr
+### commands
```python
@property
-def stderr()
+def commands() -> Commands
```
-Command stderr output.
+Module for running commands in the sandbox.
-#### error
+### pty
```python
@property
-def error()
+def pty() -> Pty
```
-Command execution error message.
+Module for interacting with the sandbox pseudo-terminal.
-#### exit\_code
+### sandbox\_id
```python
@property
-def exit_code()
+def sandbox_id() -> str
```
-Command execution exit code.
+Unique identifier of the sandbox.
-`0` if the command finished successfully.
-It is `None` if the command is still running.
+### \_\_init\_\_
+
+```python
+def __init__(**opts: Unpack[AsyncSandboxOpts])
+```
+
+Use `AsyncSandbox.create()` to create a new sandbox instead.
-#### disconnect
+### is\_running
```python
-async def disconnect() -> None
+async def is_running(request_timeout: Optional[float] = None) -> bool
```
-Disconnects from the command.
+Check if the sandbox is running.
-The command is not killed, but SDK stops receiving events from the command.
-You can reconnect to the command using `sandbox.commands.connect` method.
+**Arguments**:
+- `request_timeout`: Timeout for the request in **seconds**
-#### wait
+**Returns**:
+`True` if the sandbox is running, `False` otherwise
+Example
```python
-async def wait() -> CommandResult
+sandbox = await AsyncSandbox.create()
+await sandbox.is_running() # Returns True
+
+await sandbox.kill()
+await sandbox.is_running() # Returns False
```
-Wait for the command to finish and return the result.
-If the command exits with a non-zero exit code, it throws a `CommandExitException`.
+### create
+
+```python
+@classmethod
+async def create(cls,
+ template: Optional[str] = None,
+ timeout: Optional[int] = None,
+ metadata: Optional[Dict[str, str]] = None,
+ envs: Optional[Dict[str, str]] = None,
+ api_key: Optional[str] = None,
+ domain: Optional[str] = None,
+ debug: Optional[bool] = None,
+ request_timeout: Optional[float] = None)
+```
+
+Create a new sandbox.
+
+By default, the sandbox is created from the default `base` sandbox template.
+
+**Arguments**:
+
+- `template`: Sandbox template name or ID
+- `timeout`: Timeout for the sandbox in **seconds**, default to 300 seconds. Maximum time a sandbox can be kept alive is 24 hours (86_400 seconds) for Pro users and 1 hour (3_600 seconds) for Hobby users.
+- `metadata`: Custom metadata for the sandbox
+- `envs`: Custom environment variables for the sandbox
+- `api_key`: E2B API Key to use for authentication, defaults to `E2B_API_KEY` environment variable
+- `request_timeout`: Timeout for the request in **seconds**
**Returns**:
-`CommandResult` result of command execution
+sandbox instance for the new sandbox
+Use this method instead of using the constructor to create a new sandbox.
-#### kill
+### connect
```python
-async def kill() -> bool
+@classmethod
+async def connect(cls,
+ sandbox_id: str,
+ api_key: Optional[str] = None,
+ domain: Optional[str] = None,
+ debug: Optional[bool] = None)
```
-Kills the command.
+Connect to an existing sandbox.
-It uses `SIGKILL` signal to kill the command
+With sandbox ID you can connect to the same sandbox from different places or environments (serverless functions, etc).
-**Returns**:
+**Arguments**:
-`True` if the command was killed successfully, `False` if the command was not found
+- `sandbox_id`: Sandbox ID
+- `api_key`: E2B API Key to use for authentication, defaults to `E2B_API_KEY` environment variable
+**Returns**:
+sandbox instance for the existing sandbox
+@example
+```python
+sandbox = await AsyncSandbox.create()
+sandbox_id = sandbox.sandbox_id
+same_sandbox = await AsyncSandbox.connect(sandbox_id)
-## SandboxApi
+
+### kill
```python
-class SandboxApi(SandboxApiBase)
+@overload
+async def kill(request_timeout: Optional[float] = None) -> bool
```
+Kill the sandbox.
+
+**Arguments**:
+
+- `request_timeout`: Timeout for the request in **seconds**
+
+**Returns**:
+
+`True` if the sandbox was killed, `False` if the sandbox was not found
-#### list
+
+### kill
```python
-@classmethod
-async def list(cls,
+@overload
+@staticmethod
+async def kill(sandbox_id: str,
api_key: Optional[str] = None,
domain: Optional[str] = None,
debug: Optional[bool] = None,
- request_timeout: Optional[float] = None) -> List[SandboxInfo]
+ request_timeout: Optional[float] = None) -> bool
```
-List all running sandboxes.
+Kill the sandbox specified by sandbox ID.
**Arguments**:
-- `api_key`: API key to use for authentication, defaults to `E2B_API_KEY` environment variable
+- `sandbox_id`: Sandbox ID
+- `api_key`: E2B API Key to use for authentication, defaults to `E2B_API_KEY` environment variable
- `request_timeout`: Timeout for the request in **seconds**
**Returns**:
-List of running sandboxes
+`True` if the sandbox was killed, `False` if the sandbox was not found
+
+
+### set\_timeout
+
+```python
+@overload
+async def set_timeout(timeout: int,
+ request_timeout: Optional[float] = None) -> None
+```
+
+Set the timeout of the sandbox.
+
+After the timeout expires the sandbox will be automatically killed.
+This method can extend or reduce the sandbox timeout set when creating the sandbox or from the last call to `.set_timeout`.
+
+Maximum time a sandbox can be kept alive is 24 hours (86_400 seconds) for Pro users and 1 hour (3_600 seconds) for Hobby users.
+
+**Arguments**:
+
+- `timeout`: Timeout for the sandbox in **seconds**
+- `request_timeout`: Timeout for the request in **seconds**
+
+
+### set\_timeout
+
+```python
+@overload
+@staticmethod
+async def set_timeout(sandbox_id: str,
+ timeout: int,
+ api_key: Optional[str] = None,
+ domain: Optional[str] = None,
+ debug: Optional[bool] = None,
+ request_timeout: Optional[float] = None) -> None
+```
+
+Set the timeout of the specified sandbox.
+
+After the timeout expires the sandbox will be automatically killed.
+This method can extend or reduce the sandbox timeout set when creating the sandbox or from the last call to `.set_timeout`.
+
+Maximum time a sandbox can be kept alive is 24 hours (86_400 seconds) for Pro users and 1 hour (3_600 seconds) for Hobby users.
+
+**Arguments**:
+
+- `sandbox_id`: Sandbox ID
+- `timeout`: Timeout for the sandbox in **seconds**
+- `request_timeout`: Timeout for the request in **seconds**
diff --git a/apps/web/src/app/(docs)/docs/api-reference/python-sdk/v1.0.3/sandbox_sync/page.mdx b/apps/web/src/app/(docs)/docs/api-reference/python-sdk/v1.0.3/sandbox_sync/page.mdx
index ee88ace74..85edf462c 100644
--- a/apps/web/src/app/(docs)/docs/api-reference/python-sdk/v1.0.3/sandbox_sync/page.mdx
+++ b/apps/web/src/app/(docs)/docs/api-reference/python-sdk/v1.0.3/sandbox_sync/page.mdx
@@ -1,269 +1,39 @@
-## Sandbox
-
-```python
-class Sandbox(SandboxSetup, SandboxApi)
-```
-
-E2B cloud sandbox is a secure and isolated cloud environment.
-
-The sandbox allows you to:
-- Access Linux OS
-- Create, list, and delete files and directories
-- Run commands
-- Run isolated code
-- Access the internet
-
-Check docs [here](https://e2b.dev/docs).
-
-Use the `Sandbox()` to create a new sandbox.
-
-**Example**:
-
-```python
-from e2b import Sandbox
-
-sandbox = Sandbox()
-```
-
-
-#### files
-
-```python
-@property
-def files() -> Filesystem
-```
-
-Module for interacting with the sandbox filesystem.
-
-
-#### commands
-
-```python
-@property
-def commands() -> Commands
-```
-
-Module for running commands in the sandbox.
-
-
-#### pty
-
-```python
-@property
-def pty() -> Pty
-```
-
-Module for interacting with the sandbox pseudo-terminal.
-
-
-#### sandbox\_id
-
-```python
-@property
-def sandbox_id() -> str
-```
-
-Unique identifier of the sandbox
-
-
-#### \_\_init\_\_
-
-```python
-def __init__(template: Optional[str] = None,
- timeout: Optional[int] = None,
- metadata: Optional[Dict[str, str]] = None,
- envs: Optional[Dict[str, str]] = None,
- api_key: Optional[str] = None,
- domain: Optional[str] = None,
- debug: Optional[bool] = None,
- sandbox_id: Optional[str] = None,
- request_timeout: Optional[float] = None)
-```
-
-Create a new sandbox.
-
-By default, the sandbox is created from the default `base` sandbox template.
-
-**Arguments**:
-
-- `template`: Sandbox template name or ID
-- `timeout`: Timeout for the sandbox in **seconds**, default to 300 seconds. Maximum time a sandbox can be kept alive is 24 hours (86_400 seconds) for Pro users and 1 hour (3_600 seconds) for Hobby users
-- `metadata`: Custom metadata for the sandbox
-- `envs`: Custom environment variables for the sandbox
-- `api_key`: E2B API Key to use for authentication, defaults to `E2B_API_KEY` environment variable
-- `request_timeout`: Timeout for the request in **seconds**
-
-**Returns**:
-
-sandbox instance for the new sandbox
-
-
-#### is\_running
-
-```python
-def is_running(request_timeout: Optional[float] = None) -> bool
-```
-
-Check if the sandbox is running.
-
-**Arguments**:
-
-- `request_timeout`: Timeout for the request in **seconds**
-
-**Returns**:
-
-`True` if the sandbox is running, `False` otherwise
-Example
-```python
-sandbox = Sandbox()
-sandbox.is_running() # Returns True
-
-sandbox.kill()
-sandbox.is_running() # Returns False
-```
-
-
-#### connect
-
-```python
-@classmethod
-def connect(cls,
- sandbox_id: str,
- api_key: Optional[str] = None,
- domain: Optional[str] = None,
- debug: Optional[bool] = None)
-```
-
-Connects to an existing Sandbox.
-
-With sandbox ID you can connect to the same sandbox from different places or environments (serverless functions, etc).
-
-**Arguments**:
-
-- `sandbox_id`: Sandbox ID
-- `api_key`: E2B API Key to use for authentication, defaults to `E2B_API_KEY` environment variable
-
-**Returns**:
-
-sandbox instance for the existing sandbox
-@example
-```python
-sandbox = Sandbox()
-sandbox_id = sandbox.sandbox_id
-
-same_sandbox = Sandbox.connect(sandbox_id)
-
-
-#### kill
+## WatchHandle
```python
-@overload
-def kill(request_timeout: Optional[float] = None) -> bool
+class WatchHandle()
```
-Kill the sandbox.
-
-**Arguments**:
-
-- `request_timeout`: Timeout for the request in **seconds**
-
-**Returns**:
+Handle for watching filesystem events.
+It is used to get the latest events that have occurred in the watched directory.
-`True` if the sandbox was killed, `False` if the sandbox was not found
+Use `.stop()` to stop watching the directory.
-#### kill
+### stop
```python
-@overload
-@staticmethod
-def kill(sandbox_id: str,
- api_key: Optional[str] = None,
- domain: Optional[str] = None,
- debug: Optional[bool] = None,
- request_timeout: Optional[float] = None) -> bool
+def stop()
```
-Kill the sandbox specified by sandbox ID.
-
-**Arguments**:
-
-- `sandbox_id`: Sandbox ID
-- `api_key`: E2B API Key to use for authentication, defaults to `E2B_API_KEY` environment variable
-- `request_timeout`: Timeout for the request in **seconds**
-
-**Returns**:
-
-`True` if the sandbox was killed, `False` if the sandbox was not found
+Stop watching the directory.
+After you stop the watcher you won't be able to get the events anymore.
-#### kill
+### get\_new\_events
```python
-@class_method_variant("_cls_kill")
-def kill(request_timeout: Optional[float] = None) -> bool
+def get_new_events() -> List[FilesystemEvent]
```
-Kill the sandbox.
-
-**Arguments**:
-
-- `request_timeout`: Timeout for the request
+Get the latest events that have occurred in the watched directory since the last call, or from the beginning of the watching, up until now.
**Returns**:
-`True` if the sandbox was killed, `False` if the sandbox was not found
-
-
-#### set\_timeout
-
-```python
-@overload
-def set_timeout(timeout: int, request_timeout: Optional[float] = None) -> None
-```
-
-Set the timeout of the sandbox.
-
-After the timeout expires the sandbox will be automatically killed.
-This method can extend or reduce the sandbox timeout set when creating the sandbox or from the last call to `.set_timeout`.
-
-Maximum time a sandbox can be kept alive is 24 hours (86_400 seconds) for Pro users and 1 hour (3_600 seconds) for Hobby users.
-
-**Arguments**:
-
-- `timeout`: Timeout for the sandbox in **seconds**
-- `request_timeout`: Timeout for the request in **seconds**
-
-
-#### set\_timeout
-
-```python
-@overload
-@staticmethod
-def set_timeout(sandbox_id: str,
- timeout: int,
- api_key: Optional[str] = None,
- domain: Optional[str] = None,
- debug: Optional[bool] = None,
- request_timeout: Optional[float] = None) -> None
-```
-
-Set the timeout of the sandbox specified by sandbox ID.
-
-After the timeout expires the sandbox will be automatically killed.
-This method can extend or reduce the sandbox timeout set when creating the sandbox or from the last call to `.set_timeout`.
-
-Maximum time a sandbox can be kept alive is 24 hours (86_400 seconds) for Pro users and 1 hour (3_600 seconds) for Hobby users.
-
-**Arguments**:
-
-- `sandbox_id`: Sandbox ID
-- `timeout`: Timeout for the sandbox in **seconds**
-- `api_key`: E2B API Key to use for authentication, defaults to `E2B_API_KEY` environment variable
-- `request_timeout`: Timeout for the request in **seconds**
+List of filesystem events
@@ -277,7 +47,7 @@ class Filesystem()
Module for interacting with the filesystem in the sandbox.
-#### read
+### read
```python
@overload
@@ -301,7 +71,7 @@ Read file content as a `str`.
File content as a `str`
-#### read
+### read
```python
@overload
@@ -325,7 +95,7 @@ Read file content as a `bytearray`.
File content as a `bytearray`
-#### read
+### read
```python
@overload
@@ -349,7 +119,7 @@ Read file content as a `Iterator[bytes]`.
File content as an `Iterator[bytes]`
-#### write
+### write
```python
def write(path: str,
@@ -378,7 +148,7 @@ Writing to a file at path that doesn't exist creates the necessary directories.
Information about the written file
-#### list
+### list
```python
def list(path: str,
@@ -399,7 +169,7 @@ List entries in a directory.
List of entries in the directory
-#### exists
+### exists
```python
def exists(path: str,
@@ -420,7 +190,7 @@ Check if a file or a directory exists.
`True` if the file or directory exists, `False` otherwise
-#### remove
+### remove
```python
def remove(path: str,
@@ -437,7 +207,7 @@ Remove a file or a directory.
- `request_timeout`: Timeout for the request in **seconds**
-#### rename
+### rename
```python
def rename(old_path: str,
@@ -460,7 +230,7 @@ Rename a file or directory.
Information about the renamed file or directory
-#### make\_dir
+### make\_dir
```python
def make_dir(path: str,
@@ -481,7 +251,7 @@ Create a new directory and all directories along the way if needed on the specif
`True` if the directory was created, `False` if the directory already exists
-#### watch\_dir
+### watch\_dir
```python
def watch_dir(path: str,
@@ -504,39 +274,34 @@ Watch directory for filesystem events.
-## WatchHandle
+## SandboxApi
```python
-class WatchHandle()
+class SandboxApi(SandboxApiBase)
```
-Handle for watching filesystem events.
-It is used to get the latest events that have occurred in the watched directory.
-
-Use `.stop()` to stop watching the directory.
-
-#### stop
+### list
```python
-def stop()
-```
-
-Stop watching the directory.
-After you stop the watcher you won't be able to get the events anymore.
-
+@classmethod
+def list(cls,
+ api_key: Optional[str] = None,
+ domain: Optional[str] = None,
+ debug: Optional[bool] = None,
+ request_timeout: Optional[float] = None) -> List[SandboxInfo]
+```
-#### get\_new\_events
+List all running sandboxes.
-```python
-def get_new_events() -> List[FilesystemEvent]
-```
+**Arguments**:
-Get the latest events that have occurred in the watched directory since the last call, or from the beginning of the watching, up until now.
+- `api_key`: API key to use for authentication, defaults to `E2B_API_KEY` environment variable
+- `request_timeout`: Timeout for the request in **seconds**
**Returns**:
-List of filesystem events
+List of sandbox info
@@ -550,7 +315,7 @@ class Commands()
Module for executing commands in the sandbox.
-#### list
+### list
```python
def list(request_timeout: Optional[float] = None) -> List[ProcessInfo]
@@ -567,7 +332,7 @@ Lists all running commands and PTY sessions.
List of running commands and PTY sessions
-#### kill
+### kill
```python
def kill(pid: int, request_timeout: Optional[float] = None) -> bool
@@ -587,7 +352,7 @@ It uses `SIGKILL` signal to kill the command.
`True` if the command was killed, `False` if the command was not found
-#### send\_stdin
+### send\_stdin
```python
def send_stdin(pid: int, data: str, request_timeout: Optional[float] = None)
@@ -601,7 +366,7 @@ Send data to command stdin.
-#### run
+### run
```python
@overload
@@ -635,7 +400,7 @@ Start a new command and wait until it finishes executing.
`CommandResult` result of the command execution
-#### run
+### run
```python
@overload
@@ -667,7 +432,7 @@ Start a new command and return a handle to interact with it.
`CommandHandle` handle to interact with the running command
-#### connect
+### connect
```python
def connect(pid: int,
@@ -692,6 +457,92 @@ You can use `CommandHandle.wait()` to wait for the command to finish and get exe
+## CommandHandle
+
+```python
+class CommandHandle()
+```
+
+Command execution handle.
+
+It provides methods for waiting for the command to finish, retrieving stdout/stderr, and killing the command.
+
+
+### pid
+
+```python
+@property
+def pid()
+```
+
+Command process ID.
+
+
+### \_\_iter\_\_
+
+```python
+def __iter__()
+```
+
+Iterate over the command output.
+
+**Returns**:
+
+Generator of command outputs
+
+
+### disconnect
+
+```python
+def disconnect() -> None
+```
+
+Disconnect from the command.
+
+The command is not killed, but SDK stops receiving events from the command.
+You can reconnect to the command using `sandbox.commands.connect` method.
+
+
+### wait
+
+```python
+def wait(on_pty: Optional[Callable[[PtyOutput], None]] = None,
+ on_stdout: Optional[Callable[[str], None]] = None,
+ on_stderr: Optional[Callable[[str], None]] = None) -> CommandResult
+```
+
+Wait for the command to finish and returns the result.
+
+If the command exits with a non-zero exit code, it throws a `CommandExitException`.
+
+**Arguments**:
+
+- `on_pty`: Callback for pty output
+- `on_stdout`: Callback for stdout output
+- `on_stderr`: Callback for stderr output
+
+**Returns**:
+
+`CommandResult` result of command execution
+
+
+### kill
+
+```python
+def kill() -> bool
+```
+
+Kills the command.
+
+It uses `SIGKILL` signal to kill the command.
+
+**Returns**:
+
+Whether the command was killed successfully
+
+
+
+
## Pty
```python
@@ -701,7 +552,7 @@ class Pty()
Module for interacting with PTYs (pseudo-terminals) in the sandbox.
-#### kill
+### kill
```python
def kill(pid: int, request_timeout: Optional[float] = None) -> bool
@@ -719,7 +570,7 @@ Kill PTY.
`true` if the PTY was killed, `false` if the PTY was not found
-#### send\_stdin
+### send\_stdin
```python
def send_stdin(pid: int,
@@ -736,7 +587,7 @@ Send input to a PTY.
- `request_timeout`: Timeout for the request in **seconds**
-#### create
+### create
```python
def create(size: PtySize,
@@ -763,7 +614,7 @@ Start a new PTY (pseudo-terminal).
Handle to interact with the PTY
-#### resize
+### resize
```python
def resize(pid: int,
@@ -784,118 +635,267 @@ Call this when the terminal window is resized and the number of columns and rows
-## CommandHandle
+## Sandbox
```python
-class CommandHandle()
+class Sandbox(SandboxSetup, SandboxApi)
```
-Command execution handle.
+E2B cloud sandbox is a secure and isolated cloud environment.
-It provides methods for waiting for the command to finish, retrieving stdout/stderr, and killing the command.
+The sandbox allows you to:
+- Access Linux OS
+- Create, list, and delete files and directories
+- Run commands
+- Run isolated code
+- Access the internet
+
+Check docs [here](https://e2b.dev/docs).
+
+Use the `Sandbox()` to create a new sandbox.
+
+**Example**:
+```python
+from e2b import Sandbox
+
+sandbox = Sandbox()
+```
-#### pid
+
+### files
```python
@property
-def pid()
+def files() -> Filesystem
```
-Command process ID.
+Module for interacting with the sandbox filesystem.
-#### \_\_iter\_\_
+### commands
```python
-def __iter__()
+@property
+def commands() -> Commands
```
-Iterate over the command output.
+Module for running commands in the sandbox.
-**Returns**:
-Generator of command outputs
+### pty
+```python
+@property
+def pty() -> Pty
+```
+
+Module for interacting with the sandbox pseudo-terminal.
-#### disconnect
+
+### sandbox\_id
```python
-def disconnect() -> None
+@property
+def sandbox_id() -> str
```
-Disconnect from the command.
-
-The command is not killed, but SDK stops receiving events from the command.
-You can reconnect to the command using `sandbox.commands.connect` method.
+Unique identifier of the sandbox
-#### wait
+### \_\_init\_\_
```python
-def wait(on_pty: Optional[Callable[[PtyOutput], None]] = None,
- on_stdout: Optional[Callable[[str], None]] = None,
- on_stderr: Optional[Callable[[str], None]] = None) -> CommandResult
+def __init__(template: Optional[str] = None,
+ timeout: Optional[int] = None,
+ metadata: Optional[Dict[str, str]] = None,
+ envs: Optional[Dict[str, str]] = None,
+ api_key: Optional[str] = None,
+ domain: Optional[str] = None,
+ debug: Optional[bool] = None,
+ sandbox_id: Optional[str] = None,
+ request_timeout: Optional[float] = None)
```
-Wait for the command to finish and returns the result.
+Create a new sandbox.
-If the command exits with a non-zero exit code, it throws a `CommandExitException`.
+By default, the sandbox is created from the default `base` sandbox template.
**Arguments**:
-- `on_pty`: Callback for pty output
-- `on_stdout`: Callback for stdout output
-- `on_stderr`: Callback for stderr output
+- `template`: Sandbox template name or ID
+- `timeout`: Timeout for the sandbox in **seconds**, default to 300 seconds. Maximum time a sandbox can be kept alive is 24 hours (86_400 seconds) for Pro users and 1 hour (3_600 seconds) for Hobby users
+- `metadata`: Custom metadata for the sandbox
+- `envs`: Custom environment variables for the sandbox
+- `api_key`: E2B API Key to use for authentication, defaults to `E2B_API_KEY` environment variable
+- `request_timeout`: Timeout for the request in **seconds**
**Returns**:
-`CommandResult` result of command execution
+sandbox instance for the new sandbox
-#### kill
+### is\_running
```python
-def kill() -> bool
+def is_running(request_timeout: Optional[float] = None) -> bool
```
-Kills the command.
+Check if the sandbox is running.
-It uses `SIGKILL` signal to kill the command.
+**Arguments**:
+
+- `request_timeout`: Timeout for the request in **seconds**
**Returns**:
-Whether the command was killed successfully
+`True` if the sandbox is running, `False` otherwise
+Example
+```python
+sandbox = Sandbox()
+sandbox.is_running() # Returns True
+sandbox.kill()
+sandbox.is_running() # Returns False
+```
+### connect
-## SandboxApi
+```python
+@classmethod
+def connect(cls,
+ sandbox_id: str,
+ api_key: Optional[str] = None,
+ domain: Optional[str] = None,
+ debug: Optional[bool] = None)
+```
+
+Connects to an existing Sandbox.
+
+With sandbox ID you can connect to the same sandbox from different places or environments (serverless functions, etc).
+**Arguments**:
+
+- `sandbox_id`: Sandbox ID
+- `api_key`: E2B API Key to use for authentication, defaults to `E2B_API_KEY` environment variable
+
+**Returns**:
+
+sandbox instance for the existing sandbox
+@example
```python
-class SandboxApi(SandboxApiBase)
+sandbox = Sandbox()
+sandbox_id = sandbox.sandbox_id
+
+same_sandbox = Sandbox.connect(sandbox_id)
+
+
+### kill
+
+```python
+@overload
+def kill(request_timeout: Optional[float] = None) -> bool
```
+Kill the sandbox.
+
+**Arguments**:
+
+- `request_timeout`: Timeout for the request in **seconds**
+
+**Returns**:
+
+`True` if the sandbox was killed, `False` if the sandbox was not found
-#### list
+
+### kill
```python
-@classmethod
-def list(cls,
+@overload
+@staticmethod
+def kill(sandbox_id: str,
api_key: Optional[str] = None,
domain: Optional[str] = None,
debug: Optional[bool] = None,
- request_timeout: Optional[float] = None) -> List[SandboxInfo]
+ request_timeout: Optional[float] = None) -> bool
```
-List all running sandboxes.
+Kill the sandbox specified by sandbox ID.
**Arguments**:
-- `api_key`: API key to use for authentication, defaults to `E2B_API_KEY` environment variable
+- `sandbox_id`: Sandbox ID
+- `api_key`: E2B API Key to use for authentication, defaults to `E2B_API_KEY` environment variable
- `request_timeout`: Timeout for the request in **seconds**
**Returns**:
-List of sandbox info
+`True` if the sandbox was killed, `False` if the sandbox was not found
+
+
+### kill
+
+```python
+@class_method_variant("_cls_kill")
+def kill(request_timeout: Optional[float] = None) -> bool
+```
+
+Kill the sandbox.
+
+**Arguments**:
+
+- `request_timeout`: Timeout for the request
+
+**Returns**:
+
+`True` if the sandbox was killed, `False` if the sandbox was not found
+
+
+### set\_timeout
+
+```python
+@overload
+def set_timeout(timeout: int, request_timeout: Optional[float] = None) -> None
+```
+
+Set the timeout of the sandbox.
+
+After the timeout expires the sandbox will be automatically killed.
+This method can extend or reduce the sandbox timeout set when creating the sandbox or from the last call to `.set_timeout`.
+
+Maximum time a sandbox can be kept alive is 24 hours (86_400 seconds) for Pro users and 1 hour (3_600 seconds) for Hobby users.
+
+**Arguments**:
+
+- `timeout`: Timeout for the sandbox in **seconds**
+- `request_timeout`: Timeout for the request in **seconds**
+
+
+### set\_timeout
+
+```python
+@overload
+@staticmethod
+def set_timeout(sandbox_id: str,
+ timeout: int,
+ api_key: Optional[str] = None,
+ domain: Optional[str] = None,
+ debug: Optional[bool] = None,
+ request_timeout: Optional[float] = None) -> None
+```
+
+Set the timeout of the sandbox specified by sandbox ID.
+
+After the timeout expires the sandbox will be automatically killed.
+This method can extend or reduce the sandbox timeout set when creating the sandbox or from the last call to `.set_timeout`.
+
+Maximum time a sandbox can be kept alive is 24 hours (86_400 seconds) for Pro users and 1 hour (3_600 seconds) for Hobby users.
+
+**Arguments**:
+
+- `sandbox_id`: Sandbox ID
+- `timeout`: Timeout for the sandbox in **seconds**
+- `api_key`: E2B API Key to use for authentication, defaults to `E2B_API_KEY` environment variable
+- `request_timeout`: Timeout for the request in **seconds**