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
2 changes: 1 addition & 1 deletion .release-please-manifest.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
".": "0.1.1"
".": "0.2.0"
}
8 changes: 4 additions & 4 deletions .stats.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
configured_endpoints: 22
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/browser-use%2Fbrowser-use-86040fd18419e7b4e0947660d9c0ff1abe21550528d2d2a549736cd16f85a92d.yml
openapi_spec_hash: 7c5de9d0f633db35fd9e250fcc834d1f
config_hash: 99e0e445bc20c5723030c315bab52940
configured_endpoints: 26
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/browser-use%2Fbrowser-use-9ff5409663c58ae9e3ecc9ac764956189e3a70600f5ba1b961bb1dedf0208271.yml
openapi_spec_hash: 9865acb75430d9b799502acbae860df0
config_hash: 9d52be5177b2ede4cb0633c04f4cc4ef
9 changes: 9 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,14 @@
# Changelog

## 0.2.0 (2025-08-15)

Full Changelog: [v0.1.1...v0.2.0](https://github.com/browser-use/browser-use-node/compare/v0.1.1...v0.2.0)

### Features

* **api:** api update ([3df1a94](https://github.com/browser-use/browser-use-node/commit/3df1a94275d67ce41756227e6f0b749b2c3ed009))
* **api:** manual updates ([7183cef](https://github.com/browser-use/browser-use-node/commit/7183cef2c497b83985d368cb3a559fc0e11e4082))

## 0.1.1 (2025-08-14)

Full Changelog: [v0.1.0...v0.1.1](https://github.com/browser-use/browser-use-node/compare/v0.1.0...v0.1.1)
Expand Down
20 changes: 10 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,9 @@ const client = new BrowserUse({
apiKey: process.env['BROWSER_USE_API_KEY'], // This is the default and can be omitted
});

const tasks = await client.tasks.list();
const me = await client.users.me.retrieve();

console.log(tasks.items);
console.log(me.additionalCreditsBalanceUsd);
```

### Request & Response types
Expand All @@ -43,7 +43,7 @@ const client = new BrowserUse({
apiKey: process.env['BROWSER_USE_API_KEY'], // This is the default and can be omitted
});

const tasks: BrowserUse.TaskListResponse = await client.tasks.list();
const me: BrowserUse.Users.MeRetrieveResponse = await client.users.me.retrieve();
```

Documentation for each method, request param, and response field are available in docstrings and will appear on hover in most modern editors.
Expand All @@ -56,7 +56,7 @@ a subclass of `APIError` will be thrown:

<!-- prettier-ignore -->
```ts
const tasks = await client.tasks.list().catch(async (err) => {
const me = await client.users.me.retrieve().catch(async (err) => {
if (err instanceof BrowserUse.APIError) {
console.log(err.status); // 400
console.log(err.name); // BadRequestError
Expand Down Expand Up @@ -96,7 +96,7 @@ const client = new BrowserUse({
});

// Or, configure per-request:
await client.tasks.list({
await client.users.me.retrieve({
maxRetries: 5,
});
```
Expand All @@ -113,7 +113,7 @@ const client = new BrowserUse({
});

// Override per-request:
await client.tasks.list({
await client.users.me.retrieve({
timeout: 5 * 1000,
});
```
Expand All @@ -136,13 +136,13 @@ Unlike `.asResponse()` this method consumes the body, returning once it is parse
```ts
const client = new BrowserUse();

const response = await client.tasks.list().asResponse();
const response = await client.users.me.retrieve().asResponse();
console.log(response.headers.get('X-My-Header'));
console.log(response.statusText); // access the underlying Response object

const { data: tasks, response: raw } = await client.tasks.list().withResponse();
const { data: me, response: raw } = await client.users.me.retrieve().withResponse();
console.log(raw.headers.get('X-My-Header'));
console.log(tasks.items);
console.log(me.additionalCreditsBalanceUsd);
```

### Logging
Expand Down Expand Up @@ -222,7 +222,7 @@ parameter. This library doesn't validate at runtime that the request matches the
send will be sent as-is.

```ts
client.tasks.list({
client.users.me.retrieve({
// ...
// @ts-expect-error baz is not yet public
baz: 'undocumented option',
Expand Down
48 changes: 36 additions & 12 deletions api.md
Original file line number Diff line number Diff line change
@@ -1,23 +1,49 @@
# Users

## Me

Types:

- <code><a href="./src/resources/users/me/me.ts">MeRetrieveResponse</a></code>

Methods:

- <code title="get /users/me">client.users.me.<a href="./src/resources/users/me/me.ts">retrieve</a>() -> MeRetrieveResponse</code>

### Files

Types:

- <code><a href="./src/resources/users/me/files.ts">FileCreatePresignedURLResponse</a></code>

Methods:

- <code title="post /users/me/files/presigned-url">client.users.me.files.<a href="./src/resources/users/me/files.ts">createPresignedURL</a>({ ...params }) -> FileCreatePresignedURLResponse</code>

# Tasks

Types:

- <code><a href="./src/resources/tasks.ts">FileView</a></code>
- <code><a href="./src/resources/tasks.ts">LlmModel</a></code>
- <code><a href="./src/resources/tasks.ts">TaskItemView</a></code>
- <code><a href="./src/resources/tasks.ts">TaskStatus</a></code>
- <code><a href="./src/resources/tasks.ts">TaskStepView</a></code>
- <code><a href="./src/resources/tasks.ts">TaskView</a></code>
- <code><a href="./src/resources/tasks.ts">TaskRetrieveResponse</a></code>
- <code><a href="./src/resources/tasks.ts">TaskListResponse</a></code>
- <code><a href="./src/resources/tasks.ts">TaskRetrieveLogsResponse</a></code>
- <code><a href="./src/resources/tasks.ts">TaskRetrieveOutputFileResponse</a></code>
- <code><a href="./src/resources/tasks.ts">TaskGetLogsResponse</a></code>
- <code><a href="./src/resources/tasks.ts">TaskGetOutputFileResponse</a></code>
- <code><a href="./src/resources/tasks.ts">TaskGetUserUploadedFileResponse</a></code>

Methods:

- <code title="post /tasks">client.tasks.<a href="./src/resources/tasks.ts">create</a>({ ...params }) -> TaskView</code>
- <code title="get /tasks/{task_id}">client.tasks.<a href="./src/resources/tasks.ts">retrieve</a>(taskID, { ...params }) -> TaskRetrieveResponse</code>
- <code title="get /tasks/{task_id}">client.tasks.<a href="./src/resources/tasks.ts">retrieve</a>(taskID) -> TaskView</code>
- <code title="patch /tasks/{task_id}">client.tasks.<a href="./src/resources/tasks.ts">update</a>(taskID, { ...params }) -> TaskView</code>
- <code title="get /tasks">client.tasks.<a href="./src/resources/tasks.ts">list</a>({ ...params }) -> TaskListResponse</code>
- <code title="get /tasks/{task_id}/logs">client.tasks.<a href="./src/resources/tasks.ts">retrieveLogs</a>(taskID) -> TaskRetrieveLogsResponse</code>
- <code title="get /tasks/{task_id}/output-files/{file_name}">client.tasks.<a href="./src/resources/tasks.ts">retrieveOutputFile</a>(fileName, { ...params }) -> TaskRetrieveOutputFileResponse</code>
- <code title="get /tasks/{task_id}/logs">client.tasks.<a href="./src/resources/tasks.ts">getLogs</a>(taskID) -> TaskGetLogsResponse</code>
- <code title="get /tasks/{task_id}/output-files/{file_id}">client.tasks.<a href="./src/resources/tasks.ts">getOutputFile</a>(fileID, { ...params }) -> TaskGetOutputFileResponse</code>
- <code title="get /tasks/{task_id}/user-uploaded-files/{file_id}">client.tasks.<a href="./src/resources/tasks.ts">getUserUploadedFile</a>(fileID, { ...params }) -> TaskGetUserUploadedFileResponse</code>

# Sessions

Expand All @@ -32,19 +58,19 @@ Methods:
- <code title="get /sessions/{session_id}">client.sessions.<a href="./src/resources/sessions/sessions.ts">retrieve</a>(sessionID, { ...params }) -> SessionView</code>
- <code title="patch /sessions/{session_id}">client.sessions.<a href="./src/resources/sessions/sessions.ts">update</a>(sessionID, { ...params }) -> SessionView</code>
- <code title="get /sessions">client.sessions.<a href="./src/resources/sessions/sessions.ts">list</a>({ ...params }) -> SessionListResponse</code>
- <code title="delete /sessions/{session_id}">client.sessions.<a href="./src/resources/sessions/sessions.ts">delete</a>(sessionID) -> void</code>

## PublicShare

Types:

- <code><a href="./src/resources/sessions/public-share.ts">ShareView</a></code>
- <code><a href="./src/resources/sessions/public-share.ts">PublicShareDeleteResponse</a></code>

Methods:

- <code title="post /sessions/{session_id}/public-share">client.sessions.publicShare.<a href="./src/resources/sessions/public-share.ts">create</a>(sessionID) -> ShareView</code>
- <code title="get /sessions/{session_id}/public-share">client.sessions.publicShare.<a href="./src/resources/sessions/public-share.ts">retrieve</a>(sessionID) -> ShareView</code>
- <code title="delete /sessions/{session_id}/public-share">client.sessions.publicShare.<a href="./src/resources/sessions/public-share.ts">delete</a>(sessionID) -> unknown</code>
- <code title="delete /sessions/{session_id}/public-share">client.sessions.publicShare.<a href="./src/resources/sessions/public-share.ts">delete</a>(sessionID) -> void</code>

# BrowserProfiles

Expand All @@ -53,28 +79,26 @@ Types:
- <code><a href="./src/resources/browser-profiles.ts">BrowserProfileView</a></code>
- <code><a href="./src/resources/browser-profiles.ts">ProxyCountryCode</a></code>
- <code><a href="./src/resources/browser-profiles.ts">BrowserProfileListResponse</a></code>
- <code><a href="./src/resources/browser-profiles.ts">BrowserProfileDeleteResponse</a></code>

Methods:

- <code title="post /browser-profiles">client.browserProfiles.<a href="./src/resources/browser-profiles.ts">create</a>({ ...params }) -> BrowserProfileView</code>
- <code title="get /browser-profiles/{profile_id}">client.browserProfiles.<a href="./src/resources/browser-profiles.ts">retrieve</a>(profileID) -> BrowserProfileView</code>
- <code title="patch /browser-profiles/{profile_id}">client.browserProfiles.<a href="./src/resources/browser-profiles.ts">update</a>(profileID, { ...params }) -> BrowserProfileView</code>
- <code title="get /browser-profiles">client.browserProfiles.<a href="./src/resources/browser-profiles.ts">list</a>({ ...params }) -> BrowserProfileListResponse</code>
- <code title="delete /browser-profiles/{profile_id}">client.browserProfiles.<a href="./src/resources/browser-profiles.ts">delete</a>(profileID) -> unknown</code>
- <code title="delete /browser-profiles/{profile_id}">client.browserProfiles.<a href="./src/resources/browser-profiles.ts">delete</a>(profileID) -> void</code>

# AgentProfiles

Types:

- <code><a href="./src/resources/agent-profiles.ts">AgentProfileView</a></code>
- <code><a href="./src/resources/agent-profiles.ts">AgentProfileListResponse</a></code>
- <code><a href="./src/resources/agent-profiles.ts">AgentProfileDeleteResponse</a></code>

Methods:

- <code title="post /agent-profiles">client.agentProfiles.<a href="./src/resources/agent-profiles.ts">create</a>({ ...params }) -> AgentProfileView</code>
- <code title="get /agent-profiles/{profile_id}">client.agentProfiles.<a href="./src/resources/agent-profiles.ts">retrieve</a>(profileID) -> AgentProfileView</code>
- <code title="patch /agent-profiles/{profile_id}">client.agentProfiles.<a href="./src/resources/agent-profiles.ts">update</a>(profileID, { ...params }) -> AgentProfileView</code>
- <code title="get /agent-profiles">client.agentProfiles.<a href="./src/resources/agent-profiles.ts">list</a>({ ...params }) -> AgentProfileListResponse</code>
- <code title="delete /agent-profiles/{profile_id}">client.agentProfiles.<a href="./src/resources/agent-profiles.ts">delete</a>(profileID) -> unknown</code>
- <code title="delete /agent-profiles/{profile_id}">client.agentProfiles.<a href="./src/resources/agent-profiles.ts">delete</a>(profileID) -> void</code>
3 changes: 1 addition & 2 deletions examples/demo.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
#!/usr/bin/env -S npm run tsn -T

import { BrowserUse } from 'browser-use-sdk';
import { TaskView } from 'browser-use-sdk/resources';
import { spinner } from './utils';

// gets API Key from environment variable BROWSER_USE_API_KEY
Expand All @@ -18,7 +17,7 @@ async function main() {

poll: do {
// Wait for Task to Finish
const status = (await browseruse.tasks.retrieve(rsp.id, { statusOnly: false })) as TaskView;
const status = await browseruse.tasks.retrieve(rsp.id);

switch (status.status) {
case 'started':
Expand Down
74 changes: 74 additions & 0 deletions examples/stream.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
#!/usr/bin/env -S npm run tsn -T

import { BrowserUse } from 'browser-use-sdk';

async function main() {
// gets API Key from environment variable BROWSER_USE_API_KEY
const browseruse = new BrowserUse();

console.log('Creating task and starting stream...\n');

// Create a task and get the stream
const stream = browseruse.tasks.stream({
task: 'What is the weather in San Francisco?',
});

// Get a reader from the stream
const reader = stream.getReader();
const decoder = new TextDecoder();

try {
// Read the stream chunk by chunk
while (true) {
const { done, value } = await reader.read();

if (done) {
console.log('\nStream completed');
break;
}

// Decode the chunk and parse the Server-Sent Events format
const chunk = decoder.decode(value, { stream: true });
const lines = chunk.split('\n');

for (const line of lines) {
if (line.startsWith('event: ')) {
const event = line.slice(7);
process.stdout.write(`\n[${event}] `);
} else if (line.startsWith('data: ')) {
const data = line.slice(6);
if (data.trim() && data !== '{}') {
try {
const parsed = JSON.parse(data) as BrowserUse.TaskView;

process.stdout.write(`${parsed.status}`);
if (parsed.sessionLiveUrl) {
process.stdout.write(` | Live URL: ${parsed.sessionLiveUrl}`);
}

if (parsed.steps.length > 0) {
const latestStep = parsed.steps[parsed.steps.length - 1];
process.stdout.write(` | ${latestStep!.nextGoal}`);
}

if (parsed.status === 'finished') {
process.stdout.write(`\n\nOUTPUT: ${parsed.doneOutput}`);
// Close the reader and exit the main loop when task is finished
reader.releaseLock();
return;
}
} catch (e) {
process.stdout.write(`Raw data: ${data}`);
}
}
}
}
}
} catch (error) {
console.error('Error reading stream:', error);
} finally {
reader.releaseLock();
}
}

main().catch(console.error);
13 changes: 9 additions & 4 deletions examples/structured-output.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,15 +23,16 @@ async function main() {
const stop = spinner(() => log);

// Create Task
const rsp = await browseruse.tasks.createWithStructuredOutput({
const rsp = await browseruse.tasks.create({
task: 'Extract top 10 Hacker News posts and return the title, url, and score',
structuredOutputJson: TaskOutput,
});

poll: do {
// Wait for Task to Finish
const status = await browseruse.tasks.retrieveWithStructuredOutput(rsp.id, {
structuredOutputJson: TaskOutput,
const status = await browseruse.tasks.retrieve({
taskId: rsp.id,
schema: TaskOutput,
});

switch (status.status) {
Expand All @@ -52,12 +53,16 @@ async function main() {
}

case 'finished':
if (status.doneOutput == null) {
throw new Error('No output');
}

stop();

// Print Structured Output
console.log('TOP POSTS:');

for (const post of status.doneOutput!.posts) {
for (const post of status.doneOutput.posts) {
console.log(` - ${post.title} (${post.score}) ${post.url}`);
}

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "browser-use-sdk",
"version": "0.1.1",
"version": "0.2.0",
"description": "The official TypeScript library for the Browser Use API",
"author": "Browser Use <[email protected]>",
"types": "dist/index.d.ts",
Expand Down
Loading