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. This SDK includes both synchronous and asynchronous clients to suit different programming needs.

Features

  • Synchronous and Asynchronous Clients: Choose between SyncClient for traditional sequential programming and AsyncClient for high-performance asynchronous applications.
  • Task Management: Easily run tasks, check their status, and retrieve results.
  • Interactive Browser Sessions: Get access to and manage interactive browser sessions.

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 SyncClient
    
    client = SyncClient(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 SyncClient
    
    # The client will pick up the API key from the environment variable
    client = SyncClient()
    

Usage

Synchronous Client

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

Running a Task and Waiting for the Result

from smooth import SyncClient, TaskRequest

with SyncClient() as client:
    task_payload = TaskRequest(
        task="Go to https://www.google.com and search for 'Smooth SDK'"
    )
    
    try:
        completed_task = client.run_and_wait_for_task(task_payload)
        
        if completed_task.result:
            print("Task Result:", completed_task.result)
        else:
            print("Task Error:", completed_task.error)
            
    except TimeoutError:
        print("The task timed out.")
    except ApiError as e:
        print(f"An API error occurred: {e}")

Managing Browser Sessions

from smooth import SyncClient

with SyncClient() as client:
    # Get a new browser session
    browser_session = client.get_browser(session_name="my-test-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)

Asynchronous Client

The AsyncClient 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

import asyncio
from smooth import AsyncClient, TaskRequest

async def main():
    async with AsyncClient() as client:
        task_payload = TaskRequest(
            task="Go to Github and search for \"smooth-sdk\""
        )
        
        try:
            completed_task = await client.run_and_wait_for_task(task_payload)
            
            if completed_task.result:
                print("Task Result:", completed_task.result)
            else:
                print("Task Error:", completed_task.error)
                
        except TimeoutError:
            print("The task timed out.")
        except ApiError as e:
            print(f"An API error occurred: {e}")

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

Managing Browser Sessions

import asyncio
from smooth import AsyncClient

async def main():
    async with AsyncClient() as client:
        # Get a new browser session
        browser_session = await client.get_browser(session_name="my-async-session")
        print("Live URL:", browser_session.live_url)
        print("Session ID:", browser_session.session_id)

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

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.1.post0.tar.gz (5.4 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.1.post0-py3-none-any.whl (5.7 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: smooth_py-0.1.1.post0.tar.gz
  • Upload date:
  • Size: 5.4 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.1.post0.tar.gz
Algorithm Hash digest
SHA256 2c2abbeb10be8b5c47b782176a4adf7e34fa613b78f3fcc9b8bdb245fabdb9a7
MD5 611706c1ab929091c56fb8f2b1b55b48
BLAKE2b-256 58d01a72f91bdf892d2ebe1c022e3687b428b7b55aec48e5612cdeadb346ab6a

See more details on using hashes here.

Provenance

The following attestation bundles were made for smooth_py-0.1.1.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.1.post0-py3-none-any.whl.

File metadata

File hashes

Hashes for smooth_py-0.1.1.post0-py3-none-any.whl
Algorithm Hash digest
SHA256 e42498c90f31063ec7a900c996040ff091fe12b12751eac76899850d1a3f118a
MD5 8fc81aa6682192355db2a37b20bd7859
BLAKE2b-256 2306185f23c032cb263731f7e903011c77b50a8287560ac952884659080281eb

See more details on using hashes here.

Provenance

The following attestation bundles were made for smooth_py-0.1.1.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