Quickstart

Deploy your first instance

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.

from scrapybara import Scrapybara
client = Scrapybara(api_key="your_api_key")
4

Start an instance

Start an instance with your desired configuration. You can choose from Ubuntu, Browser, and Windows instances. We recommend using Ubuntu for most tasks.

instance = client.start_ubuntu(
timeout_hours=1,
)
# browser_instance = client.start_browser(
# timeout_hours=1,
# )
5

Get the stream URL

Get the stream URL to view and interact with the instance manually.

stream_url = instance.get_stream_url().stream_url
6

Interact with the instance

Interact with the instance with computer and bash.

Move the mouse
instance.computer(
action="move_mouse",
coordinates=[200, 100]
)
Left click
instance.computer(
action="click_mouse",
button="left"
)
Type hello
instance.computer(
action="type_text",
text="Hello, world!"
)
Run a bash command
result = instance.bash(
command="ls -la"
)
7

Connect to the browser

Connect to the browser with Playwright to enable programmatic browser control and authenticated browser sessions. Learn more here.

Connect to Playwright
from playwright.sync_api import sync_playwright
cdp_url = instance.browser.start().cdp_url
playwright = sync_playwright().start()
browser = playwright.chromium.connect_over_cdp(cdp_url)
Save the auth state
auth_state_id = instance.browser.save_auth(name="default").auth_state_id
Reuse the auth state on other instances
instance.browser.authenticate(auth_state_id=auth_state_id)
8

Take action!

Build your first agent with the Act SDK to control your Scrapybara instance with BashTool, ComputerTool, EditTool. Learn more here.

from scrapybara.tools import BashTool, ComputerTool, EditTool
from scrapybara.openai import OpenAI, UBUNTU_SYSTEM_PROMPT
response = client.act(
model=OpenAI(),
tools=[
BashTool(instance),
ComputerTool(instance),
EditTool(instance),
],
system=UBUNTU_SYSTEM_PROMPT,
prompt="Go to the top link on Hacker News",
on_step=lambda step: print(step.text),
)
9

Stop the instance

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

instance.stop()

Start building

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