feat(sdk): expose Browserbase search and fetch - #2828
Conversation
🦋 Changeset detectedLatest commit: 30fae44 The changes in this PR will be included in the next version bump. This PR includes changesets to release 12 packages
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 |
There was a problem hiding this comment.
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
Reply with feedback, questions, or to request a fix.
Re-trigger cubic
There was a problem hiding this comment.
Review completed against the latest diff
Reply with feedback, questions, or to request a fix.
Re-trigger cubic
4fdcd07 to
63e4e30
Compare
seanmcguire12
left a comment
There was a problem hiding this comment.
can we add examples in each examples/ dir ?
63e4e30 to
019d567
Compare
|
Addressed the examples request in 30fae44 with separate runnable Fetch and Search examples in each SDK: |
019d567 to
30fae44
Compare
Summary
Testing
Summary by cubic
Implements AP-2921 by exposing Browserbase Search and Fetch through the TypeScript and Python
browserbasefacades and Go'sSearchBrowserbase/FetchBrowserbasefunctions, without launching a browser.Written for commit 30fae44. Summary will update on new commits.