Sandbox
Python
__init__
Python
desktop
template.
Arguments:
resolution
: Startup the desktop with custom screen resolution. Defaults to (1024, 768)dpi
: Startup the desktop with custom DPI. Defaults to 96display
: Startup the desktop with custom display. Defaults to “:0”template
: Sandbox template name or IDtimeout
: 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 usersmetadata
: Custom metadata for the sandboxenvs
: Custom environment variables for the sandboxapi_key
: E2B API Key to use for authentication, defaults toE2B_API_KEY
environment variabledomain
: E2B domain to use for authentication, defaults toE2B_DOMAIN
environment variabledebug
: If True, the sandbox will be created in debug mode, defaults toE2B_DEBUG
environment variablesandbox_id
: Sandbox ID to connect to, defaults toE2B_SANDBOX_ID
environment variablerequest_timeout
: Timeout for the request in seconds
screenshot
Python
screenshot
Python
screenshot
Python
format
: The format of the screenshot. Can be ‘bytes’, ‘blob’, or ‘stream’.
left_click
Python
double_click
Python
right_click
Python
middle_click
Python
scroll
Python
direction
: The direction to scroll. Can be “up” or “down”.amount
: The amount to scroll.
move_mouse
Python
x
: The x coordinate.y
: The y coordinate.
mouse_press
Python
mouse_release
Python
get_cursor_position
Python
RuntimeError
: If the cursor position cannot be determined
get_screen_size
Python
RuntimeError
: If the screen size cannot be determined
write
Python
text
: The text to write.chunk_size
: The size of each chunk of text to write.delay_in_ms
: The delay between each chunk of text.
press
Python
key
: The key to press (e.g. “enter”, “space”, “backspace”, etc.).
drag
Python
from
: The starting position.to
: The ending position.
wait
Python
ms
: The amount of time to wait in milliseconds.
open
Python
file_or_url
: The file or URL to open.