Skip to main content

Python SDK Overview

Contributions are welcome at https://github.com/CloudCruise/cloudcruise-python. Report bugs via GitHub issues or Discord. The CloudCruise Python SDK lets you launch browser automation workflows, stream run events, verify webhooks, and manage vault credentials directly from Python services.

Installation

Set the required credentials in code or via environment variables (CLOUDCRUISE_API_KEY, CLOUDCRUISE_ENCRYPTION_KEY). Retrieve them from CloudCruise Settings.

1. Creating a Run

By default a run executes the latest version on the workflow’s default branch. Set at most one of workflow_version (an exact version or semver range such as "1.2.3", "^1.2.0" or "1.x"; the highest matching release runs) or workflow_branch_id (that branch’s latest version runs) to pin it. Workflows shows how to list versions and branches, and Workflow Versioning explains what each version bump means and which pin to choose. The server validates run_input_variables against the input schema of the version that runs. Invalid input raises InputValidationError.

2. Listening to run events

Attach per-event handlers for an attribute-access experience. Each handler receives a FlattenedRunEvent with type, payload, timestamp, expires_at, and raw.
You can also subscribe to run.event once and switch on event.type:

Async iteration (streaming)

Prefer a loop? Iterate over the handle to process the underlying SSE messages. Each item is the original SSE envelope.

Other available events

  • open: connection established
  • ping: heartbeat messages
  • reconnect: reconnect attempts with {"attemptDelayMs": ...}
  • message: catch-all mirror of run.event and ping
  • error: SSE errors
  • end: the run reached a final status (execution.success, execution.failed or execution.stopped; see Run Statuses)
Example:

3. Wait for Completion

You can block until the workflow completes. For long-running workflows this may take a while, so use cautiously. The returned value is a RunResult dataclass.

Watching a Live Session

While a session is running, fetch a viewer URL to watch its browser stream:
The auth token embedded in connection.url is single-use — reopening a previously used viewer link (reloading the tab, or opening it later) fails to connect. Call get_live_view_connection again to mint a fresh link instead of reusing the old one. This only works while the session is still active.

Next Steps

  • Explore the Run API for detailed workflow execution options
  • Learn about Vault API for secure credential management
  • Check out Workflow API to manage your workflows
  • Set up Webhooks for event notifications