Create a New Session
Creates a new sandbox session with specified environment type and configuration using the MarinaBox SDK.
Python SDK
from marinabox import MarinaboxSDK
sdk = MarinaboxSDK()
session = sdk.create_session(
env_type="browser", # Optional: 'browser' or 'desktop', defaults to 'browser'
tag="Development", # Optional: custom tag for the session
kiosk=False, # Optional: launch Chrome in kiosk mode (browser only)
initial_url="https://example.com" # Optional: initial URL to open (browser only)
)
# Example: Create a kiosk mode browser session with initial URL
kiosk_session = sdk.create_session(
env_type="browser",
tag="Kiosk Display",
kiosk=True,
initial_url="https://dashboard.example.com"
)
Response Object
The method returns a BrowserSession
object with the following attributes:
{
"session_id": "abc123xyz", # Unique identifier for the session
"container_id": "abc123xyz789", # Docker container ID
"vnc_port": 5002, # Port number for VNC connection
"created_at": "2024-12-14T10:30:00Z", # Creation timestamp
"env_type": "browser", # Environment type
"debug_port": 4002, # Debug port (browser only)
"status": "running", # Session status
"resolution": "1280x800x24", # Screen resolution
"tag": "Development", # Custom tag
"websocket_url": "ws://localhost:4002/devtools/browser/abc123xyz" # Browser debugging URL
}
Parameters
Parameter | Type | Required | Description |
---|
env_type | str | No | Environment type (‘browser’ or ‘desktop’). Default: ‘browser’ |
tag | str | No | Custom tag for the session |
kiosk | bool | No | Launch Chrome in kiosk mode (browser only). Default: False |
initial_url | str | No | Initial URL to open when browser starts (browser only) |
Error Handling
try:
session = sdk.create_session(env_type="invalid")
except ValueError as e:
print(f"Invalid environment type: {e}")
except Exception as e:
print(f"Failed to create session: {e}")