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
SyncClientfor traditional sequential programming andAsyncClientfor 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:
-
Directly in the client constructor:
from smooth import SyncClient client = SyncClient(api_key="YOUR_API_KEY")
-
As an environment variable:
Set the
SMOOTH_API_KEYenvironment 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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
8bf641f854756560a6abd7f43a4429f6c9357a6ec7f5364df19ed6e5cca29eae
|
|
| MD5 |
09cf7d5b64d63f56dcbec2b9860d4edc
|
|
| BLAKE2b-256 |
ec662ad405236823beaabd4c6f2beffbd7254e2b34da99c86efe6aea78346272
|
Provenance
The following attestation bundles were made for smooth_py-0.1.0.tar.gz:
Publisher:
publish.yaml on circlemind-ai/smooth-sdk
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
smooth_py-0.1.0.tar.gz -
Subject digest:
8bf641f854756560a6abd7f43a4429f6c9357a6ec7f5364df19ed6e5cca29eae - Sigstore transparency entry: 406399944
- Sigstore integration time:
-
Permalink:
circlemind-ai/smooth-sdk@f7daa65c083e9580d3cd41c7bb4229777d07ceb8 -
Branch / Tag:
refs/heads/master - Owner: https://github.com/circlemind-ai
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yaml@f7daa65c083e9580d3cd41c7bb4229777d07ceb8 -
Trigger Event:
workflow_dispatch
-
Statement type:
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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
82b0cd8f3a2c9a342723c0a6f03b47d9341854f7ea0fb19ad1a6237051f1040b
|
|
| MD5 |
ae5b7bcd6044debf10bcd458cb23d761
|
|
| BLAKE2b-256 |
64bd4f2453c864f007ed79bdcca31158d838874977047702fd7a6e48d402f8fa
|
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
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
smooth_py-0.1.0-py3-none-any.whl -
Subject digest:
82b0cd8f3a2c9a342723c0a6f03b47d9341854f7ea0fb19ad1a6237051f1040b - Sigstore transparency entry: 406399965
- Sigstore integration time:
-
Permalink:
circlemind-ai/smooth-sdk@f7daa65c083e9580d3cd41c7bb4229777d07ceb8 -
Branch / Tag:
refs/heads/master - Owner: https://github.com/circlemind-ai
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yaml@f7daa65c083e9580d3cd41c7bb4229777d07ceb8 -
Trigger Event:
workflow_dispatch
-
Statement type: