Skip to content

Commit d339b83

Browse files
feat(api): manual updates
1 parent 5d09807 commit d339b83

File tree

2 files changed

+26
-16
lines changed

2 files changed

+26
-16
lines changed

.stats.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
configured_endpoints: 26
22
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/browser-use%2Fbrowser-use-ce018db4d6891d645cfb220c86d17ac1d431e1ba2f604e8015876b17a5a11149.yml
33
openapi_spec_hash: e9a00924682ab214ca5d8b6b5c84430e
4-
config_hash: 317a81a9027b1e17bb0b4012455daeac
4+
config_hash: dd3e22b635fa0eb9a7c741a8aaca2a7f

README.md

Lines changed: 25 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,9 @@ const client = new BrowserUse({
2626
apiKey: process.env['BROWSER_USE_API_KEY'], // This is the default and can be omitted
2727
});
2828

29-
const task = await client.tasks.create({ task: 'x' });
29+
const task = await client.tasks.create({
30+
task: 'Search for the top 10 Hacker News posts and return the title and url.',
31+
});
3032

3133
console.log(task.id);
3234
```
@@ -43,7 +45,9 @@ const client = new BrowserUse({
4345
apiKey: process.env['BROWSER_USE_API_KEY'], // This is the default and can be omitted
4446
});
4547

46-
const params: BrowserUse.TaskCreateParams = { task: 'x' };
48+
const params: BrowserUse.TaskCreateParams = {
49+
task: 'Search for the top 10 Hacker News posts and return the title and url.',
50+
};
4751
const task: BrowserUse.TaskCreateResponse = await client.tasks.create(params);
4852
```
4953

@@ -57,15 +61,17 @@ a subclass of `APIError` will be thrown:
5761

5862
<!-- prettier-ignore -->
5963
```ts
60-
const task = await client.tasks.create({ task: 'x' }).catch(async (err) => {
61-
if (err instanceof BrowserUse.APIError) {
62-
console.log(err.status); // 400
63-
console.log(err.name); // BadRequestError
64-
console.log(err.headers); // {server: 'nginx', ...}
65-
} else {
66-
throw err;
67-
}
68-
});
64+
const task = await client.tasks
65+
.create({ task: 'Search for the top 10 Hacker News posts and return the title and url.' })
66+
.catch(async (err) => {
67+
if (err instanceof BrowserUse.APIError) {
68+
console.log(err.status); // 400
69+
console.log(err.name); // BadRequestError
70+
console.log(err.headers); // {server: 'nginx', ...}
71+
} else {
72+
throw err;
73+
}
74+
});
6975
```
7076

7177
Error codes are as follows:
@@ -97,7 +103,7 @@ const client = new BrowserUse({
97103
});
98104

99105
// Or, configure per-request:
100-
await client.tasks.create({ task: 'x' }, {
106+
await client.tasks.create({ task: 'Search for the top 10 Hacker News posts and return the title and url.' }, {
101107
maxRetries: 5,
102108
});
103109
```
@@ -114,7 +120,7 @@ const client = new BrowserUse({
114120
});
115121

116122
// Override per-request:
117-
await client.tasks.create({ task: 'x' }, {
123+
await client.tasks.create({ task: 'Search for the top 10 Hacker News posts and return the title and url.' }, {
118124
timeout: 5 * 1000,
119125
});
120126
```
@@ -137,11 +143,15 @@ Unlike `.asResponse()` this method consumes the body, returning once it is parse
137143
```ts
138144
const client = new BrowserUse();
139145

140-
const response = await client.tasks.create({ task: 'x' }).asResponse();
146+
const response = await client.tasks
147+
.create({ task: 'Search for the top 10 Hacker News posts and return the title and url.' })
148+
.asResponse();
141149
console.log(response.headers.get('X-My-Header'));
142150
console.log(response.statusText); // access the underlying Response object
143151

144-
const { data: task, response: raw } = await client.tasks.create({ task: 'x' }).withResponse();
152+
const { data: task, response: raw } = await client.tasks
153+
.create({ task: 'Search for the top 10 Hacker News posts and return the title and url.' })
154+
.withResponse();
145155
console.log(raw.headers.get('X-My-Header'));
146156
console.log(task.id);
147157
```

0 commit comments

Comments
 (0)