Migration Guide
Migrating to the v1 Python SDK
The Browserbase v1 Python SDK has been rewritten from the ground up and ships with a ton of new features and better support that we can’t wait for you to try. This guide is designed to help you maximize your experience with v1.
We hope this guide is useful to you; if you have any questions don’t hesitate to reach out to support@browserbase.com or create a new issue.
We’ve written out specific guidelines on how to migrate each v0 method to v1 below. v1 also adds one-to-one mappings for every API endpoint, so you can incorporate new Browserbase features in your codebase with much less lift.
Breaking Changes
The v1 SDK is more flexible, easier to use, and has a more consistent API. It is also a lot more modular, meaning the majority of function calls have changed from browserbase.$thing_$do()
to browserbase.$thing.$do()
. For example:
Deleted Methods
load
, load_url
, and screenshot
have been fully removed in the v1 SDK. You can use the following example instead that encapsulates the same functionality using Playwright.
For async Playwright (like in Jupyter notebooks or IPython environments), you can import async_playwright
instead of sync_playwright
.
Updates to Common Workflows
Create Session
This is how you would create a session with the v0 SDK, where CreateSessionOptions
is a Pydantic object defined here.
Now, you can create a session with the v1 SDK by calling the create
method on sessions
.
For more complex session creation, you can import BrowserSettings
and use Pydantic’s TypeAdapter
to conform JSON spec to the appropriate Pydantic class. You can also import each individual subclass.
Get Connect URL
In the v0 SDK, you could run browserbase.get_connect_url()
to create a new session and retrieve its connect url, or browserbase.get_connect_url(session_id=some_session.id)
to retrieve the connect url for an existing session.
In the v1 SDK, you can create a session and retrieve its connect url in a single call with bb.sessions.create()
.
Complete Session
v0 allowed you to complete a session by calling browserbase.complete_session(session_id=some_session.id)
.
In the v1 SDK, completing a session is done by updating its status to REQUEST_RELEASE
.
Reference for other methods
These methods have been rewritten for modularity and flexibility. As mentioned above, the pattern here is that the method has been renamed from browserbase.$thing_$do()
to bb.$thing.$do()
.
List Sessions
Get Session
Get Session Recording
Get Session Downloads
Note: The parameter retry_interval
is no longer supported. You can configure retries with the following syntax on bb init:
Keep in mind, however, that this only affects the default retry behavior, which will only retry on 4xx/5xx errors. The remaining pattern still applies:
Get Debug Connection URLs
Get Session Logs
Was this page helpful?