{"id":28491969,"url":"https://github.com/browserbase/sdk-node","last_synced_at":"2026-04-06T21:01:20.273Z","repository":{"id":260541710,"uuid":"878195675","full_name":"browserbase/sdk-node","owner":"browserbase","description":"Node.js SDK for Browserbase","archived":false,"fork":false,"pushed_at":"2026-04-01T02:26:55.000Z","size":926,"stargazers_count":61,"open_issues_count":7,"forks_count":14,"subscribers_count":7,"default_branch":"main","last_synced_at":"2026-04-01T04:56:32.234Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"https://docs.browserbase.com","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/browserbase.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":"SECURITY.md","support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2024-10-25T00:01:16.000Z","updated_at":"2026-03-30T02:28:02.000Z","dependencies_parsed_at":"2026-02-26T05:00:07.755Z","dependency_job_id":null,"html_url":"https://github.com/browserbase/sdk-node","commit_stats":null,"previous_names":["browserbase/sdk-node"],"tags_count":19,"template":false,"template_full_name":null,"purl":"pkg:github/browserbase/sdk-node","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/browserbase%2Fsdk-node","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/browserbase%2Fsdk-node/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/browserbase%2Fsdk-node/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/browserbase%2Fsdk-node/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/browserbase","download_url":"https://codeload.github.com/browserbase/sdk-node/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/browserbase%2Fsdk-node/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":31489427,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-06T17:22:55.647Z","status":"ssl_error","status_checked_at":"2026-04-06T17:22:54.741Z","response_time":112,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2025-06-08T08:09:11.537Z","updated_at":"2026-04-06T21:01:20.267Z","avatar_url":"https://github.com/browserbase.png","language":"TypeScript","readme":"# Browserbase Node API Library\n\n[![NPM version](https://img.shields.io/npm/v/@browserbasehq/sdk.svg)](https://npmjs.org/package/@browserbasehq/sdk) ![npm bundle size](https://img.shields.io/bundlephobia/minzip/@browserbasehq/sdk)\n\nThis library provides convenient access to the Browserbase REST API from server-side TypeScript or JavaScript.\n\nThe 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).\n\nIt is generated with [Stainless](https://www.stainless.com/).\n\n## Installation\n\n```sh\nnpm install @browserbasehq/sdk\n```\n\n## Usage\n\nThe full API of this library can be found in [api.md](api.md).\n\n\u003c!-- prettier-ignore --\u003e\n```js\nimport Browserbase from '@browserbasehq/sdk';\n\nconst client = new Browserbase({\n  apiKey: process.env['BROWSERBASE_API_KEY'], // This is the default and can be omitted\n});\n\nconst session = await client.sessions.create({ projectId: 'your_project_id' });\n```\n\n### Request \u0026 Response types\n\nThis library includes TypeScript definitions for all request params and response fields. You may import and use them like so:\n\n\u003c!-- prettier-ignore --\u003e\n```ts\nimport Browserbase from '@browserbasehq/sdk';\n\nconst client = new Browserbase({\n  apiKey: process.env['BROWSERBASE_API_KEY'], // This is the default and can be omitted\n});\n\nconst params: Browserbase.SessionCreateParams = { projectId: 'your_project_id' };\nconst session: Browserbase.SessionCreateResponse = await client.sessions.create(params);\n```\n\nDocumentation for each method, request param, and response field are available in docstrings and will appear on hover in most modern editors.\n\n## File uploads\n\nRequest parameters that correspond to file uploads can be passed in many different forms:\n\n- `File` (or an object with the same structure)\n- a `fetch` `Response` (or an object with the same structure)\n- an `fs.ReadStream`\n- the return value of our `toFile` helper\n\n```ts\nimport fs from 'fs';\nimport fetch from 'node-fetch';\nimport Browserbase, { toFile } from '@browserbasehq/sdk';\n\nconst client = new Browserbase();\n\n// If you have access to Node `fs` we recommend using `fs.createReadStream()`:\nawait client.extensions.create({ file: fs.createReadStream('/path/to/file') });\n\n// Or if you have the web `File` API you can pass a `File` instance:\nawait client.extensions.create({ file: new File(['my bytes'], 'file') });\n\n// You can also pass a `fetch` `Response`:\nawait client.extensions.create({ file: await fetch('https://somesite/file') });\n\n// Finally, if none of the above are convenient, you can use our `toFile` helper:\nawait client.extensions.create({ file: await toFile(Buffer.from('my bytes'), 'file') });\nawait client.extensions.create({ file: await toFile(new Uint8Array([0, 1, 2]), 'file') });\n```\n\n## Handling errors\n\nWhen the library is unable to connect to the API,\nor if the API returns a non-success status code (i.e., 4xx or 5xx response),\na subclass of `APIError` will be thrown:\n\n\u003c!-- prettier-ignore --\u003e\n```ts\nconst session = await client.sessions\n  .create({ projectId: 'your_project_id' })\n  .catch(async (err) =\u003e {\n    if (err instanceof Browserbase.APIError) {\n      console.log(err.status); // 400\n      console.log(err.name); // BadRequestError\n      console.log(err.headers); // {server: 'nginx', ...}\n    } else {\n      throw err;\n    }\n  });\n```\n\nError codes are as follows:\n\n| Status Code | Error Type                 |\n| ----------- | -------------------------- |\n| 400         | `BadRequestError`          |\n| 401         | `AuthenticationError`      |\n| 403         | `PermissionDeniedError`    |\n| 404         | `NotFoundError`            |\n| 422         | `UnprocessableEntityError` |\n| 429         | `RateLimitError`           |\n| \u003e=500       | `InternalServerError`      |\n| N/A         | `APIConnectionError`       |\n\n### Retries\n\nCertain errors will be automatically retried 2 times by default, with a short exponential backoff.\nConnection errors (for example, due to a network connectivity problem), 408 Request Timeout, 409 Conflict,\n429 Rate Limit, and \u003e=500 Internal errors will all be retried by default.\n\nYou can use the `maxRetries` option to configure or disable this:\n\n\u003c!-- prettier-ignore --\u003e\n```js\n// Configure the default for all requests:\nconst client = new Browserbase({\n  maxRetries: 0, // default is 2\n});\n\n// Or, configure per-request:\nawait client.sessions.create({ projectId: 'your_project_id' }, {\n  maxRetries: 5,\n});\n```\n\n### Timeouts\n\nRequests time out after 1 minute by default. You can configure this with a `timeout` option:\n\n\u003c!-- prettier-ignore --\u003e\n```ts\n// Configure the default for all requests:\nconst client = new Browserbase({\n  timeout: 20 * 1000, // 20 seconds (default is 1 minute)\n});\n\n// Override per-request:\nawait client.sessions.create({ projectId: 'your_project_id' }, {\n  timeout: 5 * 1000,\n});\n```\n\nOn timeout, an `APIConnectionTimeoutError` is thrown.\n\nNote that requests which time out will be [retried twice by default](#retries).\n\n## Advanced Usage\n\n### Accessing raw Response data (e.g., headers)\n\nThe \"raw\" `Response` returned by `fetch()` can be accessed through the `.asResponse()` method on the `APIPromise` type that all methods return.\n\nYou can also use the `.withResponse()` method to get the raw `Response` along with the parsed data.\n\n\u003c!-- prettier-ignore --\u003e\n```ts\nconst client = new Browserbase();\n\nconst response = await client.sessions.create({ projectId: 'your_project_id' }).asResponse();\nconsole.log(response.headers.get('X-My-Header'));\nconsole.log(response.statusText); // access the underlying Response object\n\nconst { data: session, response: raw } = await client.sessions\n  .create({ projectId: 'your_project_id' })\n  .withResponse();\nconsole.log(raw.headers.get('X-My-Header'));\nconsole.log(session);\n```\n\n### Making custom/undocumented requests\n\nThis library is typed for convenient access to the documented API. If you need to access undocumented\nendpoints, params, or response properties, the library can still be used.\n\n#### Undocumented endpoints\n\nTo make requests to undocumented endpoints, you can use `client.get`, `client.post`, and other HTTP verbs.\nOptions on the client, such as retries, will be respected when making these requests.\n\n```ts\nawait client.post('/some/path', {\n  body: { some_prop: 'foo' },\n  query: { some_query_arg: 'bar' },\n});\n```\n\n#### Undocumented request params\n\nTo make requests using undocumented parameters, you may use `// @ts-expect-error` on the undocumented\nparameter. This library doesn't validate at runtime that the request matches the type, so any extra values you\nsend will be sent as-is.\n\n```ts\nclient.foo.create({\n  foo: 'my_param',\n  bar: 12,\n  // @ts-expect-error baz is not yet public\n  baz: 'undocumented option',\n});\n```\n\nFor requests with the `GET` verb, any extra params will be in the query, all other requests will send the\nextra param in the body.\n\nIf you want to explicitly send an extra argument, you can do so with the `query`, `body`, and `headers` request\noptions.\n\n#### Undocumented response properties\n\nTo access undocumented response properties, you may access the response object with `// @ts-expect-error` on\nthe response object, or cast the response object to the requisite type. Like the request params, we do not\nvalidate or strip extra properties from the response from the API.\n\n### Customizing the fetch client\n\nBy default, this library uses `node-fetch` in Node, and expects a global `fetch` function in other environments.\n\nIf you would prefer to use a global, web-standards-compliant `fetch` function even in a Node environment,\n(for example, if you are running Node with `--experimental-fetch` or using NextJS which polyfills with `undici`),\nadd the following import before your first import `from \"Browserbase\"`:\n\n```ts\n// Tell TypeScript and the package to use the global web fetch instead of node-fetch.\n// Note, despite the name, this does not add any polyfills, but expects them to be provided if needed.\nimport '@browserbasehq/sdk/shims/web';\nimport Browserbase from '@browserbasehq/sdk';\n```\n\nTo do the inverse, add `import \"@browserbasehq/sdk/shims/node\"` (which does import polyfills).\nThis can also be useful if you are getting the wrong TypeScript types for `Response` ([more details](https://github.com/browserbase/sdk-node/tree/main/src/_shims#readme)).\n\n### Logging and middleware\n\nYou may also provide a custom `fetch` function when instantiating the client,\nwhich can be used to inspect or alter the `Request` or `Response` before/after each request:\n\n```ts\nimport { fetch } from 'undici'; // as one example\nimport Browserbase from '@browserbasehq/sdk';\n\nconst client = new Browserbase({\n  fetch: async (url: RequestInfo, init?: RequestInit): Promise\u003cResponse\u003e =\u003e {\n    console.log('About to make a request', url, init);\n    const response = await fetch(url, init);\n    console.log('Got response', response);\n    return response;\n  },\n});\n```\n\nNote that if given a `DEBUG=true` environment variable, this library will log all requests and responses automatically.\nThis is intended for debugging purposes only and may change in the future without notice.\n\n### Configuring an HTTP(S) Agent (e.g., for proxies)\n\nBy default, this library uses a stable agent for all http/https requests to reuse TCP connections, eliminating many TCP \u0026 TLS handshakes and shaving around 100ms off most requests.\n\nIf you would like to disable or customize this behavior, for example to use the API behind a proxy, you can pass an `httpAgent` which is used for all requests (be they http or https), for example:\n\n\u003c!-- prettier-ignore --\u003e\n```ts\nimport http from 'http';\nimport { HttpsProxyAgent } from 'https-proxy-agent';\n\n// Configure the default for all requests:\nconst client = new Browserbase({\n  httpAgent: new HttpsProxyAgent(process.env.PROXY_URL),\n});\n\n// Override per-request:\nawait client.sessions.create(\n  { projectId: 'your_project_id' },\n  {\n    httpAgent: new http.Agent({ keepAlive: false }),\n  },\n);\n```\n\n## Semantic versioning\n\nThis package generally follows [SemVer](https://semver.org/spec/v2.0.0.html) conventions, though certain backwards-incompatible changes may be released as minor versions:\n\n1. Changes that only affect static types, without breaking runtime behavior.\n2. Changes to library internals which are technically public but not intended or documented for external use. _(Please open a GitHub issue to let us know if you are relying on such internals.)_\n3. Changes that we do not expect to impact the vast majority of users in practice.\n\nWe take backwards-compatibility seriously and work hard to ensure you can rely on a smooth upgrade experience.\n\nWe are keen for your feedback; please open an [issue](https://www.github.com/browserbase/sdk-node/issues) with questions, bugs, or suggestions.\n\n## Requirements\n\nTypeScript \u003e= 4.5 is supported.\n\nThe following runtimes are supported:\n\n- Web browsers (Up-to-date Chrome, Firefox, Safari, Edge, and more)\n- Node.js 18 LTS or later ([non-EOL](https://endoflife.date/nodejs)) versions.\n- Deno v1.28.0 or higher.\n- Bun 1.0 or later.\n- Cloudflare Workers.\n- Vercel Edge Runtime.\n- Jest 28 or greater with the `\"node\"` environment (`\"jsdom\"` is not supported at this time).\n- Nitro v2.6 or greater.\n\nNote that React Native is not supported at this time.\n\nIf you are interested in other runtime environments, please open or upvote an issue on GitHub.\n\n## Contributing\n\nSee [the contributing documentation](./CONTRIBUTING.md).\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbrowserbase%2Fsdk-node","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbrowserbase%2Fsdk-node","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbrowserbase%2Fsdk-node/lists"}