Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -55,14 +55,18 @@ jobs:
run: ./scripts/build

- name: Get GitHub OIDC Token
if: github.repository == 'stainless-sdks/browserbase-node'
if: |-
github.repository == 'stainless-sdks/browserbase-node' &&
!startsWith(github.ref, 'refs/heads/stl/')
id: github-oidc
uses: actions/github-script@v8
with:
script: core.setOutput('github_token', await core.getIDToken());

- name: Upload tarball
if: github.repository == 'stainless-sdks/browserbase-node'
if: |-
github.repository == 'stainless-sdks/browserbase-node' &&
!startsWith(github.ref, 'refs/heads/stl/')
env:
URL: https://pkg.stainless.com/s
AUTH: ${{ steps.github-oidc.outputs.github_token }}
Expand Down
2 changes: 1 addition & 1 deletion .release-please-manifest.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
".": "2.7.0"
".": "2.8.0-alpha.1"
}
8 changes: 4 additions & 4 deletions .stats.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
configured_endpoints: 19
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/browserbase%2Fbrowserbase-215bc4361122162181eecce83c0dbdda7c45a21801e7addb75102e8011413069.yml
openapi_spec_hash: c4fadc5bb6b84cd3988c8d864b67bf61
config_hash: a106b247c7cdf02ac1033077402cfe2d
configured_endpoints: 20
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/browserbase%2Fbrowserbase-b20f9fea14d79990ab1af3d276f931e026cd955ac623ec6ace80b2af90de170f.yml
openapi_spec_hash: 943ff4b3297014503fdc9854544cb9a4
config_hash: 55c54fdafc9e80be584829b5724b00ab
41 changes: 41 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,46 @@
# Changelog

## 2.8.0-alpha.1 (2026-03-11)

Full Changelog: [v2.7.0...v2.8.0-alpha.1](https://github.com/browserbase/sdk-node/compare/v2.7.0...v2.8.0-alpha.1)

### Features

* [CORE-1804][apps/api] Add fetch API schema ([969d581](https://github.com/browserbase/sdk-node/commit/969d58179bdbccc926871e9fdfec572a5aa73a97))
* **api:** api update ([#19](https://github.com/browserbase/sdk-node/issues/19)) ([8df9cc8](https://github.com/browserbase/sdk-node/commit/8df9cc8c76e4a615ba63d4568086bd60e88a0dfb))
* **api:** update via SDK Studio ([#10](https://github.com/browserbase/sdk-node/issues/10)) ([2c6c15d](https://github.com/browserbase/sdk-node/commit/2c6c15d148d1a5e74a48f92087580d8c590288af))
* **api:** update via SDK Studio ([#11](https://github.com/browserbase/sdk-node/issues/11)) ([9191ed6](https://github.com/browserbase/sdk-node/commit/9191ed631256b52a39de1aafcf1d7deb2788efdb))
* **api:** update via SDK Studio ([#12](https://github.com/browserbase/sdk-node/issues/12)) ([ebeaf82](https://github.com/browserbase/sdk-node/commit/ebeaf82736747398450d739e27d6874603c4f942))
* **api:** update via SDK Studio ([#13](https://github.com/browserbase/sdk-node/issues/13)) ([c0ffdce](https://github.com/browserbase/sdk-node/commit/c0ffdce615059b9523817d22ef18e01e778f3454))
* **api:** update via SDK Studio ([#16](https://github.com/browserbase/sdk-node/issues/16)) ([a96a86c](https://github.com/browserbase/sdk-node/commit/a96a86c2e7c5025cacd7edd89f88b914de3596e3))
* **api:** update via SDK Studio ([#17](https://github.com/browserbase/sdk-node/issues/17)) ([52cf741](https://github.com/browserbase/sdk-node/commit/52cf741bc4c5712f2fe15ee6eaa48e4c3643ec58))
* **api:** update via SDK Studio ([#3](https://github.com/browserbase/sdk-node/issues/3)) ([8a06f81](https://github.com/browserbase/sdk-node/commit/8a06f81c1cd5dc8a64b9fd10ed26f8547469fdeb))
* **api:** update via SDK Studio ([#4](https://github.com/browserbase/sdk-node/issues/4)) ([cf6309b](https://github.com/browserbase/sdk-node/commit/cf6309bb5de1376139fb0ba6b8e45b5d0801bee5))
* **api:** update via SDK Studio ([#5](https://github.com/browserbase/sdk-node/issues/5)) ([4275810](https://github.com/browserbase/sdk-node/commit/427581035437844d44333c0e3471db675dff89c7))
* **api:** update via SDK Studio ([#6](https://github.com/browserbase/sdk-node/issues/6)) ([299d77e](https://github.com/browserbase/sdk-node/commit/299d77ebc0994b0ab39a9c908157d42d605e9765))
* **api:** update via SDK Studio ([#7](https://github.com/browserbase/sdk-node/issues/7)) ([e1e4738](https://github.com/browserbase/sdk-node/commit/e1e47381dc142f94bd61e7f5819eafbf5b4797a7))
* **api:** update via SDK Studio ([#8](https://github.com/browserbase/sdk-node/issues/8)) ([2d845ff](https://github.com/browserbase/sdk-node/commit/2d845ffc683ea988980e42ea2c03699034af6980))
* **api:** update via SDK Studio ([#9](https://github.com/browserbase/sdk-node/issues/9)) ([a17fadc](https://github.com/browserbase/sdk-node/commit/a17fadcac323079f3e36e0c965f6d6c1be26f1d8))


### Bug Fixes

* **client:** preserve URL params already embedded in path ([81f76ab](https://github.com/browserbase/sdk-node/commit/81f76aba8e0ac48fe758e9c567ba9e3fb174cfc5))
* use npm publish instead of yarn publish ([#173](https://github.com/browserbase/sdk-node/issues/173)) ([05b3225](https://github.com/browserbase/sdk-node/commit/05b3225efe94473f2b49988dab63a9e67beb9802))


### Chores

* **ci:** skip uploading artifacts on stainless-internal branches ([0c1949d](https://github.com/browserbase/sdk-node/commit/0c1949d9237aa69c6ca9adda699376672f398f24))
* go live ([#1](https://github.com/browserbase/sdk-node/issues/1)) ([bc9e36e](https://github.com/browserbase/sdk-node/commit/bc9e36ec17be8df65bc4bd43bad6ad6617e4973c))
* **internal:** codegen related update ([d8b846c](https://github.com/browserbase/sdk-node/commit/d8b846cae415cec3a826e26b1a8cae47cca9e943))
* **internal:** move stringifyQuery implementation to internal function ([fb87469](https://github.com/browserbase/sdk-node/commit/fb8746921c5bad61c77f44b6e3fe8bf164c1e5b5))
* **release:** prepare alpha ([#36](https://github.com/browserbase/sdk-node/issues/36)) ([c5e0f61](https://github.com/browserbase/sdk-node/commit/c5e0f61f324c607421449db10cf861a0a5100b4a))
* **release:** v2.0.0 ([#39](https://github.com/browserbase/sdk-node/issues/39)) ([2ecb572](https://github.com/browserbase/sdk-node/commit/2ecb5720bc6102a3487ecd71f06fd3c548b5f760))
* **test:** do not count install time for mock server timeout ([1fd6556](https://github.com/browserbase/sdk-node/commit/1fd655639e75cf32f66d361c5c287960f6fc3982))
* update placeholder string ([fb97b1c](https://github.com/browserbase/sdk-node/commit/fb97b1c30905958b6a427a13e6922a4da30c2c15))
* update SDK settings ([#21](https://github.com/browserbase/sdk-node/issues/21)) ([dd2956f](https://github.com/browserbase/sdk-node/commit/dd2956f0b22aac232b6ae3cdd572a4d6b688099d))

## 2.7.0-alpha.3 (2026-02-26)

Full Changelog: [v2.7.0-alpha.2...v2.7.0-alpha.3](https://github.com/browserbase/sdk-node/compare/v2.7.0-alpha.2...v2.7.0-alpha.3)
Expand Down
10 changes: 10 additions & 0 deletions api.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,16 @@ Methods:
- <code title="get /v1/extensions/{id}">client.extensions.<a href="./src/resources/extensions.ts">retrieve</a>(id) -> Extension</code>
- <code title="delete /v1/extensions/{id}">client.extensions.<a href="./src/resources/extensions.ts">delete</a>(id) -> void</code>

# FetchAPI

Types:

- <code><a href="./src/resources/fetch-api.ts">FetchAPICreateResponse</a></code>

Methods:

- <code title="post /v1/fetch">client.fetchAPI.<a href="./src/resources/fetch-api.ts">create</a>({ ...params }) -> FetchAPICreateResponse</code>

# Projects

Types:
Expand Down
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@browserbasehq/sdk",
"version": "2.7.0",
"version": "2.8.0-alpha.1",
"description": "The official Node.js library for the Browserbase API",
"author": "Browserbase <support@browserbase.com>",
"types": "dist/index.d.ts",
Expand Down
13 changes: 12 additions & 1 deletion scripts/mock
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,22 @@ echo "==> Starting mock server with URL ${URL}"

# Run prism mock on the given spec
if [ "$1" == "--daemon" ]; then
# Pre-install the package so the download doesn't eat into the startup timeout
npm exec --package=@stainless-api/prism-cli@5.15.0 -- prism --version

npm exec --package=@stainless-api/prism-cli@5.15.0 -- prism mock "$URL" &> .prism.log &

# Wait for server to come online
# Wait for server to come online (max 30s)
echo -n "Waiting for server"
attempts=0
while ! grep -q "✖ fatal\|Prism is listening" ".prism.log" ; do
attempts=$((attempts + 1))
if [ "$attempts" -ge 300 ]; then
echo
echo "Timed out waiting for Prism server to start"
cat .prism.log
exit 1
fi
echo -n "."
sleep 0.1
done
Expand Down
31 changes: 10 additions & 21 deletions src/core.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import {
APIConnectionTimeoutError,
APIUserAbortError,
} from './error';
import { stringifyQuery } from './internal/utils/query';
import {
kind as shimsKind,
type Readable,
Expand Down Expand Up @@ -523,32 +524,20 @@ export abstract class APIClient {
: new URL(baseURL + (baseURL.endsWith('/') && path.startsWith('/') ? path.slice(1) : path));

const defaultQuery = this.defaultQuery();
if (!isEmptyObj(defaultQuery)) {
query = { ...defaultQuery, ...query } as Req;
const pathQuery = Object.fromEntries(url.searchParams);
if (!isEmptyObj(defaultQuery) || !isEmptyObj(pathQuery)) {
query = { ...pathQuery, ...defaultQuery, ...query } as Req;
}

if (typeof query === 'object' && query && !Array.isArray(query)) {
url.search = this.stringifyQuery(query as Record<string, unknown>);
url.search = this.stringifyQuery(query);
}

return url.toString();
}

protected stringifyQuery(query: Record<string, unknown>): string {
return Object.entries(query)
.filter(([_, value]) => typeof value !== 'undefined')
.map(([key, value]) => {
if (typeof value === 'string' || typeof value === 'number' || typeof value === 'boolean') {
return `${encodeURIComponent(key)}=${encodeURIComponent(value)}`;
}
if (value === null) {
return `${encodeURIComponent(key)}=`;
}
throw new BrowserbaseError(
`Cannot stringify type ${typeof value}; Expected string, number, boolean, or null. If you need to pass nested query parameters, you can manually encode them, e.g. { query: { 'foo[key1]': value1, 'foo[key2]': value2 } }, and please open a GitHub issue requesting better support for your use case.`,
);
})
.join('&');
protected stringifyQuery(query: object | Record<string, unknown>): string {
return stringifyQuery(query);
}

async fetchWithTimeout(
Expand Down Expand Up @@ -630,9 +619,9 @@ export abstract class APIClient {
}
}

// If the API asks us to wait a certain amount of time (and it's a reasonable amount),
// just do what it says, but otherwise calculate a default
if (!(timeoutMillis && 0 <= timeoutMillis && timeoutMillis < 60 * 1000)) {
// If the API asks us to wait a certain amount of time, do what it says.
// Otherwise calculate a default.
if (timeoutMillis === undefined) {
const maxRetries = options.maxRetries ?? this.maxRetries;
timeoutMillis = this.calculateDefaultRetryTimeoutMillis(retriesRemaining, maxRetries);
}
Expand Down
9 changes: 9 additions & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import {
Contexts,
} from './resources/contexts';
import { Extension, ExtensionCreateParams, Extensions } from './resources/extensions';
import { FetchAPI, FetchAPICreateParams, FetchAPICreateResponse } from './resources/fetch-api';
import { Project, ProjectListResponse, ProjectUsage, Projects } from './resources/projects';
import {
Session,
Expand Down Expand Up @@ -144,6 +145,7 @@ export class Browserbase extends Core.APIClient {

contexts: API.Contexts = new API.Contexts(this);
extensions: API.Extensions = new API.Extensions(this);
fetchAPI: API.FetchAPI = new API.FetchAPI(this);
projects: API.Projects = new API.Projects(this);
sessions: API.Sessions = new API.Sessions(this);

Expand Down Expand Up @@ -192,6 +194,7 @@ export class Browserbase extends Core.APIClient {

Browserbase.Contexts = Contexts;
Browserbase.Extensions = Extensions;
Browserbase.FetchAPI = FetchAPI;
Browserbase.Projects = Projects;
Browserbase.Sessions = Sessions;

Expand All @@ -212,6 +215,12 @@ export declare namespace Browserbase {
type ExtensionCreateParams as ExtensionCreateParams,
};

export {
FetchAPI as FetchAPI,
type FetchAPICreateResponse as FetchAPICreateResponse,
type FetchAPICreateParams as FetchAPICreateParams,
};

export {
Projects as Projects,
type Project as Project,
Expand Down
23 changes: 23 additions & 0 deletions src/internal/utils/query.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.

import { BrowserbaseError } from '../../error';

/**
* Basic re-implementation of `qs.stringify` for primitive types.
*/
export function stringifyQuery(query: object | Record<string, unknown>) {
return Object.entries(query)
.filter(([_, value]) => typeof value !== 'undefined')
.map(([key, value]) => {
if (typeof value === 'string' || typeof value === 'number' || typeof value === 'boolean') {
return `${encodeURIComponent(key)}=${encodeURIComponent(value)}`;
}
if (value === null) {
return `${encodeURIComponent(key)}=`;
}
throw new BrowserbaseError(
`Cannot stringify type ${typeof value}; Expected string, number, boolean, or null. If you need to pass nested query parameters, you can manually encode them, e.g. { query: { 'foo[key1]': value1, 'foo[key2]': value2 } }, and please open a GitHub issue requesting better support for your use case.`,
);
})
.join('&');
}
77 changes: 77 additions & 0 deletions src/resources/fetch-api.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.

import { APIResource } from '../resource';
import * as Core from '../core';

export class FetchAPI extends APIResource {
/**
* Fetch a page and return its content, headers, and metadata.
*/
create(body: FetchAPICreateParams, options?: Core.RequestOptions): Core.APIPromise<FetchAPICreateResponse> {
return this._client.post('/v1/fetch', { body, ...options });
}
}

/**
* Response body for fetch
*/
export interface FetchAPICreateResponse {
/**
* Unique identifier for the fetch request
*/
id: string;

/**
* The response body content
*/
content: string;

/**
* The MIME type of the response
*/
contentType: string;

/**
* The character encoding of the response
*/
encoding: string;

/**
* Response headers as key-value pairs
*/
headers: { [key: string]: string };

/**
* HTTP status code of the fetched response
*/
statusCode: number;
}

export interface FetchAPICreateParams {
/**
* The URL to fetch
*/
url: string;

/**
* Whether to bypass TLS certificate verification
*/
allowInsecureSsl?: boolean;

/**
* Whether to follow HTTP redirects
*/
allowRedirects?: boolean;

/**
* Whether to enable proxy support for the request
*/
proxies?: boolean;
}

export declare namespace FetchAPI {
export {
type FetchAPICreateResponse as FetchAPICreateResponse,
type FetchAPICreateParams as FetchAPICreateParams,
};
}
1 change: 1 addition & 0 deletions src/resources/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ export {
type ContextCreateParams,
} from './contexts';
export { Extensions, type Extension, type ExtensionCreateParams } from './extensions';
export { FetchAPI, type FetchAPICreateResponse, type FetchAPICreateParams } from './fetch-api';
export { Projects, type Project, type ProjectUsage, type ProjectListResponse } from './projects';
export {
Sessions,
Expand Down
2 changes: 1 addition & 1 deletion src/version.ts
Original file line number Diff line number Diff line change
@@ -1 +1 @@
export const VERSION = '2.7.0'; // x-release-please-version
export const VERSION = '2.8.0-alpha.1'; // x-release-please-version
4 changes: 2 additions & 2 deletions tests/api-resources/extensions.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ const client = new Browserbase({
describe('resource extensions', () => {
test('create: only required params', async () => {
const responsePromise = client.extensions.create({
file: await toFile(Buffer.from('# my file contents'), 'README.md'),
file: await toFile(Buffer.from('Example data'), 'README.md'),
});
const rawResponse = await responsePromise.asResponse();
expect(rawResponse).toBeInstanceOf(Response);
Expand All @@ -24,7 +24,7 @@ describe('resource extensions', () => {

test('create: required and optional params', async () => {
const response = await client.extensions.create({
file: await toFile(Buffer.from('# my file contents'), 'README.md'),
file: await toFile(Buffer.from('Example data'), 'README.md'),
});
});

Expand Down
Loading
Loading