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.

1from scrapybara import Scrapybara
2
3client = 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.

1instance = client.start_ubuntu(
2 timeout_hours=1,
3)
4
5# browser_instance = client.start_browser(
6# timeout_hours=1,
7# )
8
9# windows_instance = client.start_windows(
10# timeout_hours=1,
11# )
5

Get the stream URL

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

1stream_url = instance.get_stream_url().stream_url
6

Interact with the instance

Interact with the instance with computer and bash.

Move the mouse
1instance.computer(
2 action="mouse_move",
3 coordinate=[200, 100]
4)
Left click
1instance.computer(
2 action="left_click"
3)
Type hello
1instance.computer(
2 action="type",
3 text="Hello, world!"
4)
Run a bash command
1result = instance.bash(
2 command="ls -la"
3)
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
1from playwright.sync_api import sync_playwright
2
3cdp_url = instance.browser.start().cdp_url
4playwright = sync_playwright().start()
5browser = playwright.chromium.connect_over_cdp(cdp_url)
Save the auth state
1auth_state_id = instance.browser.save_auth(name="default").auth_state_id
Reuse the auth state on other instances
1instance.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.

1from scrapybara.tools import BashTool, ComputerTool, EditTool
2from scrapybara.anthropic import Anthropic
3from scrapybara.prompts import UBUNTU_SYSTEM_PROMPT
4
5response = client.act(
6 model=Anthropic(),
7 tools=[
8 BashTool(instance),
9 ComputerTool(instance),
10 EditTool(instance),
11 ],
12 system=UBUNTU_SYSTEM_PROMPT,
13 prompt="Go to the top link on Hacker News",
14 on_step=lambda step: print(step.text),
15)
9

Stop the instance

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

1instance.stop()

Start building

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

Built with