Skip to main content

Official Python SDK for the Simplex API

Project description

Simplex Python SDK

Official Python SDK for the Simplex API - A powerful workflow automation platform for browser-based tasks.

Python Version License: MIT

Installation

pip install simplex

Quick Start

import time
from simplex import SimplexClient

# Initialize the client
client = SimplexClient(api_key="your-api-key")

# Run a workflow
response = client.run_workflow(
    "workflow-id",
    variables={"email": "user@example.com"}
)

print(f"Session started: {response['session_id']}")

# Poll for completion
while True:
    status = client.get_session_status(response["session_id"])
    if not status["in_progress"]:
        break
    time.sleep(1)

# Check results
if status["success"]:
    print("Success!")
    print("Scraper outputs:", status["scraper_outputs"])
    print("File metadata:", status["file_metadata"])
else:
    print("Failed")

API Reference

SimplexClient

client = SimplexClient(
    api_key="your-api-key",
    base_url="https://api.simplex.sh",  # Optional
    timeout=30,                          # Request timeout in seconds
    max_retries=3,                       # Retry attempts for failed requests
    retry_delay=1.0,                     # Delay between retries in seconds
)

Methods

run_workflow(workflow_id, variables=None, metadata=None, webhook_url=None)

Run a workflow by its ID.

response = client.run_workflow(
    "workflow-id",
    variables={"key": "value"},
    metadata="optional metadata",
    webhook_url="https://your-webhook.com/callback"
)

print(response["session_id"])  # Session ID for polling
print(response["vnc_url"])     # VNC URL to watch the session

get_session_status(session_id)

Get the status of a running or completed session.

status = client.get_session_status("session-id")

print(status["in_progress"])       # True while running
print(status["success"])           # True/False when complete, None while running
print(status["scraper_outputs"])   # Data collected by scrapers
print(status["file_metadata"])     # Metadata for downloaded files
print(status["metadata"])          # Custom metadata
print(status["workflow_metadata"]) # Workflow metadata

download_session_files(session_id, filename=None)

Download files from a completed session.

# Download all files as a zip
zip_data = client.download_session_files("session-id")
with open("files.zip", "wb") as f:
    f.write(zip_data)

# Download a specific file
pdf_data = client.download_session_files("session-id", filename="report.pdf")
with open("report.pdf", "wb") as f:
    f.write(pdf_data)

retrieve_session_replay(session_id)

Download the session replay video (MP4).

video = client.retrieve_session_replay("session-id")
with open("replay.mp4", "wb") as f:
    f.write(video)

retrieve_session_logs(session_id)

Get the session logs as parsed JSON.

logs = client.retrieve_session_logs("session-id")
for entry in logs:
    print(f"{entry['timestamp']}: {entry['message']}")

Error Handling

The SDK provides specific exception types for different error scenarios:

from simplex import (
    SimplexClient,
    SimplexError,
    WorkflowError,
    AuthenticationError,
    RateLimitError,
    NetworkError,
    ValidationError,
)

client = SimplexClient(api_key="your-api-key")

try:
    result = client.run_workflow("workflow-id")
except AuthenticationError as e:
    print(f"Invalid API key: {e.message}")
except RateLimitError as e:
    print(f"Rate limited. Retry after {e.retry_after} seconds")
except ValidationError as e:
    print(f"Invalid request: {e.message}")
except WorkflowError as e:
    print(f"Workflow error: {e.message}")
    print(f"Session ID: {e.session_id}")
except NetworkError as e:
    print(f"Network error: {e.message}")
except SimplexError as e:
    print(f"General error: {e.message}")

Type Hints

The SDK includes full type hints for better IDE support:

from simplex import (
    SimplexClient,
    SessionStatusResponse,
    RunWorkflowResponse,
    FileMetadata,
)

client = SimplexClient(api_key="your-api-key")
response: RunWorkflowResponse = client.run_workflow("workflow-id")
status: SessionStatusResponse = client.get_session_status(response["session_id"])

Requirements

  • Python 3.9+
  • requests>=2.25.0

License

MIT License - see LICENSE for details.

Support

Project details


Release history Release notifications | RSS feed

This version

3.0.1

Download files

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

Source Distribution

simplex-3.0.1.tar.gz (13.5 kB view details)

Uploaded Source

Built Distribution

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

simplex-3.0.1-py3-none-any.whl (13.9 kB view details)

Uploaded Python 3

File details

Details for the file simplex-3.0.1.tar.gz.

File metadata

  • Download URL: simplex-3.0.1.tar.gz
  • Upload date:
  • Size: 13.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.5

File hashes

Hashes for simplex-3.0.1.tar.gz
Algorithm Hash digest
SHA256 fde4428f65d7e8a5822983427680e37d9856d9bb110297011a9ea27b2b3038df
MD5 b0c782643cb20d3214b267c11895810d
BLAKE2b-256 329512f26bf683e008604246710be1d9113ab8e90e81a3a0be15e490fd4f937d

See more details on using hashes here.

File details

Details for the file simplex-3.0.1-py3-none-any.whl.

File metadata

  • Download URL: simplex-3.0.1-py3-none-any.whl
  • Upload date:
  • Size: 13.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.5

File hashes

Hashes for simplex-3.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 d6b5cbfa885dc4ae3d194133e7a77c0386e120a7afa1437408dccd4a0d6076f7
MD5 37a201dd3e62d3cc0fb5573cbb2e3125
BLAKE2b-256 34763489c28d5da60da277e9aef1ead478f2f38c4a16f667ec0db2d6f333c09e

See more details on using hashes here.

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