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

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: terminal status for the session
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