Skip to main content

No project description provided

Project description

Smooth Python SDK

The Smooth Python SDK provides a convenient way to interact with the Smooth API for programmatic browser automation and task execution.

Features

  • Synchronous and Asynchronous Clients: Choose between SmoothClient for traditional sequential programming and SmoothAsyncClient for high-performance asynchronous applications.
  • Task Management: Easily run tasks and retrieve results upon completion.
  • Interactive Browser Sessions: Get access to, interact with, and delete stateful browser sessions to manage your login credentials.
  • Advanced Task Configuration: Customize task execution with options for device type, session recording, stealth mode, and proxy settings.

Installation

You can install the Smooth Python SDK using pip:

pip install smooth-py

Authentication

The SDK requires an API key for authentication. You can provide the API key in two ways:

  1. Directly in the client constructor:

    from smooth import SmoothClient
    
    client = SmoothClient(api_key="YOUR_API_KEY")
    
  2. As an environment variable:

    Set the CIRCLEMIND_API_KEY environment variable, and the client will automatically use it.

    export CIRCLEMIND_API_KEY="YOUR_API_KEY"
    
    from smooth import SmoothClient
    
    # The client will pick up the API key from the environment variable
    client = SmoothClient()
    

Usage

Synchronous Client

The SmoothClient is ideal for scripts and applications that don't require asynchronous operations.

Running a Task and Waiting for the Result

The run method returns a TaskHandle. You can use the result() method on this handle to wait for the task to complete and get its final state.

from smooth import SmoothClient
from smooth.models import ApiError, TimeoutError

with SmoothClient() as client:
    try:
        # The run method returns a handle to the task immediately
        task_handle = client.run(
            task="Go to https://www.google.com and search for 'Smooth SDK'",
            device="desktop",
            enable_recording=True
        )
        print(f"Task submitted with ID: {task_handle.id}")
        print(f"Live view available at: {task_handle.live_url}")

        # The result() method waits for the task to complete
        completed_task = task_handle.result()
        
        if completed_task.status == "done":
            print("Task Result:", completed_task.output)
            print(f"View recording at: {completed_task.recording_url}")
        else:
            print("Task Failed:", completed_task.output)
            
    except TimeoutError:
        print("The task timed out.")
    except ApiError as e:
        print(f"An API error occurred: {e}")

Managing Browser Sessions

You can create, list, and delete browser sessions to maintain state (like logins) between tasks.

from smooth import SmoothClient

with SmoothClient() as client:
    # Create a new browser session
    browser_session = client.open_session()
    print("Live URL:", browser_session.live_url)
    print("Session ID:", browser_session.session_id)

    # List all browser sessions
    sessions = client.list_sessions()
    print("All Session IDs:", sessions.session_ids)

    # Delete the browser session
    client.delete_session(session_id=session_id)
    print(f"Session '{session_id}' deleted.")

Asynchronous Client

The SmoothAsyncClient is designed for use in asynchronous applications, such as those built with asyncio, to handle multiple operations concurrently without blocking.

Running a Task and Waiting for the Result

The run method returns an AsyncTaskHandle. Await the result() method on the handle to get the final task status.

import asyncio
from smooth import SmoothAsyncClient
from smooth.models import ApiError, TimeoutError

async def main():
    async with SmoothAsyncClient() as client:
        try:
            # The run method returns a handle to the task immediately
            task_handle = await client.run(
                task="Go to Github and search for \"smooth-sdk\""
            )
            print(f"Task submitted with ID: {task_handle.id}")
            print(f"Live view available at: {task_handle.live_url}")

            # The result() method waits for the task to complete
            completed_task = await task_handle.result()
            
            if completed_task.status == "done":
                print("Task Result:", completed_task.output)
            else:
                print("Task Failed:", completed_task.output)
                
        except TimeoutError:
            print("The task timed out.")
        except ApiError as e:
            print(f"An API error occurred: {e}")

if __name__ == "__main__":
    asyncio.run(main())

Project details


Release history Release notifications | RSS feed

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

smooth_py-0.1.3.post0.tar.gz (6.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

smooth_py-0.1.3.post0-py3-none-any.whl (6.4 kB view details)

Uploaded Python 3

File details

Details for the file smooth_py-0.1.3.post0.tar.gz.

File metadata

  • Download URL: smooth_py-0.1.3.post0.tar.gz
  • Upload date:
  • Size: 6.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for smooth_py-0.1.3.post0.tar.gz
Algorithm Hash digest
SHA256 19ff44555542f926d1d6f1b0bcdcf5ecf7ac8a4de8d18eaa7d11d2207c8afd4a
MD5 d8268b096f2fe3ecc7287d8a0079f7de
BLAKE2b-256 67dcc1ed25f98ed1b980f566cf6bf1f301bd368bc46f0d576ba8c1e5a9eed781

See more details on using hashes here.

Provenance

The following attestation bundles were made for smooth_py-0.1.3.post0.tar.gz:

Publisher: publish.yaml on circlemind-ai/smooth-sdk

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file smooth_py-0.1.3.post0-py3-none-any.whl.

File metadata

File hashes

Hashes for smooth_py-0.1.3.post0-py3-none-any.whl
Algorithm Hash digest
SHA256 d9d3b65174948cc378ca157038f7716e34891e5ed41c19fe33af5b1f2fd64a53
MD5 f9abb219fc321ff55f745009052359e5
BLAKE2b-256 bbc8d451b483f5872b566d7f7668e38fac7db912035f4c227b1f9a68743f505a

See more details on using hashes here.

Provenance

The following attestation bundles were made for smooth_py-0.1.3.post0-py3-none-any.whl:

Publisher: publish.yaml on circlemind-ai/smooth-sdk

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page