Learn how to chain single actions together programmatically
Build dynamic workflows by chaining single actions together programmatically. This approach gives you full control over execution flow with your own code.
Sessions maintain browser state across multiple actions:
Screen config: Set viewport dimensions
TTL: Session expires after this duration (in seconds)
Session ID: Use the same ID to chain actions together
Copy
# Create a sessionsession = client.create_session( screen_config={"width": 1440, "height": 900}, ttl=3600 # Session lasts 1 hour)# The session_id is used for all subsequent actionssession_id = session["session_id"]
Always terminate sessions when done to free up resources and avoid unnecessary charges.
Variables let you pass dynamic values to your actions:
Copy
result = client.run_single_action( action="Search for {{product}} and add to cart", session_id=session_id, id="search-and-add", variables={ "product": "wireless headphones" })
Variables are replaced at runtime using the {{variable_name}} syntax.
result = client.run_single_action( action="Click the login button", session_id=session_id, id="click-login")# Access the resultprint(result["success"]) # True/Falseprint(result["result"]) # Description of what happenedprint(result["credits"]) # Credits used