Runtime SDK
Retrieve a connected user session and execute custom automation scripts
This reference is for the v0.8.0 SDK. Please see here for older versions.
Getting Started
This package is not published to public package registries (i.e. NPM) at this time.
Create a .npmrc
file in the root of your project to gain access to our private package registry.
Add the SDK to your project’s dependencies.
You’ll need the appUserId
of a user that you’ve previously linked an account with to run this code example.
The Runtime SDK makes automating actions easy. Just give it a callback to perform on your user’s behalf. Use it like this:
Use our open-source Actions library as a reference for pre-built playwright scripts such as:
Posting content on LinkedIn Searching for products on Amazon Sending a direct message on InstagramConfiguration
The anon.run()
function has a variety of configuration options to fit any use case.
You can configure where the browser runs, how network traffic is proxied, timeouts, and more.
Hosting
By default, the browser is a managed instance hosted by Browserbase. This is best for most use cases as it alleviates the need for you to manage your own browser infrastructure.
You can also use your own instance if it has an externally accessible CDP (Chrome
Devtools Protocol) URL. Note that localhost
endpoints are not typically
externally accessible.
Remote Browser
This example injects your account sessions into an existing browser instance already running on a Browserbase CDP URL.
Proxying
Anon uses proxying to mimic the network behavior of your users and avoid account flagging. You can disable this, provide your own proxies, or use Anon’s proxies with your own browser instance.
Anon only provides proxies in the US at the moment, so you will need to specify your own proxies for international users.
Using your own Proxy
Disable Proxying
Note that this will generally decrease the reliability of your app integrations, as unproxied traffic can trigger bot detection.
Timeouts
A managed browser instance has a finite lifetime. You can adjust the lifetime
using the sessionDuration
parameter. This specifies the browser lifetime in
seconds.
Setting browser instance lifetime:
Monitoring
Live Session Rendering
Even though our managed instances are headless, you and your users can observe a rendered view of the webpage live.
You can even embed the webpage as an iframe. This can be shared with your users so that they can watch the automations as they happen.
Logs
You can pass in a custom Logger
to the
browser initialization for fine-grained control over logging:
Screenshots
You can plug into the existing Playwright screenshot functionality as follows:
Was this page helpful?