1- # Stagehand Python API library
1+ # Browserbase Python API library
22
33<!-- prettier-ignore -->
44[ ![ PyPI version] ( https://img.shields.io/pypi/v/stagehand.svg?label=pypi%20(stable) )] ( https://pypi.org/project/stagehand/ )
55
6- The Stagehand Python library provides convenient access to the Stagehand REST API from any Python 3.9+
6+ The Browserbase Python library provides convenient access to the Browserbase REST API from any Python 3.9+
77application. The library includes type definitions for all request params and response fields,
88and offers both synchronous and asynchronous clients powered by [ httpx] ( https://github.com/encode/httpx ) .
99
@@ -29,12 +29,12 @@ The full API of this library can be found in [api.md](api.md).
2929
3030``` python
3131import os
32- from stagehand import Stagehand
32+ from stagehand import Browserbase
3333
34- client = Stagehand (
34+ client = Browserbase (
3535 api_key = os.environ.get(" STAGEHAND_API_KEY" ), # This is the default and can be omitted
36- # defaults to "production".
37- environment = " environment_1 " ,
36+ # or 'production' | 'local'; defaults to "production".
37+ environment = " dev " ,
3838)
3939
4040response = client.sessions.start(
@@ -50,17 +50,17 @@ so that your API Key is not stored in source control.
5050
5151## Async usage
5252
53- Simply import ` AsyncStagehand ` instead of ` Stagehand ` and use ` await ` with each API call:
53+ Simply import ` AsyncBrowserbase ` instead of ` Browserbase ` and use ` await ` with each API call:
5454
5555``` python
5656import os
5757import asyncio
58- from stagehand import AsyncStagehand
58+ from stagehand import AsyncBrowserbase
5959
60- client = AsyncStagehand (
60+ client = AsyncBrowserbase (
6161 api_key = os.environ.get(" STAGEHAND_API_KEY" ), # This is the default and can be omitted
62- # defaults to "production".
63- environment = " environment_1 " ,
62+ # or 'production' | 'local'; defaults to "production".
63+ environment = " dev " ,
6464)
6565
6666
@@ -93,11 +93,11 @@ Then you can enable it by instantiating the client with `http_client=DefaultAioH
9393import os
9494import asyncio
9595from stagehand import DefaultAioHttpClient
96- from stagehand import AsyncStagehand
96+ from stagehand import AsyncBrowserbase
9797
9898
9999async def main () -> None :
100- async with AsyncStagehand (
100+ async with AsyncBrowserbase (
101101 api_key = os.environ.get(" STAGEHAND_API_KEY" ), # This is the default and can be omitted
102102 http_client = DefaultAioHttpClient(),
103103 ) as client:
@@ -124,9 +124,9 @@ Typed requests and responses provide autocomplete and documentation within your
124124Nested parameters are dictionaries, typed using ` TypedDict ` , for example:
125125
126126``` python
127- from stagehand import Stagehand
127+ from stagehand import Browserbase
128128
129- client = Stagehand ()
129+ client = Browserbase ()
130130
131131response = client.sessions.start(
132132 env = " LOCAL" ,
@@ -146,9 +146,9 @@ All errors inherit from `stagehand.APIError`.
146146
147147``` python
148148import stagehand
149- from stagehand import Stagehand
149+ from stagehand import Browserbase
150150
151- client = Stagehand ()
151+ client = Browserbase ()
152152
153153try :
154154 client.sessions.start(
@@ -187,10 +187,10 @@ Connection errors (for example, due to a network connectivity problem), 408 Requ
187187You can use the ` max_retries ` option to configure or disable retry settings:
188188
189189``` python
190- from stagehand import Stagehand
190+ from stagehand import Browserbase
191191
192192# Configure the default for all requests:
193- client = Stagehand (
193+ client = Browserbase (
194194 # default is 2
195195 max_retries = 0 ,
196196)
@@ -207,16 +207,16 @@ By default requests time out after 1 minute. You can configure this with a `time
207207which accepts a float or an [ ` httpx.Timeout ` ] ( https://www.python-httpx.org/advanced/timeouts/#fine-tuning-the-configuration ) object:
208208
209209``` python
210- from stagehand import Stagehand
210+ from stagehand import Browserbase
211211
212212# Configure the default for all requests:
213- client = Stagehand (
213+ client = Browserbase (
214214 # 20 seconds (default is 1 minute)
215215 timeout = 20.0 ,
216216)
217217
218218# More granular control:
219- client = Stagehand (
219+ client = Browserbase (
220220 timeout = httpx.Timeout(60.0 , read = 5.0 , write = 10.0 , connect = 2.0 ),
221221)
222222
@@ -236,10 +236,10 @@ Note that requests that time out are [retried twice by default](#retries).
236236
237237We use the standard library [ ` logging ` ] ( https://docs.python.org/3/library/logging.html ) module.
238238
239- You can enable logging by setting the environment variable ` STAGEHAND_LOG ` to ` info ` .
239+ You can enable logging by setting the environment variable ` BROWSERBASE_LOG ` to ` info ` .
240240
241241``` shell
242- $ export STAGEHAND_LOG =info
242+ $ export BROWSERBASE_LOG =info
243243```
244244
245245Or to ` debug ` for more verbose logging.
@@ -261,9 +261,9 @@ if response.my_field is None:
261261The "raw" Response object can be accessed by prefixing ` .with_raw_response. ` to any HTTP method call, e.g.,
262262
263263``` py
264- from stagehand import Stagehand
264+ from stagehand import Browserbase
265265
266- client = Stagehand ()
266+ client = Browserbase ()
267267response = client.sessions.with_raw_response.start(
268268 env = " LOCAL" ,
269269)
@@ -339,10 +339,10 @@ You can directly override the [httpx client](https://www.python-httpx.org/api/#c
339339
340340``` python
341341import httpx
342- from stagehand import Stagehand , DefaultHttpxClient
342+ from stagehand import Browserbase , DefaultHttpxClient
343343
344- client = Stagehand (
345- # Or use the `STAGEHAND_BASE_URL ` env var
344+ client = Browserbase (
345+ # Or use the `BROWSERBASE_BASE_URL ` env var
346346 base_url = " http://my.test.server.example.com:8083" ,
347347 http_client = DefaultHttpxClient(
348348 proxy = " http://my.test.proxy.example.com" ,
@@ -362,9 +362,9 @@ client.with_options(http_client=DefaultHttpxClient(...))
362362By default the library closes underlying HTTP connections whenever the client is [ garbage collected] ( https://docs.python.org/3/reference/datamodel.html#object.__del__ ) . You can manually close the client using the ` .close() ` method if desired, or with a context manager that closes when exiting.
363363
364364``` py
365- from stagehand import Stagehand
365+ from stagehand import Browserbase
366366
367- with Stagehand () as client:
367+ with Browserbase () as client:
368368 # make requests here
369369 ...
370370
0 commit comments