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
23 changes: 0 additions & 23 deletions .devcontainer/Dockerfile

This file was deleted.

27 changes: 12 additions & 15 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -1,20 +1,17 @@
// For format details, see https://aka.ms/devcontainer.json. For config options, see the
// README at: https://github.com/devcontainers/templates/tree/main/src/debian
{
"name": "Debian",
"build": {
"dockerfile": "Dockerfile"
"name": "Development",
"image": "mcr.microsoft.com/devcontainers/typescript-node:latest",
"features": {
"ghcr.io/devcontainers/features/node:1": {}
},
"postCreateCommand": "yarn install",
"customizations": {
"vscode": {
"extensions": [
"esbenp.prettier-vscode"
]
}
}

// Features to add to the dev container. More info: https://containers.dev/features.
// "features": {},

// Use 'forwardPorts' to make a list of ports inside the container available locally.
// "forwardPorts": [],

// Configure tool-specific properties.
// "customizations": {},

// Uncomment to connect as root instead. More info: https://aka.ms/dev-containers-non-root.
// "remoteUser": "root"
}
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.3.0"
".": "2.4.0"
}
2 changes: 1 addition & 1 deletion .stats.yml
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
configured_endpoints: 18
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/browserbase%2Fbrowserbase-396a2b9092f645c5a9e46a1f3be8c2e45ca9ae079e1d39761eb0a73f56e24b15.yml
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/browserbase%2Fbrowserbase-06206dff3ffaf539b0ed8aa5bac368cb366b631f85d7a4ba5f07aca91c172550.yml
29 changes: 29 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,34 @@
# Changelog

## 2.4.0 (2025-03-14)

Full Changelog: [v2.3.0...v2.4.0](https://github.com/browserbase/sdk-node/compare/v2.3.0...v2.4.0)

### Features

* **api:** api update ([#142](https://github.com/browserbase/sdk-node/issues/142)) ([b2391f8](https://github.com/browserbase/sdk-node/commit/b2391f8eb6b6a35d033de3b54a8731a59601c177))
* **api:** api update ([#144](https://github.com/browserbase/sdk-node/issues/144)) ([c7aaea1](https://github.com/browserbase/sdk-node/commit/c7aaea13fae457c258a8ee97b7b1717866f15b2d))


### Bug Fixes

* **client:** fix export map for index exports ([#137](https://github.com/browserbase/sdk-node/issues/137)) ([7e3ba08](https://github.com/browserbase/sdk-node/commit/7e3ba0874d40256119ab5f9f556bff5a43425188))
* **exports:** ensure resource imports don't require /index ([#146](https://github.com/browserbase/sdk-node/issues/146)) ([c6ec9a5](https://github.com/browserbase/sdk-node/commit/c6ec9a5a8a87c6e1d811945c89bc674188198bf7))


### Chores

* **internal:** codegen related update ([#138](https://github.com/browserbase/sdk-node/issues/138)) ([316a6af](https://github.com/browserbase/sdk-node/commit/316a6af67a7c7daa6d78956e7dab1fd88f4bf90c))
* **internal:** codegen related update ([#143](https://github.com/browserbase/sdk-node/issues/143)) ([d8d3fb9](https://github.com/browserbase/sdk-node/commit/d8d3fb9f1d3ee6497cd781fee475e475416237cf))
* **internal:** fix devcontainers setup ([#139](https://github.com/browserbase/sdk-node/issues/139)) ([40202bd](https://github.com/browserbase/sdk-node/commit/40202bdf590f7df08d872c70a362ac7c3c1393a2))
* **internal:** version bump ([#129](https://github.com/browserbase/sdk-node/issues/129)) ([82c57f9](https://github.com/browserbase/sdk-node/commit/82c57f9b9c51dd5e29c4ccdb1855a8883b28ab08))
* **internal:** version bump ([#135](https://github.com/browserbase/sdk-node/issues/135)) ([90a4906](https://github.com/browserbase/sdk-node/commit/90a4906a5fbddf73b49cd45293619a9deadcb3e0))


### Documentation

* update URLs from stainlessapi.com to stainless.com ([#140](https://github.com/browserbase/sdk-node/issues/140)) ([0e240d7](https://github.com/browserbase/sdk-node/commit/0e240d7076fba9e8220d0fadb177426fe7bf3972))

## 2.3.0 (2025-02-05)

Full Changelog: [v2.2.0...v2.3.0](https://github.com/browserbase/sdk-node/compare/v2.2.0...v2.3.0)
Expand Down
32 changes: 31 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ This library provides convenient access to the Browserbase REST API from server-

The REST API documentation can be found on [docs.browserbase.com](https://docs.browserbase.com). The full API of this library can be found in [api.md](api.md).

It is generated with [Stainless](https://www.stainlessapi.com/).
It is generated with [Stainless](https://www.stainless.com/).

## Installation

Expand Down Expand Up @@ -57,6 +57,36 @@ main();

Documentation for each method, request param, and response field are available in docstrings and will appear on hover in most modern editors.

## File uploads

Request parameters that correspond to file uploads can be passed in many different forms:

- `File` (or an object with the same structure)
- a `fetch` `Response` (or an object with the same structure)
- an `fs.ReadStream`
- the return value of our `toFile` helper

```ts
import fs from 'fs';
import fetch from 'node-fetch';
import Browserbase, { toFile } from '@browserbasehq/sdk';

const client = new Browserbase();

// If you have access to Node `fs` we recommend using `fs.createReadStream()`:
await client.extensions.create({ file: fs.createReadStream('/path/to/file') });

// Or if you have the web `File` API you can pass a `File` instance:
await client.extensions.create({ file: new File(['my bytes'], 'file') });

// You can also pass a `fetch` `Response`:
await client.extensions.create({ file: await fetch('https://somesite/file') });

// Finally, if none of the above are convenient, you can use our `toFile` helper:
await client.extensions.create({ file: await toFile(Buffer.from('my bytes'), 'file') });
await client.extensions.create({ file: await toFile(new Uint8Array([0, 1, 2]), 'file') });
```

## Handling errors

When the library is unable to connect to the API,
Expand Down
4 changes: 2 additions & 2 deletions SECURITY.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@

## Reporting Security Issues

This SDK is generated by [Stainless Software Inc](http://stainlessapi.com). Stainless takes security seriously, and encourages you to report any security vulnerability promptly so that appropriate action can be taken.
This SDK is generated by [Stainless Software Inc](http://stainless.com). Stainless takes security seriously, and encourages you to report any security vulnerability promptly so that appropriate action can be taken.

To report a security issue, please contact the Stainless team at security@stainlessapi.com.
To report a security issue, please contact the Stainless team at security@stainless.com.

## Responsible Disclosure

Expand Down
3 changes: 2 additions & 1 deletion api.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,12 +45,13 @@ Types:
- <code><a href="./src/resources/sessions/sessions.ts">Session</a></code>
- <code><a href="./src/resources/sessions/sessions.ts">SessionLiveURLs</a></code>
- <code><a href="./src/resources/sessions/sessions.ts">SessionCreateResponse</a></code>
- <code><a href="./src/resources/sessions/sessions.ts">SessionRetrieveResponse</a></code>
- <code><a href="./src/resources/sessions/sessions.ts">SessionListResponse</a></code>

Methods:

- <code title="post /v1/sessions">client.sessions.<a href="./src/resources/sessions/sessions.ts">create</a>({ ...params }) -> SessionCreateResponse</code>
- <code title="get /v1/sessions/{id}">client.sessions.<a href="./src/resources/sessions/sessions.ts">retrieve</a>(id) -> Session</code>
- <code title="get /v1/sessions/{id}">client.sessions.<a href="./src/resources/sessions/sessions.ts">retrieve</a>(id) -> SessionRetrieveResponse</code>
- <code title="post /v1/sessions/{id}">client.sessions.<a href="./src/resources/sessions/sessions.ts">update</a>(id, { ...params }) -> Session</code>
- <code title="get /v1/sessions">client.sessions.<a href="./src/resources/sessions/sessions.ts">list</a>({ ...params }) -> SessionListResponse</code>
- <code title="get /v1/sessions/{id}/debug">client.sessions.<a href="./src/resources/sessions/sessions.ts">debug</a>(id) -> SessionLiveURLs</code>
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.

16 changes: 8 additions & 8 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@browserbasehq/sdk",
"version": "2.3.0",
"version": "2.4.0",
"description": "The official Node.js library for the Browserbase API",
"author": "Browserbase <[email protected]>",
"types": "dist/index.d.ts",
Expand Down Expand Up @@ -113,17 +113,17 @@
"default": "./dist/index.mjs"
},
"./*.mjs": {
"types": "./dist/*.d.ts",
"default": "./dist/*.mjs"
"types": ["./dist/*.d.ts", "./dist/*/index.d.ts"],
"default": ["./dist/*.mjs", "./dist/*/index.mjs"]
},
"./*.js": {
"types": "./dist/*.d.ts",
"default": "./dist/*.js"
"types": ["./dist/*.d.ts", "./dist/*/index.d.ts"],
"default": ["./dist/*.js", "./dist/*/index.js"]
},
"./*": {
"types": "./dist/*.d.ts",
"require": "./dist/*.js",
"default": "./dist/*.mjs"
"types": ["./dist/*.d.ts", "./dist/*/index.d.ts"],
"require": ["./dist/*.js", "./dist/*/index.js"],
"default": ["./dist/*.mjs", "./dist/*/index.mjs"]
}
}
}
2 changes: 1 addition & 1 deletion scripts/bootstrap
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ set -e

cd "$(dirname "$0")/.."

if [ -f "Brewfile" ] && [ "$(uname -s)" = "Darwin" ]; then
if [ -f "Brewfile" ] && [ "$(uname -s)" = "Darwin" ] && [ "$SKIP_BREW" != "1" ]; then
brew bundle check >/dev/null 2>&1 || {
echo "==> Installing Homebrew dependencies…"
brew bundle
Expand Down
4 changes: 2 additions & 2 deletions src/core.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,8 @@ async function defaultParseResponse<T>(props: APIResponseProps): Promise<T> {
}

const contentType = response.headers.get('content-type');
const isJSON =
contentType?.includes('application/json') || contentType?.includes('application/vnd.api+json');
const mediaType = contentType?.split(';')[0]?.trim();
const isJSON = mediaType?.includes('application/json') || mediaType?.endsWith('+json');
if (isJSON) {
const json = await response.json();

Expand Down
2 changes: 2 additions & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import {
SessionListParams,
SessionListResponse,
SessionLiveURLs,
SessionRetrieveResponse,
SessionUpdateParams,
Sessions,
} from './resources/sessions/sessions';
Expand Down Expand Up @@ -212,6 +213,7 @@ export declare namespace Browserbase {
type Session as Session,
type SessionLiveURLs as SessionLiveURLs,
type SessionCreateResponse as SessionCreateResponse,
type SessionRetrieveResponse as SessionRetrieveResponse,
type SessionListResponse as SessionListResponse,
type SessionCreateParams as SessionCreateParams,
type SessionUpdateParams as SessionUpdateParams,
Expand Down
1 change: 1 addition & 0 deletions src/resources/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ export {
type Session,
type SessionLiveURLs,
type SessionCreateResponse,
type SessionRetrieveResponse,
type SessionListResponse,
type SessionCreateParams,
type SessionUpdateParams,
Expand Down
3 changes: 3 additions & 0 deletions src/resources/sessions.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.

export * from './sessions/index';
1 change: 1 addition & 0 deletions src/resources/sessions/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ export {
type Session,
type SessionLiveURLs,
type SessionCreateResponse,
type SessionRetrieveResponse,
type SessionListResponse,
type SessionCreateParams,
type SessionUpdateParams,
Expand Down
77 changes: 75 additions & 2 deletions src/resources/sessions/sessions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ export class Sessions extends APIResource {
/**
* Session
*/
retrieve(id: string, options?: Core.RequestOptions): Core.APIPromise<Session> {
retrieve(id: string, options?: Core.RequestOptions): Core.APIPromise<SessionRetrieveResponse> {
return this._client.get(`/v1/sessions/${id}`, options);
}

Expand Down Expand Up @@ -217,6 +217,78 @@ export interface SessionCreateResponse {
userMetadata?: Record<string, unknown>;
}

export interface SessionRetrieveResponse {
id: string;

createdAt: string;

expiresAt: string;

/**
* Indicates if the Session was created to be kept alive upon disconnections
*/
keepAlive: boolean;

/**
* The Project ID linked to the Session.
*/
projectId: string;

/**
* Bytes used via the [Proxy](/features/stealth-mode#proxies-and-residential-ips)
*/
proxyBytes: number;

/**
* The region where the Session is running.
*/
region: 'us-west-2' | 'us-east-1' | 'eu-central-1' | 'ap-southeast-1';

startedAt: string;

status: 'RUNNING' | 'ERROR' | 'TIMED_OUT' | 'COMPLETED';

updatedAt: string;

/**
* CPU used by the Session
*/
avgCpuUsage?: number;

/**
* WebSocket URL to connect to the Session.
*/
connectUrl?: string;

/**
* Optional. The Context linked to the Session.
*/
contextId?: string;

endedAt?: string;

/**
* Memory used by the Session
*/
memoryUsage?: number;

/**
* HTTP URL to connect to the Session.
*/
seleniumRemoteUrl?: string;

/**
* Signing key to use when connecting to the Session via HTTP.
*/
signingKey?: string;

/**
* Arbitrary user metadata to attach to the session. To learn more about user
* metadata, see [User Metadata](/features/sessions#user-metadata).
*/
userMetadata?: Record<string, unknown>;
}

export type SessionListResponse = Array<Session>;

export interface SessionCreateParams {
Expand Down Expand Up @@ -332,7 +404,7 @@ export namespace SessionCreateParams {

devices?: Array<'desktop' | 'mobile'>;

httpVersion?: 1 | 2;
httpVersion?: '1' | '2';

/**
* Full list of locales is available
Expand Down Expand Up @@ -473,6 +545,7 @@ export declare namespace Sessions {
type Session as Session,
type SessionLiveURLs as SessionLiveURLs,
type SessionCreateResponse as SessionCreateResponse,
type SessionRetrieveResponse as SessionRetrieveResponse,
type SessionListResponse as SessionListResponse,
type SessionCreateParams as SessionCreateParams,
type SessionUpdateParams as SessionUpdateParams,
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.3.0'; // x-release-please-version
export const VERSION = '2.4.0'; // x-release-please-version
2 changes: 1 addition & 1 deletion tests/api-resources/sessions/sessions.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ describe('resource sessions', () => {
fingerprint: {
browsers: ['chrome'],
devices: ['desktop'],
httpVersion: 1,
httpVersion: '1',
locales: ['string'],
operatingSystems: ['android'],
screen: { maxHeight: 0, maxWidth: 0, minHeight: 0, minWidth: 0 },
Expand Down