gbox_sdk.wrapper.box package

Subpackages

Submodules

gbox_sdk.wrapper.box.action module

gbox_sdk.wrapper.box.base module

gbox_sdk.wrapper.box.browser module

class gbox_sdk.wrapper.box.browser.BrowserTabOperator(*, client, box_id, data)

Bases: object

Provides operations related to browser tabs for a specific box.

Args:

client (GboxClient): The GboxClient instance used to interact with the API. box_id (str): The unique identifier of the box.

update(url)

Navigate an existing browser tab to a new URL.

This endpoint updates the specified tab by navigating it to the provided URL and returns the updated tab information. The browser will wait for the DOM content to be loaded before returning the response. If the navigation fails due to an invalid URL or network issues, an error will be returned. The updated tab information will include the new title, final URL (after any redirects), and favicon from the new page.

Return type:

BrowserUpdateTabResponse

Args:

url: The tab new url

Returns:

BrowserUpdateTabResponse: The updated tab information.

Example:
>>> box.browser.tab.update("https://www.google.com")

gbox_sdk.wrapper.box.file_system module

gbox_sdk.wrapper.box.linux module

Module contents

class gbox_sdk.wrapper.box.ActionOperator(client, box_id)

Bases: object

Provides high-level action operations for a specific box using the GboxClient.

Methods correspond to various box actions such as click, drag, swipe, type, screenshot, etc.

ai(instruction, *, background=NOT_GIVEN, include_screenshot=NOT_GIVEN, output_format=NOT_GIVEN, screenshot_delay=NOT_GIVEN, settings=NOT_GIVEN, on_action_start=None, on_action_end=None)

Perform an AI-powered action on the box.

Return type:

Union[AIActionScreenshotResult, AIActionResult]

Args:
instruction: Direct instruction of the UI action to perform (e.g., ‘click the login button’,

‘input username in the email field’, ‘scroll down’, ‘swipe left’)

background: The background of the UI action to perform. The purpose of background is to let

the action executor to understand the context of why the instruction is given including important previous actions and observations

include_screenshot: Whether to include screenshots in the action response. If false, the screenshot

object will still be returned but with empty URIs. Default is false.

output_format: Type of the URI. default is base64.

screenshot_delay: Delay after performing the action, before taking the final screenshot.

Execution flow:

  1. Take screenshot before action

  2. Perform the action

  3. Wait for screenshotDelay (this parameter)

  4. Take screenshot after action

Example: ‘500ms’ means wait 500ms after the action before capturing the final screenshot.

Supported time units: ms (milliseconds), s (seconds), m (minutes), h (hours) Example formats: “500ms”, “30s”, “5m”, “1h” Default: 500ms Maximum allowed: 30s

settings: AI action settings

on_action_start: Callback function called when action starts on_action_end: Callback function called when action ends

Returns:

ActionAIResponse: The response from the AI action.

Example:
>>> response = myBox.action.ai("Click on the login button")
>>> response = myBox.action.ai(
...     instruction="Click on the login button",
...     background="The background of the action",
...     include_screenshot=True,
...     output_format="base64",
...     screenshot_delay="500ms",
...     settings={"disableActions": ["click"], "systemPrompt": "You are a helpful assistant"},
... )
ai_stream(instruction, *, background=NOT_GIVEN, include_screenshot=NOT_GIVEN, output_format=NOT_GIVEN, screenshot_delay=NOT_GIVEN, settings=NOT_GIVEN, on_action_start=None, on_action_end=None)

Perform an AI-powered action on the box with streaming support.

Return type:

Union[AIActionScreenshotResult, AIActionResult]

Args:
instruction: Direct instruction of the UI action to perform (e.g., ‘click the login button’,

‘input username in the email field’, ‘scroll down’, ‘swipe left’)

background: The background of the UI action to perform. The purpose of background is to let

the action executor to understand the context of why the instruction is given including important previous actions and observations

include_screenshot: Whether to include screenshots in the action response. If false, the screenshot

object will still be returned but with empty URIs. Default is false.

output_format: Type of the URI. default is base64.

screenshot_delay: Delay after performing the action, before taking the final screenshot.

Execution flow:

  1. Take screenshot before action

  2. Perform the action

  3. Wait for screenshotDelay (this parameter)

  4. Take screenshot after action

Example: ‘500ms’ means wait 500ms after the action before capturing the final screenshot.

Supported time units: ms (milliseconds), s (seconds), m (minutes), h (hours) Example formats: “500ms”, “30s”, “5m”, “1h” Default: 500ms Maximum allowed: 30s

settings: AI action settings

on_action_start: Callback function called when action starts on_action_end: Callback function called when action ends

Returns:

ActionAIResponse: The response from the AI action.

Example:
>>> response = myBox.action.ai_stream(
...     instruction="Click on the login button",
...     on_action_start=lambda: print("Action started"),
...     on_action_end=lambda: print("Action ended"),
... )
click(*, x, y, button=NOT_GIVEN, double=NOT_GIVEN, include_screenshot=NOT_GIVEN, output_format=NOT_GIVEN, screenshot_delay=NOT_GIVEN)

Perform a click action on the box.

Return type:

Union[ActionIncludeScreenshotResult, ActionCommonResult]

Args:

x: X coordinate of the click

y: Y coordinate of the click

button: Mouse button to click

double: Whether to perform a double click

include_screenshot: Whether to include screenshots in the action response. If false, the screenshot

object will still be returned but with empty URIs. Default is false.

output_format: Type of the URI. default is base64.

screenshot_delay: Delay after performing the action, before taking the final screenshot.

Execution flow:

  1. Take screenshot before action

  2. Perform the action

  3. Wait for screenshotDelay (this parameter)

  4. Take screenshot after action

Example: ‘500ms’ means wait 500ms after the action before capturing the final screenshot.

Supported time units: ms (milliseconds), s (seconds), m (minutes), h (hours) Example formats: “500ms”, “30s”, “5m”, “1h” Default: 500ms Maximum allowed: 30s

Returns:

ActionClickResponse: The response from the click action.

Example:
>>> response = myBox.action.click(x=100, y=100)
drag(*, path=NOT_GIVEN, start=NOT_GIVEN, end=NOT_GIVEN, duration=NOT_GIVEN, include_screenshot=NOT_GIVEN, output_format=NOT_GIVEN, screenshot_delay=NOT_GIVEN)

Perform a drag action on the box.

Return type:

Union[ActionIncludeScreenshotResult, ActionCommonResult]

Args:

path: Path of the drag action as a series of coordinates

end: Single point in a drag path

start: Single point in a drag path

duration: Duration to complete the movement from start to end coordinates

Supported time units: ms (milliseconds), s (seconds), m (minutes), h (hours) Example formats: “500ms”, “30s”, “5m”, “1h” Default: 500ms

include_screenshot: Whether to include screenshots in the action response. If false, the screenshot

object will still be returned but with empty URIs. Default is false.

output_format: Type of the URI. default is base64.

screenshot_delay: Delay after performing the action, before taking the final screenshot.

Execution flow:

  1. Take screenshot before action

  2. Perform the action

  3. Wait for screenshotDelay (this parameter)

  4. Take screenshot after action

Example: ‘500ms’ means wait 500ms after the action before capturing the final screenshot.

Supported time units: ms (milliseconds), s (seconds), m (minutes), h (hours) Example formats: “500ms”, “30s”, “5m”, “1h” Default: 500ms Maximum allowed: 30s

Returns:

ActionDragResponse: The response from the drag action.

Examples:

Simple drag from start to end: >>> response = myBox.action.drag(start={“x”: 100, “y”: 100}, end={“x”: 200, “y”: 200})

Advanced drag with path: >>> response = myBox.action.drag( … path=[ … {“x”: 100, “y”: 100}, … {“x”: 150, “y”: 150}, … {“x”: 200, “y”: 200}, … ] … )

extract(*, instruction, schema=NOT_GIVEN)

Extract data from the UI interface using a JSON schema.

Return type:

ActionExtractResponse

Args:

instruction: The instruction of the action to extract data from the UI interface

schema: JSON Schema defining the structure of data to extract. Supports object, array,

string, number, boolean types with validation rules.

Common use cases:

  • Extract text content: { “type”: “string” }

  • Extract structured data: { “type”: “object”, “properties”: {…} }

  • Extract lists: { “type”: “array”, “items”: {…} }

  • Extract with validation: Add constraints like “required”, “enum”, “pattern”, etc.

Returns:

ActionExtractResponse: The response containing the extracted data.

Example:
>>> response = myBox.action.extract(
...     instruction="Extract the user name from the profile",
...     schema={"type": "string"},
... )
long_press(*, x, y, duration=NOT_GIVEN, include_screenshot=NOT_GIVEN, output_format=NOT_GIVEN, presigned_expires_in=NOT_GIVEN, screenshot_delay=NOT_GIVEN)

Perform a long press action at specified coordinates for a specified duration. Useful for triggering context menus, drag operations, or other long-press interactions.

Return type:

Union[ActionIncludeScreenshotResult, ActionCommonResult]

Args:

x: X coordinate of the long press

y: Y coordinate of the long press

duration: Duration to hold the press (e.g. ‘1s’, ‘500ms’)

Supported time units: ms (milliseconds), s (seconds), m (minutes), h (hours) Example formats: “500ms”, “30s”, “5m”, “1h” Default: 1s

include_screenshot: Whether to include screenshots in the action response. If false, the screenshot

object will still be returned but with empty URIs. Default is false.

output_format: Type of the URI. default is base64.

presigned_expires_in: Presigned url expires in. Only takes effect when outputFormat is storageKey.

Supported time units: ms (milliseconds), s (seconds), m (minutes), h (hours) Example formats: “500ms”, “30s”, “5m”, “1h” Default: 30m

screenshot_delay: Delay after performing the action, before taking the final screenshot.

Execution flow:

  1. Take screenshot before action

  2. Perform the action

  3. Wait for screenshotDelay (this parameter)

  4. Take screenshot after action

Example: ‘500ms’ means wait 500ms after the action before capturing the final screenshot.

Supported time units: ms (milliseconds), s (seconds), m (minutes), h (hours) Example formats: “500ms”, “30s”, “5m”, “1h” Default: 500ms Maximum allowed: 30s

move(*, x, y, include_screenshot=NOT_GIVEN, output_format=NOT_GIVEN, screenshot_delay=NOT_GIVEN)

Move an element or pointer on the box.

Return type:

Union[ActionIncludeScreenshotResult, ActionCommonResult]

Args:

x: X coordinate to move to

y: Y coordinate to move to

include_screenshot: Whether to include screenshots in the action response. If false, the screenshot

object will still be returned but with empty URIs. Default is false.

output_format: Type of the URI. default is base64.

screenshot_delay: Delay after performing the action, before taking the final screenshot.

Execution flow:

  1. Take screenshot before action

  2. Perform the action

  3. Wait for screenshotDelay (this parameter)

  4. Take screenshot after action

Example: ‘500ms’ means wait 500ms after the action before capturing the final screenshot.

Supported time units: ms (milliseconds), s (seconds), m (minutes), h (hours) Example formats: “500ms”, “30s”, “5m”, “1h” Default: 500ms Maximum allowed: 30s

Returns:

ActionMoveResponse: The response from the move action.

Example:
>>> response = myBox.action.move(x=200, y=300)
press_button(*, buttons, include_screenshot=NOT_GIVEN, output_format=NOT_GIVEN, screenshot_delay=NOT_GIVEN)

Simulate a button press on the box.

Return type:

Union[ActionIncludeScreenshotResult, ActionCommonResult]

Args:

buttons: Button to press

include_screenshot: Whether to include screenshots in the action response. If false, the screenshot

object will still be returned but with empty URIs. Default is false.

output_format: Type of the URI. default is base64.

screenshot_delay: Delay after performing the action, before taking the final screenshot.

Execution flow:

  1. Take screenshot before action

  2. Perform the action

  3. Wait for screenshotDelay (this parameter)

  4. Take screenshot after action

Example: ‘500ms’ means wait 500ms after the action before capturing the final screenshot.

Supported time units: ms (milliseconds), s (seconds), m (minutes), h (hours) Example formats: “500ms”, “30s”, “5m”, “1h” Default: 500ms Maximum allowed: 30s

Returns:

ActionPressButtonResponse: The response from the button press action.

Example:
>>> response = myBox.action.press_button(buttons=["power"])
press_key(*, keys, combination=NOT_GIVEN, include_screenshot=NOT_GIVEN, output_format=NOT_GIVEN, screenshot_delay=NOT_GIVEN)

Simulate a key press on the box.

Return type:

Union[ActionIncludeScreenshotResult, ActionCommonResult]

Args:
keys: This is an array of keyboard keys to press. Supports cross-platform

compatibility.

combination: Whether to press keys as combination (simultaneously) or sequentially. When

true, all keys are pressed together as a shortcut (e.g., Ctrl+C). When false, keys are pressed one by one in sequence.

include_screenshot: Whether to include screenshots in the action response. If false, the screenshot

object will still be returned but with empty URIs. Default is false.

output_format: Type of the URI. default is base64.

screenshot_delay: Delay after performing the action, before taking the final screenshot.

Execution flow:

  1. Take screenshot before action

  2. Perform the action

  3. Wait for screenshotDelay (this parameter)

  4. Take screenshot after action

Example: ‘500ms’ means wait 500ms after the action before capturing the final screenshot.

Supported time units: ms (milliseconds), s (seconds), m (minutes), h (hours) Example formats: “500ms”, “30s”, “5m”, “1h” Default: 500ms Maximum allowed: 30s

Returns:

ActionPressKeyResponse: The response from the key press action.

Example:
>>> response = myBox.action.press_key(keys=["enter"])
>>> response = myBox.action.press_key(keys=["control", "c"], combination=True)
screen_layout()

Get the current structured screen layout information.

Return type:

ActionScreenLayoutResponse

Returns:

ActionScreenLayoutResponse: The response containing the screen layout data.

Example:
>>> response = myBox.action.screen_layout()
screen_recording_start(duration)

Start recording the box screen.

Only one recording can be active at a time. If a recording is already in progress, starting a new recording will stop the previous one and keep only the latest recording.

Return type:

None

Args:
duration: Duration of the recording. Default is 30m, max is 30m. The recording will

automatically stop when the duration time is reached.

Supported time units: ms (milliseconds), s (seconds), m (minutes), h (hours) Example formats: “500ms”, “30s”, “5m”, “1h” Maximum allowed: 30m

Example:
>>> response = myBox.action.screen_recording_start(duration="30m")
screen_recording_stop()

Stop recording the screen.

Return type:

ActionRecordingStopResponse

Returns:

ActionRecordingStopResponse: The response from the screen recording stop action.

Example:
>>> response = myBox.action.screen_recording_stop()
screen_rotation(orientation, *, include_screenshot=NOT_GIVEN, output_format=NOT_GIVEN, presigned_expires_in=NOT_GIVEN, screenshot_delay=NOT_GIVEN)

Rotate the screen orientation.

Note that even after rotating the screen, applications or system layouts may not automatically adapt to the gravity sensor changes, so visual changes may not always occur.

Return type:

Union[ActionIncludeScreenshotResult, ActionCommonResult]

Args:

orientation: Target screen orientation

include_screenshot: Whether to include screenshots in the action response. If false, the screenshot

object will still be returned but with empty URIs. Default is false.

output_format: Type of the URI. default is base64.

presigned_expires_in: Presigned url expires in. Only takes effect when outputFormat is storageKey.

Supported time units: ms (milliseconds), s (seconds), m (minutes), h (hours) Example formats: “500ms”, “30s”, “5m”, “1h” Default: 30m

screenshot_delay: Delay after performing the action, before taking the final screenshot.

Execution flow:

  1. Take screenshot before action

  2. Perform the action

  3. Wait for screenshotDelay (this parameter)

  4. Take screenshot after action

Example: ‘500ms’ means wait 500ms after the action before capturing the final screenshot.

Supported time units: ms (milliseconds), s (seconds), m (minutes), h (hours) Example formats: “500ms”, “30s”, “5m”, “1h” Default: 500ms Maximum allowed: 30s

Returns:

ActionScreenRotationResponse: The response from the screen rotation action.

Example:
>>> response = myBox.action.screen_rotation("landscapeLeft")
>>> response = myBox.action.screen_rotation(
...     orientation="landscapeLeft",
...     include_screenshot=True,
...     output_format="storageKey",
...     presigned_expires_in="30m",
...     screenshot_delay="500ms",
... )
screenshot(*, path=NOT_GIVEN, clip=NOT_GIVEN, output_format=NOT_GIVEN)

Take a screenshot of the box.

Return type:

ActionScreenshotResponse

Args:

path: The path to save the screenshot to.

clip: Clipping region for screenshot capture

output_format: Type of the URI. default is base64.

Returns:

ActionScreenshotResponse: The response containing the screenshot data.

Examples:

Take a screenshot and return base64 data: >>> response = action_operator.screenshot()

Take a screenshot and save to file: >>> response = action_operator.screenshot(path=”/path/to/screenshot.png”)

Take a screenshot with specific format: >>> response = action_operator.screenshot(output_format=”base64”)

scroll(*, scroll_x, scroll_y, x, y, include_screenshot=NOT_GIVEN, output_format=NOT_GIVEN, screenshot_delay=NOT_GIVEN)

Perform a scroll action on the box.

Return type:

Union[ActionIncludeScreenshotResult, ActionCommonResult]

Args:

scroll_x: Horizontal scroll amount

scroll_y: Vertical scroll amount

x: X coordinate of the scroll position

y: Y coordinate of the scroll position

include_screenshot: Whether to include screenshots in the action response. If false, the screenshot

object will still be returned but with empty URIs. Default is false.

output_format: Type of the URI. default is base64.

screenshot_delay: Delay after performing the action, before taking the final screenshot.

Execution flow:

  1. Take screenshot before action

  2. Perform the action

  3. Wait for screenshotDelay (this parameter)

  4. Take screenshot after action

Example: ‘500ms’ means wait 500ms after the action before capturing the final screenshot.

Supported time units: ms (milliseconds), s (seconds), m (minutes), h (hours) Example formats: “500ms”, “30s”, “5m”, “1h” Default: 500ms Maximum allowed: 30s

Returns:

ActionScrollResponse: The response from the scroll action.

Example:
>>> response = myBox.action.scroll(scroll_x=0, scroll_y=100, x=100, y=100)
swipe(*, direction=NOT_GIVEN, distance=NOT_GIVEN, start=NOT_GIVEN, end=NOT_GIVEN, duration=NOT_GIVEN, include_screenshot=NOT_GIVEN, output_format=NOT_GIVEN, screenshot_delay=NOT_GIVEN)

Perform a swipe action on the box.

Return type:

Union[ActionIncludeScreenshotResult, ActionCommonResult]

Args:
direction: Direction to swipe. The gesture will be performed from the center of the screen

towards this direction.

distance: Distance of the swipe in pixels. If not provided, the swipe will be performed

from the center of the screen to the screen edge

duration: Duration of the swipe

Supported time units: ms (milliseconds), s (seconds), m (minutes), h (hours) Example formats: “500ms”, “30s”, “5m”, “1h” Default: 500ms

include_screenshot: Whether to include screenshots in the action response. If false, the screenshot

object will still be returned but with empty URIs. Default is false.

output_format: Type of the URI. default is base64.

screenshot_delay: Delay after performing the action, before taking the final screenshot.

Execution flow:

  1. Take screenshot before action

  2. Perform the action

  3. Wait for screenshotDelay (this parameter)

  4. Take screenshot after action

Example: ‘500ms’ means wait 500ms after the action before capturing the final screenshot.

Supported time units: ms (milliseconds), s (seconds), m (minutes), h (hours) Example formats: “500ms”, “30s”, “5m”, “1h” Default: 500ms Maximum allowed: 30s

Returns:

ActionSwipeResponse: The response from the swipe action.

Example:
>>> response = myBox.action.swipe({"direction": "up"})
tap(*, x, y, include_screenshot=NOT_GIVEN, output_format=NOT_GIVEN, presigned_expires_in=NOT_GIVEN, screenshot_delay=NOT_GIVEN)

Tap action for Android devices using ADB input tap command

Return type:

Union[ActionIncludeScreenshotResult, ActionCommonResult]

Args:

x: X coordinate of the tap

y: Y coordinate of the tap

include_screenshot: Whether to include screenshots in the action response. If false, the screenshot

object will still be returned but with empty URIs. Default is false.

output_format: Type of the URI. default is base64.

presigned_expires_in: Presigned url expires in. Only takes effect when outputFormat is storageKey.

Supported time units: ms (milliseconds), s (seconds), m (minutes), h (hours) Example formats: “500ms”, “30s”, “5m”, “1h” Default: 30m

screenshot_delay: Delay after performing the action, before taking the final screenshot.

Execution flow:

  1. Take screenshot before action

  2. Perform the action

  3. Wait for screenshotDelay (this parameter)

  4. Take screenshot after action

Example: ‘500ms’ means wait 500ms after the action before capturing the final screenshot.

Supported time units: ms (milliseconds), s (seconds), m (minutes), h (hours) Example formats: “500ms”, “30s”, “5m”, “1h” Default: 500ms Maximum allowed: 30s

touch(*, points, include_screenshot=NOT_GIVEN, output_format=NOT_GIVEN, screenshot_delay=NOT_GIVEN)

Simulate a touch action on the box.

Return type:

Union[ActionIncludeScreenshotResult, ActionCommonResult]

Args:

points: Array of touch points and their actions

include_screenshot: Whether to include screenshots in the action response. If false, the screenshot

object will still be returned but with empty URIs. Default is false.

output_format: Type of the URI. default is base64.

screenshot_delay: Delay after performing the action, before taking the final screenshot.

Execution flow:

  1. Take screenshot before action

  2. Perform the action

  3. Wait for screenshotDelay (this parameter)

  4. Take screenshot after action

Example: ‘500ms’ means wait 500ms after the action before capturing the final screenshot.

Supported time units: ms (milliseconds), s (seconds), m (minutes), h (hours) Example formats: “500ms”, “30s”, “5m”, “1h” Default: 500ms Maximum allowed: 30s

Returns:

ActionTouchResponse: The response from the touch action.

Example:
>>> response = myBox.action.touch(points=[{"start": {"x": 0, "y": 0}}])
type(*, text, include_screenshot=NOT_GIVEN, mode=NOT_GIVEN, output_format=NOT_GIVEN, screenshot_delay=NOT_GIVEN)

Simulate typing text on the box.

Return type:

Union[ActionIncludeScreenshotResult, ActionCommonResult]

Args:

text: Text to type

include_screenshot: Whether to include screenshots in the action response. If false, the screenshot

object will still be returned but with empty URIs. Default is false.

mode: Text input mode: ‘append’ to add text to existing content, ‘replace’ to replace

all existing text

output_format: Type of the URI. default is base64.

screenshot_delay: Delay after performing the action, before taking the final screenshot.

Execution flow:

  1. Take screenshot before action

  2. Perform the action

  3. Wait for screenshotDelay (this parameter)

  4. Take screenshot after action

Example: ‘500ms’ means wait 500ms after the action before capturing the final screenshot.

Supported time units: ms (milliseconds), s (seconds), m (minutes), h (hours) Example formats: “500ms”, “30s”, “5m”, “1h” Default: 500ms Maximum allowed: 30s

Returns:

ActionTypeResponse: The response from the type action.

Example:
>>> response = myBox.action.type(text="Hello, World!")
class gbox_sdk.wrapper.box.ActionScreenshot

Bases: ActionScreenshotParams

Extends ActionScreenshotParams to optionally include a file path for saving the screenshot.

Attributes:

path (Optional[str]): The file path where the screenshot will be saved.

clip: Clip
output_format: Annotated[Literal['base64', 'storageKey']]
path: Optional[str]
class gbox_sdk.wrapper.box.AndroidAppOperator(client, box, data)

Bases: object

Operator class for managing a specific Android app within a box.

Provides methods to open, restart, close, list activities, and backup the app.

Attributes:

client (GboxClient): The API client used for communication. box (AndroidBox): The Android box data object. data (AndroidApp): The app data object.

backup()

Backup the app.

Return type:

BinaryAPIResponse

Returns:

BinaryAPIResponse: The backup response containing binary data.

Examples:
>>> box.app.backup()
close()

Close the app.

Return type:

None

Examples:
>>> box.app.close()
list_activities()

List all activities of the app.

Return type:

AndroidListActivitiesResponse

Returns:

AndroidListActivitiesResponse: The response containing the list of activities.

Examples:
>>> box.app.list_activities()
open(activity_name=NOT_GIVEN)

Open the app, optionally specifying an activity name.

Return type:

None

Args:

activity_name: Activity name, default is the main activity.

Examples:
>>> box.app.open()
>>> box.app.open("com.example.app.MainActivity")
restart(activity_name=NOT_GIVEN)

Restart the app, optionally specifying an activity name.

Return type:

None

Args:

activity_name: Activity name, default is the main activity.

Examples:
>>> box.app.restart()
>>> box.app.restart("com.example.app.MainActivity")
class gbox_sdk.wrapper.box.AndroidBoxOperator(client, data)

Bases: BaseBox

Operator class for managing Android boxes, providing access to app and package management functionalities.

Attributes:

app (AndroidAppManager): Manager for Android app operations. pkg (AndroidPkgManager): Manager for Android package operations.

class gbox_sdk.wrapper.box.AndroidPkgOperator(client, box, data)

Bases: object

Operator class for managing a specific Android package within a box.

Provides methods to open, close, restart, list activities, and backup the package.

Attributes:

client (GboxClient): The API client used for communication. box (AndroidBox): The Android box data object. data (AndroidGetResponse): The package data object.

backup()

Backup the package.

Return type:

BinaryAPIResponse

Returns:

BinaryAPIResponse: The backup response containing binary data.

Examples:
>>> box.pkg.backup()
close()

Close the package.

Return type:

None

list_activities()

List all activities of the package.

Return type:

AndroidListActivitiesResponse

Returns:

AndroidListActivitiesResponse: The response containing the list of activities.

Examples:
>>> box.pkg.list_activities()
open(activity_name=None)

Open the package, optionally specifying an activity name.

Return type:

None

Args:

activity_name: Activity name, default is the main activity.

Examples:
>>> box.pkg.open()
>>> box.pkg.open("com.example.app.MainActivity")
restart(activity_name=None)

Restart the package, optionally specifying an activity name.

Return type:

None

Args:

activity_name: Activity name, default is the main activity.

Examples:
>>> box.pkg.restart()
>>> box.pkg.restart("com.example.app.MainActivity")
class gbox_sdk.wrapper.box.BaseBox(client, data)

Bases: object

Base class for box operations, providing common interfaces for box lifecycle and actions.

Attributes:

client (GboxClient): The Gbox client instance used for API calls. data (Union[LinuxBox, AndroidBox]): The box data object. action (ActionOperator): Operator for box actions. fs (FileSystemOperator): Operator for file system actions. browser (BrowserOperator): Operator for browser actions.

command(commands, on_stdout=None, on_stderr=None, envs=NOT_GIVEN, api_timeout=NOT_GIVEN, working_dir=NOT_GIVEN)

Execute shell commands in the box.

Return type:

Union[BoxExecuteCommandsResponse, WebSocketResult]

Args:

commands: The command to run. Can be a single string or an array of strings

envs: The environment variables to run the command

api_timeout: The timeout of the command. If the command times out, the exit code will be 124.

For example: ‘timeout 5s sleep 10s’ will result in exit code 124.

Supported time units: ms (milliseconds), s (seconds), m (minutes), h (hours) Example formats: “500ms”, “30s”, “5m”, “1h” Default: 30s

working_dir: The working directory of the command. It not provided, the command will be run

in the box.config.workingDir directory.

on_stdout: Callback for stdout.

on_stderr: Callback for stderr.

Returns:

Union[BoxExecuteCommandsResponse, WebSocketResult]: The response containing the command execution result.

Example:
>>> box.command(commands=["ls", "-l"], on_stdout=lambda x: print(x), on_stderr=lambda x: print(x))
display()

Retrieve the current display properties for a running box.

This endpoint provides details about the box’s screen resolution, orientation, and other visual properties

Return type:

BoxDisplayResponse

Returns:

BoxDisplayResponse: The response containing the display properties.

Example:
>>> box.display()
live_view(*, expires_in=NOT_GIVEN)

Get the live view URL for the box.

Return type:

BoxLiveViewURLResponse

Args:

expires_in: The duration for the live view URL to be valid.

Returns:

BoxLiveViewURLResponse: The response containing the live view URL.

run_code(code, argv=NOT_GIVEN, envs=NOT_GIVEN, language=NOT_GIVEN, api_timeout=NOT_GIVEN, working_dir=NOT_GIVEN, on_stdout=None, on_stderr=None)

Run code in the box.

Return type:

Union[BoxRunCodeResponse, WebSocketResult]

Args:

code: The code to run

argv: The arguments to run the code. For example, if you want to run “python index.py

–help”, you should pass [”–help”] as arguments.

envs: The environment variables to run the code

language: The language of the code.

api_timeout: The timeout of the code execution. If the code execution times out, the exit

code will be 124.

Supported time units: ms (milliseconds), s (seconds), m (minutes), h (hours) Example formats: “500ms”, “30s”, “5m”, “1h” Default: 30s

working_dir: The working directory of the code. It not provided, the code will be run in the

box.config.workingDir directory.

on_stdout: Callback for stdout.

on_stderr: Callback for stderr.

Returns:

Union[BoxRunCodeResponse, WebSocketResult]: The response containing the code execution result.

Example:
>>> box.run_code(
...     code="print('Hello, World!')",
...     language="python",
...     on_stdout=lambda x: print(x),
...     on_stderr=lambda x: print(x),
... )
start(*, wait=NOT_GIVEN)

Start the box.

Return type:

Self

Args:

wait: Whether to wait for the box to start.

Returns:

Self: The updated box instance for method chaining.

Example:
>>> box.start()
>>> box.start(wait=True)
stop(*, wait=NOT_GIVEN)

Stop the box.

Return type:

Self

Args:

wait: Whether to wait for the box to stop.

Returns:

Self: The updated box instance for method chaining.

Example:
>>> box.stop()
>>> box.stop(wait=True)
terminate(*, wait=NOT_GIVEN)

Terminate the box.

Return type:

Self

Args:

wait: Whether to wait for the box to terminate.

Returns:

Self: The updated box instance for method chaining.

Example:
>>> box.terminate()
>>> box.terminate(wait=True)
web_terminal(*, expires_in=NOT_GIVEN)

Get the web terminal URL for the box.

Return type:

BoxWebTerminalURLResponse

Args:

body (BoxWebTerminalURLParams): Parameters for web terminal URL.

Returns:

BoxWebTerminalURLResponse: The response containing the web terminal URL.

class gbox_sdk.wrapper.box.BrowserOperator(client, box_id)

Bases: object

Provides operations related to browser management for a specific box.

Args:

client (GboxClient): The GboxClient instance used to interact with the API. box_id (str): The unique identifier of the box.

cdp_url()

Get the Chrome DevTools Protocol (CDP) URL for the browser in the specified box.

Return type:

str

Returns:

str: The CDP URL for the browser.

Example:
>>> box.browser.cdp_url()
close_tab(tab_id)

Close a specific browser tab identified by its id.

This endpoint will permanently close the tab and free up the associated resources. After closing a tab, the ids of subsequent tabs may change.

Return type:

BrowserCloseTabResponse

Args:

tab_id: The tab id

Example:
>>> box.browser.close_tab("1")
list_tab()

Retrieve a comprehensive list of all currently open browser tabs in the specified box. This endpoint returns detailed information about each tab including its id, title, current URL, and favicon. The returned id can be used for subsequent operations like navigation, closing, or updating tabs. This is essential for managing multiple browser sessions and understanding the current state of the browser environment.

Return type:

List[BrowserTabOperator]

Returns:

list: A list of tab objects. BrowserTabOperator

Example:
>>> box.browser.list_tab()
list_tab_info()

Retrieve a comprehensive list of all currently open browser tabs in the specified box. This endpoint returns detailed information about each tab including its id, title, current URL, and favicon. The returned id can be used for subsequent operations like navigation, closing, or updating tabs. This is essential for managing multiple browser sessions and understanding the current state of the browser environment.

Return type:

BrowserGetTabsResponse

Returns:

BrowserGetTabsResponse: The list of tab information.

Example:
>>> box.browser.list_tab_info()
open_tab(url)

Create and open a new browser tab with the specified URL.

This endpoint will navigate to the provided URL and return the new tab’s information including its assigned id, loaded title, final URL (after any redirects), and favicon. The returned tab id can be used for future operations on this specific tab. The browser will attempt to load the page and will wait for the DOM content to be loaded before returning the response. If the URL is invalid or unreachable, an error will be returned.

Return type:

BrowserOpenTabResponse

Args:

url: The tab url

Example:
>>> box.browser.open_tab("https://www.google.com")
switch_tab(tab_id)

Switch to a specific browser tab by bringing it to the foreground (making it the active/frontmost tab). This operation sets the specified tab as the currently active tab without changing its URL or content. The tab will receive focus and become visible to the user. This is useful for managing multiple browser sessions and controlling which tab is currently in focus.

Return type:

BrowserSwitchTabResponse

Args:

tab_id: The tab id

Example:
>>> box.browser.switch_tab("1")
update_tab(*, tab_id, url)

Navigate an existing browser tab to a new URL.

This endpoint updates the specified tab by navigating it to the provided URL and returns the updated tab information. The browser will wait for the DOM content to be loaded before returning the response. If the navigation fails due to an invalid URL or network issues, an error will be returned. The updated tab information will include the new title, final URL (after any redirects), and favicon from the new page.

Return type:

BrowserUpdateTabResponse

Args:

tab_id: The tab id url: The tab new url

Example:
>>> box.browser.update_tab(tab_id="1", url="https://www.google.com")
class gbox_sdk.wrapper.box.DirectoryOperator(client, box_id, data)

Bases: object

Operator for directory operations within a box.

Provides methods to list and rename a directory.

Args:

client (GboxClient): The Gbox client instance. box_id (str): The ID of the box to operate on. data (DataDir): The directory data.

list(*, depth=NOT_GIVEN, working_dir=NOT_GIVEN)

List files and directories in this directory, returning operator objects.

Return type:

List[Union[FileOperator, DirectoryOperator]]

Args:

path: Target directory path in the box

depth: Depth of the directory

working_dir: Working directory. If not provided, the file will be read from the

box.config.workingDir directory.

Returns:

List[Union[FileOperator, DirectoryOperator]]: List of file or directory operator objects.

Example:
>>> box.file_system.list(path="/path/to/directory", depth=1, working_dir="/path/to/working_dir")
>>> box.file_system.list("/path/to/directory")
list_info(*, depth=NOT_GIVEN, working_dir=NOT_GIVEN)

Get detailed information about files and directories in this directory.

Return type:

FListResponse

Args:

path: Target directory path in the box

depth: Depth of the directory

working_dir: Working directory. If not provided, the file will be read from the

box.config.workingDir directory.

Returns:

FListResponse: The response containing file/directory information.

Example:
>>> box.file_system.list_info(path="/path/to/directory", depth=1, working_dir="/path/to/working_dir")
>>> box.file_system.list_info("/path/to/directory")
rename(*, new_path, working_dir=NOT_GIVEN)

Rename this directory.

Return type:

Union[File, Dir]

Args:
new_path: New path in the box. If the path does not start with ‘/’, the file/directory

will be renamed relative to the working directory. If the newPath already exists, the rename will fail.

working_dir: Working directory. If not provided, the file will be read from the

box.config.workingDir directory.

Returns:

FRenameResponse: The response after renaming.

Example:
>>> box.file_system.rename(
...     old_path="/path/to/old/file", new_path="/path/to/new/file", working_dir="/path/to/working_dir"
... )
>>> box.file_system.rename("/path/to/old/file", "/path/to/new/file")
class gbox_sdk.wrapper.box.FileOperator(client, box_id, data)

Bases: object

Operator for file operations within a box.

Provides methods to read, write, and rename a file.

Args:

client (GboxClient): The Gbox client instance. box_id (str): The ID of the box to operate on. data (DataFile): The file data.

read(*, working_dir=NOT_GIVEN)

Read the content of this file.

Return type:

FReadResponse

Args:

working_dir: The working directory to read the file from.

Returns:

FReadResponse: The response containing file content.

Example:
>>> box.file_system.read(working_dir="/path/to/working_dir")
>>> box.file_system.read()
rename(new_path, *, working_dir=NOT_GIVEN)

Rename this file.

Return type:

Union[File, Dir]

Args:

new_path: The new path of the file. working_dir: The working directory to rename the file in.

Returns:

FRenameResponse: The response after renaming.

Example:
>>> box.file_system.rename(new_path="/path/to/new/file", working_dir="/path/to/working_dir")
write(content, *, working_dir=NOT_GIVEN)

Write content to this file (text or binary).

Return type:

FWriteResponse

Args:

content: The content to write to the file. working_dir: The working directory to write the file to.

Returns:

FWriteResponse: The response after writing.

Example:
>>> box.file_system.write(content="Hello, World!", path="/path/to/file", working_dir="/path/to/working_dir")
>>> box.file_system.write("Hello, World!")
class gbox_sdk.wrapper.box.FileSystemOperator(client, box_id)

Bases: object

Operator for file system operations within a box.

Provides methods to list, read, write, remove, check existence, rename, and retrieve file or directory information in a box.

Args:

client (GboxClient): The Gbox client instance. box_id (str): The ID of the box to operate on.

exists(path, *, working_dir=NOT_GIVEN)

Check if a file or directory exists.

Return type:

Union[ExistsFileResult, NotExistsFileResult]

Args:
path: Target path in the box. If the path does not start with ‘/’, the file/directory

will be checked relative to the working directory

working_dir: Working directory. If not provided, the file will be read from the

box.config.workingDir directory.

Returns:

FExistsResponse: The response indicating existence.

Example:
>>> box.file_system.exists(path="/path/to/file", working_dir="/path/to/working_dir")
>>> box.file_system.exists("/path/to/file")
get(path, *, working_dir=NOT_GIVEN)

Get an operator for a file or directory by its information.

Return type:

Union[FileOperator, DirectoryOperator]

Args:
path: Target path in the box. If the path does not start with ‘/’, the file/directory

will be checked relative to the working directory

working_dir: Working directory. If not provided, the file will be read from the

box.config.workingDir directory.

Returns:

Union[FileOperator, DirectoryOperator]: The corresponding operator object.

Example:
>>> box.file_system.get(path="/path/to/file", working_dir="/path/to/working_dir")
>>> box.file_system.get("/path/to/file")
list(path, *, depth=NOT_GIVEN, working_dir=NOT_GIVEN)

List files and directories at a given path or with given parameters, returning operator objects.

Return type:

List[Union[FileOperator, DirectoryOperator]]

Args:

path: Target directory path in the box

depth: Depth of the directory

working_dir: Working directory. If not provided, the file will be read from the

box.config.workingDir directory.

Returns:

List[Union[FileOperator, DirectoryOperator]]: List of file or directory operator objects.

Example:
>>> box.file_system.list(path="/path/to/directory", depth=1, working_dir="/path/to/working_dir")
>>> box.file_system.list("/path/to/directory")
list_info(path, *, depth=NOT_GIVEN, working_dir=NOT_GIVEN)

Get detailed information about files and directories at a given path or with given parameters.

Return type:

FListResponse

Args:

path: Target directory path in the box

depth: Depth of the directory

working_dir: Working directory. If not provided, the file will be read from the

box.config.workingDir directory.

Returns:

FListResponse: The response containing file/directory information.

Example:
>>> box.file_system.list_info(path="/path/to/directory", depth=1, working_dir="/path/to/working_dir")
>>> box.file_system.list_info("/path/to/directory")
read(path, *, working_dir=NOT_GIVEN)

Read the content of a file.

Return type:

FReadResponse

Args:
path: Target path in the box. If the path does not start with ‘/’, the file will be

read from the working directory.

working_dir: Working directory. If not provided, the file will be read from the

box.config.workingDir directory.

Returns:

FReadResponse: The response containing file content.

Example:
>>> box.file_system.read(path="/path/to/file", working_dir="/path/to/working_dir")
>>> box.file_system.read("/path/to/file")
remove(path, *, working_dir=NOT_GIVEN)

Remove a file or directory.

Return type:

FRemoveResponse

Args:
path: Target path in the box. If the path does not start with ‘/’, the file/directory

will be checked relative to the working directory

working_dir: Working directory. If not provided, the file will be read from the

box.config.workingDir directory.

Returns:

FRemoveResponse: The response after removing the file or directory.

Example:
>>> box.file_system.remove(path="/path/to/file", working_dir="/path/to/working_dir")
>>> box.file_system.remove("/path/to/file")
rename(*, old_path, new_path, working_dir=NOT_GIVEN)

Rename a file or directory.

Return type:

Union[File, Dir]

Args:
new_path: New path in the box. If the path does not start with ‘/’, the file/directory

will be renamed relative to the working directory. If the newPath already exists, the rename will fail.

old_path: Old path in the box. If the path does not start with ‘/’, the file/directory

will be renamed relative to the working directory. If the oldPath does not exist, the rename will fail.

working_dir: Working directory. If not provided, the file will be read from the

box.config.workingDir directory.

Returns:

FRenameResponse: The response after renaming.

Example:
>>> box.file_system.rename(
...     old_path="/path/to/old/file", new_path="/path/to/new/file", working_dir="/path/to/working_dir"
... )
write(*, content, path, working_dir=NOT_GIVEN)

Write content to a file (text or binary).

Return type:

FileOperator

Args:

content: Content of the file (Max size: 512MB)

path: Target path in the box. If the path does not start with ‘/’, the file will be

written relative to the working directory. Creates necessary directories in the path if they don’t exist. If the target path already exists, the write will fail.

working_dir: Working directory. If not provided, the file will be read from the

box.config.workingDir directory.

Returns:

FileOperator: The file operator for the written file.

Example:
>>> box.file_system.write(content="Hello, World!", path="/path/to/file", working_dir="/path/to/working_dir")
>>> box.file_system.write(content="Hello, World!", path="/path/to/file")
class gbox_sdk.wrapper.box.LinuxBoxOperator(client, data)

Bases: BaseBox

Operator class for managing Linux boxes via the Gbox SDK. Provides an interface to interact with and control Linux-based boxes.