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 SMOOTH_API_KEY environment variable, and the client will automatically use it.

    export SMOOTH_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.0.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.0-py3-none-any.whl (5.7 kB view details)

Uploaded Python 3

File details

Details for the file smooth_py-0.1.0.tar.gz.

File metadata

  • Download URL: smooth_py-0.1.0.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.0.tar.gz
Algorithm Hash digest
SHA256 8bf641f854756560a6abd7f43a4429f6c9357a6ec7f5364df19ed6e5cca29eae
MD5 09cf7d5b64d63f56dcbec2b9860d4edc
BLAKE2b-256 ec662ad405236823beaabd4c6f2beffbd7254e2b34da99c86efe6aea78346272

See more details on using hashes here.

Provenance

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

File metadata

  • Download URL: smooth_py-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 5.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for smooth_py-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 82b0cd8f3a2c9a342723c0a6f03b47d9341854f7ea0fb19ad1a6237051f1040b
MD5 ae5b7bcd6044debf10bcd458cb23d761
BLAKE2b-256 64bd4f2453c864f007ed79bdcca31158d838874977047702fd7a6e48d402f8fa

See more details on using hashes here.

Provenance

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