Skip to main content

Official SDKs

Tzafon provides official SDKs for Python and TypeScript with identical functionality and APIs.

Python SDK

pip install tzafon

TypeScript SDK

npm install tzafon

Installation

pip install tzafon
export TZAFON_API_KEY=sk_your_api_key_here
from tzafon import Computer

client = Computer()  # Auto-reads from environment

Explicit API Key

from tzafon import Computer

client = Computer(api_key="sk_your_api_key_here")

Basic Usage

Both SDKs follow the same pattern with language-specific conventions.
from tzafon import Computer

client = Computer()
with client.create(kind="browser") as computer:
    computer.navigate("https://example.com")
    computer.click(100, 200)

How Actions Work

Actions execute immediately when called. Each method call sends a request to the computer instance.
from tzafon import Computer

client = Computer()
computer = client.create(kind="browser")
computer.navigate("https://example.com")  # Executes now
computer.click(100, 200)                  # Executes now

API Levels

The SDK provides two levels of API access: The wrapper provides convenient, language-idiomatic methods for common operations:
# High-level wrapper - clean and simple
computer.navigate("https://example.com")
computer.click(100, 200)
computer.screenshot()
Limitations: The wrapper methods work with single tabs only and don’t expose advanced parameters like tab_id or include_context. Use the wrapper when:
  • You’re working with a single tab
  • You want clean, readable code
  • You don’t need page context or advanced features

Direct API or execute_action/execute (For Advanced Features)

Use execute_action/execute when:
  • You need multi-tab management (tab_id parameter)
  • You want page context (include_context parameter)
  • You’re batching multiple actions together
For advanced features like multi-tab management, use either the direct API or the generic execute_action()/execute() method:
# Method 1: execute_action for advanced features
computer.execute_action({
    "type": "click",
    "x": 100,
    "y": 200,
    "tab_id": "tab_abc123",
    "include_context": True
})

# Method 2: Direct API access
client.computers.click(
    computer.id,
    x=100,
    y=200,
    tab_id="tab_abc123"
)
For multi-tab workflows and page context, see Multi-Tab Management and Page Context.

Feature Parity

Core actions work identically across both SDKs:
ActionPythonTypeScript
Navigatenavigate(url)navigate(url)
Clickclick(x, y)click(x, y)
Typetype(text)type(text)
Screenshotscreenshot()screenshot()
Double Clickdouble_click(x, y)doubleClick(x, y)
Right Clickright_click(x, y)rightClick(x, y)
Dragdrag(x1, y1, x2, y2)drag(x1, y1, x2, y2)
Hotkeyhotkey(*keys)hotkey(keys)
Scrollscroll(dx, dy)scroll(dx, dy)
HTMLhtml()getHTML()
Debugdebug(command)debug(command)
Set Viewportset_viewport(w, h)setViewport(w, h)
Waitwait(seconds)wait(seconds)

Advanced Features

FeaturePythonTypeScript
Batch Actionsexecute_batch(actions)batch(actions)
Key Downexecute_action({"type": "key_down", ...})execute({ type: 'key_down', ...})
Key Upexecute_action({"type": "key_up", ...})execute({ type: 'key_up', ...})
Mouse Downexecute_action({"type": "mouse_down", ...})execute({ type: 'mouse_down', ...})
Mouse Upexecute_action({"type": "mouse_up", ...})execute({ type: 'mouse_up', ...})
Keep Alivekeep_alive()keepAlive()
Stream Eventsstream_events()streamEvents()
Stream Screencaststream_screencast()streamScreencast()

Version Requirements

Python

  • Python 3.9+
  • pip

TypeScript/Node

  • Node.js 20+ (LTS)
  • npm/yarn/pnpm

Next Steps