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.

1instance = client.start(
2 instance_type="small",
3 timeout_hours=1,
4)
5

Pause and resume the instance

Pause the instance to save resources and resume it when needed.

Pause the instance
1instance.pause()
Resume the instance
1instance.resume(timeout_hours=1)
6

Interact with the instance

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

Get the stream URL
1stream_url = instance.get_stream_url().stream_url
Take a screenshot
1base_64_image = instance.screenshot().base_64_image
Move the mouse
1result = instance.computer(
2 action="mouse_move",
3 coordinate=[200, 100]
4)
Left click
1result = instance.computer(
2 action="left_click"
3)
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 SYSTEM_PROMPT
4
5response = client.act(
6 model=Anthropic(),
7 tools=[
8 BashTool(instance),
9 ComputerTool(instance),
10 EditTool(instance),
11 BrowserTool(instance),
12 ],
13 system=SYSTEM_PROMPT,
14 prompt="Go to the top link on Hacker News",
15 on_step=lambda step: print(step.text),
16)
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