Skip to content

feat(sdk): expose Browserbase search and fetch - #2828

Merged
miguelg719 merged 9 commits into
mainfrom
miguelgonzalez/ap-2921-export-browserbasesearch-and-browserbasefetch-through
Sep 2, 2026
Merged

feat(sdk): expose Browserbase search and fetch#2828
miguelg719 merged 9 commits into
mainfrom
miguelgonzalez/ap-2921-export-browserbasesearch-and-browserbasefetch-through

Conversation

@miguelg719

@miguelg719 miguelg719 commented Aug 27, 2026

Copy link
Copy Markdown
Collaborator

Summary

  • expose Browserbase Search and Fetch through the TypeScript and Python browserbase facades
  • add equivalent SearchBrowserbase and FetchBrowserbase APIs to Go using the existing Browserbase HTTP transport
  • normalize response models across SDKs and document usage

Testing

  • pnpm --filter @browserbasehq/stagehand build
  • pnpm --filter @browserbasehq/stagehand test:unit (199 passed)
  • Python Ruff, ty, and pytest (460 passed, 1 skipped)
  • Go package tests (passed)

Summary by cubic

Implements AP-2921 by exposing Browserbase Search and Fetch through the TypeScript and Python browserbase facades and Go's SearchBrowserbase/FetchBrowserbase functions, without launching a browser.

  • Uses the official Browserbase SDK in TypeScript and Python and the existing HTTP transport in Go.
  • Validates query limits, fetch formats, schema requirements, URLs, and required Go search-result fields.
  • Normalizes result models, adds typed fetch content handling in Go, and keeps the three SDKs' APIs in sync.
  • Adds README examples and tests, and improves Go extension drift checks with SHA-256 hashes and cache invalidation.

Written for commit 30fae44. Summary will update on new commits.

Review in cubic

@changeset-bot

changeset-bot Bot commented Aug 27, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 30fae44

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 12 packages
Name Type
@browserbasehq/stagehand-python Minor
@browserbasehq/stagehand-go Minor
@browserbasehq/stagehand Minor
@browserbasehq/stagehand-integrations Patch
@browserbasehq/stagehand-integrations-example-eve-facade Patch
@browserbasehq/stagehand-integrations-example-pi-facade Patch
@browserbasehq/stagehand-integrations-claude-agent-sdk Patch
@browserbasehq/stagehand-integrations-example-claude-code-facade Patch
@browserbasehq/stagehand-integrations-codex-sdk Patch
@browserbasehq/stagehand-integrations-example-codex-facade Patch
@browserbasehq/stagehand-integrations-example-mastra-facade Patch
@browserbasehq/stagehand-integrations-example-vercel-ai-facade Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All reported issues were addressed across 19 files

Architecture diagram
sequenceDiagram
    participant User as SDK User
    participant TS as TypeScript SDK<br/>(browserbase facade)
    participant Py as Python SDK<br/>(browserbase facade)
    participant Go as Go SDK<br/>(SearchBrowserbase/FetchBrowserbase)
    participant BB as Browserbase API

    Note over TS,Go: Search Flow

    User->>TS: browserbase.search({apiKey, query, numResults})
    TS->>TS: Validate options (zod: query min 1,<br/>numResults 1-25, strictObject)
    TS->>BB: POST /v1/search with X-BB-API-Key
    BB-->>TS: Search results (query, requestId, results[])
    TS->>TS: Parse/validate response schema
    TS-->>User: BrowserbaseSearchResult

    User->>Py: browserbase.search(api_key, query, num_results)
    Py->>Py: Validate options (pydantic: query min 1,<br/>num_results 1-25)
    Py->>BB: AsyncBrowserbase.search.web()
    BB-->>Py: Search results
    Py->>Py: Normalize publishedDate to ISO format
    Py-->>User: BrowserbaseSearchResult

    User->>Go: SearchBrowserbase(ctx, BrowserbaseSearchOptions)
    Go->>Go: Validate options (query required,<br/>numResults 1-25)
    Go->>Go: Create HTTP client with API key
    Go->>BB: POST /v1/search with X-BB-API-Key
    BB-->>Go: Search response JSON
    Go->>Go: Validate required response fields<br/>(query, requestId, results)
    Go-->>User: BrowserbaseSearchResult

    Note over TS,Go: Fetch Flow

    User->>TS: browserbase.fetch({apiKey, url, format})
    TS->>TS: Validate options (zod: url valid,<br/>format enum raw/json/markdown)
    TS->>BB: POST /v1/fetch with X-BB-API-Key
    BB-->>TS: Fetch result (id, content, contentType,<br/>encoding, headers, statusCode)
    TS->>TS: Parse/validate response schema
    TS-->>User: BrowserbaseFetchResult

    User->>Py: browserbase.fetch(api_key, url, format)
    Py->>Py: Validate options (pydantic: url valid,<br/>format enum, schema alias)
    Py->>BB: AsyncBrowserbase.fetch_api.create()
    BB-->>Py: Fetch result
    Py->>Py: Normalize response fields
    Py-->>User: BrowserbaseFetchResult

    User->>Go: FetchBrowserbase(ctx, BrowserbaseFetchOptions)
    Go->>Go: Validate options (url http/https,<br/>format enum)
    Go->>Go: Create HTTP client with API key
    Go->>BB: POST /v1/fetch with X-BB-API-Key
    BB-->>Go: Fetch response JSON
    Go->>Go: Validate required fields +<br/>decode content (string or object)
    Go-->>User: BrowserbaseFetchResult

    Note over BB: All requests require<br/>X-BB-API-Key header
Loading

Reply with feedback, questions, or to request a fix.

Re-trigger cubic

Comment thread packages/sdk-ts/src/clientSchemas.ts Outdated
Comment thread packages/sdk-ts/src/browser/browserbaseServices.ts
Comment thread packages/sdk-python/README.md Outdated
Comment thread packages/sdk-go/README.md Outdated
Comment thread packages/sdk-go/browserbase_services.go Outdated
Comment thread packages/sdk-python/tests/test_browser.py
@miguelg719
miguelg719 marked this pull request as draft August 27, 2026 02:28
@miguelg719
miguelg719 marked this pull request as ready for review August 27, 2026 03:18

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review completed against the latest diff

Reply with feedback, questions, or to request a fix.

Re-trigger cubic

Comment thread packages/sdk-go/README.md Outdated
Comment thread packages/sdk-go/browserbase_services.go
@miguelg719
miguelg719 force-pushed the miguelgonzalez/ap-2921-export-browserbasesearch-and-browserbasefetch-through branch from 4fdcd07 to 63e4e30 Compare September 1, 2026 00:54
@charlypoly
charlypoly requested a review from ziruihao September 2, 2026 02:33

@seanmcguire12 seanmcguire12 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we add examples in each examples/ dir ?

Comment thread packages/sdk-ts/src/clientSchemas.ts
Comment thread packages/sdk-go/browserbase_services.go Outdated
Comment thread README.md Outdated
@miguelg719
miguelg719 force-pushed the miguelgonzalez/ap-2921-export-browserbasesearch-and-browserbasefetch-through branch from 63e4e30 to 019d567 Compare September 2, 2026 19:05
@miguelg719

miguelg719 commented Sep 2, 2026

Copy link
Copy Markdown
Collaborator Author

Addressed the examples request in 30fae44 with separate runnable Fetch and Search examples in each SDK: packages/sdk-ts/examples/{fetch,search}.ts, packages/sdk-python/examples/{fetch,search}.py, and packages/sdk-go/examples/{fetch,search}.go. Also rebased onto current main; local TypeScript, Python, Go, formatting, lint, package-contract, and extension-drift checks pass.

@miguelg719
miguelg719 force-pushed the miguelgonzalez/ap-2921-export-browserbasesearch-and-browserbasefetch-through branch from 019d567 to 30fae44 Compare September 2, 2026 19:11
@miguelg719
miguelg719 merged commit e2c8946 into main Sep 2, 2026
55 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants