1

Get your API Key

Go over the Dashboard’s Settings tab:

Then copy your API Key directly from the input.

2

Install the Browserbase SDK, Playwright, and Langchain Community

  pip install browserbase playwright langchain_community
3

Load documents or images

Load documents

from langchain_community.document_loaders import BrowserbaseLoader
import os 

load_dotenv()

BROWSERBASE_API_KEY = os.getenv("BROWSERBASE_API_KEY")
BROWSERBASE_PROJECT_ID = os.getenv("BROWSERBASE_PROJECT_ID")

loader = BrowserbaseLoader(
    api_key=BROWSERBASE_API_KEY,
    project_id=BROWSERBASE_PROJECT_ID,
    urls=[
        # load multiple pages
        "https://www.espn.com",
        "https://lilianweng.github.io/posts/2023-06-23-agent/"
    ],
    text_content=True,
)

documents = loader.load()
print(documents)

Loader Options

  • urls Required. A list of URLs to fetch.
  • text_content Retrieve only text content. Default is False.
  • api_key Browserbase API key. Default is BROWSERBASE_API_KEY env variable.
  • project_id Browserbase Project ID. Default is BROWSERBASE_PROJECT_ID env variable.
  • session_id Optional. Provide an existing Session ID.
  • proxy Optional. Enable/Disable Proxies.

Was this page helpful?