Deploy your first instance

1

Generate API key

Sign up on our dashboard. An API key will be generated for you automatically.

2

Install SDK

Install the Python SDK with pip.

pip install scrapybara
3

Configure client

Configure the client with your API key.

main.py
from scrapybara import Scrapybara

client = Scrapybara(api_key="your_api_key")
4

Start an instance

Start an instance with your desired configuration.

main.py
instance = client.start(
    instance_type="small",
    region="us-west-1"
)
instance_id = instance.id
5

Interact with the instance

Interact with the instance with screenshot, bash, computer, and edit.

main.py
base_64_image = client.screenshot(instance_id)
main.py
result = client.computer(
    instance_id,
    action="mouse_move",
    coordinate=[200, 100]
)
main.py
result = client.computer(
    instance_id,
    action="left_click"
)
main.py
result = client.bash(
    instance_id,
    command="ls -la"
)
6

Use with Claude Computer Use (optional)

Connect Claude Computer Use to your Scrapybara instance with BashTool, ComputerTool, EditTool, and ToolResult. See the full example here.

main.py
from scrapybara.anthropic import BashTool, ComputerTool, EditTool, ToolResult
from anthropic import Anthropic

# ToolCollection definition ommitted, see full example

tool_collection = ToolCollection(
    ComputerTool(client, instance_id),
    BashTool(client, instance_id),
    EditTool(client, instance_id)
)

anthropic_client = Anthropic(api_key="your_api_key")
response = anthropic_client.beta.messages.create(
    model="claude-3-5-sonnet-20241022",
    max_tokens=4096,
    messages=messages,
    system=[{"type": "text", "text": SYSTEM_PROMPT}],
    tools=tool_collection.to_params(),
    betas=["computer-use-2024-10-22"]
)

7

Stop the instance

Stop the instance when you’re done. This will delete all data stored during the session.

main.py
client.stop(instance_id)

Start building

Be sure to check out our other resources to learn more. Happy building! ₍ᐢ•(ܫ)•ᐢ₎