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

Uploaded Python 3

File details

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

File metadata

  • Download URL: smooth_py-0.1.1.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.tar.gz
Algorithm Hash digest
SHA256 3a3d505cbb726e5c09717b48ba70b83c9888f0e65a982bc37b0008ce5b980bc2
MD5 35ea08b1b197089c234ee8f3f9478019
BLAKE2b-256 f26491fe5733547c7929bd6e09ef13d8f00a45d4df9f6feaa66d067b2175b638

See more details on using hashes here.

Provenance

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

File metadata

  • Download URL: smooth_py-0.1.1-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.1-py3-none-any.whl
Algorithm Hash digest
SHA256 4b9b94089e28995219436afc694444b9b239e154f56640a6f04dace0c77633cb
MD5 29ad44a6844df99008d345bae0494c98
BLAKE2b-256 5341660e3d3cb36f3625589da8e596934a7d3847f9da3687d700bad95a910d40

See more details on using hashes here.

Provenance

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