@@ -26,9 +26,11 @@ const client = new BrowserUse({
2626 apiKey: process .env [' BROWSER_USE_API_KEY' ], // This is the default and can be omitted
2727});
2828
29- const me = await client .users .me .retrieve ();
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
31- console .log (me . additionalCreditsBalanceUsd );
33+ console .log (task . id );
3234```
3335
3436### Request & Response types
@@ -43,7 +45,10 @@ const client = new BrowserUse({
4345 apiKey: process .env [' BROWSER_USE_API_KEY' ], // This is the default and can be omitted
4446});
4547
46- const me: BrowserUse .Users .MeRetrieveResponse = await client .users .me .retrieve ();
48+ const params: BrowserUse .TaskCreateParams = {
49+ task: ' Search for the top 10 Hacker News posts and return the title and url.' ,
50+ };
51+ const task: BrowserUse .TaskCreateResponse = await client .tasks .create (params );
4752```
4853
4954Documentation for each method, request param, and response field are available in docstrings and will appear on hover in most modern editors.
@@ -56,15 +61,17 @@ a subclass of `APIError` will be thrown:
5661
5762<!-- prettier-ignore -->
5863``` ts
59- const me = await client .users .me .retrieve ().catch (async (err ) => {
60- if (err instanceof BrowserUse .APIError ) {
61- console .log (err .status ); // 400
62- console .log (err .name ); // BadRequestError
63- console .log (err .headers ); // {server: 'nginx', ...}
64- } else {
65- throw err ;
66- }
67- });
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+ });
6875```
6976
7077Error codes are as follows:
@@ -96,7 +103,7 @@ const client = new BrowserUse({
96103});
97104
98105// Or, configure per-request:
99- await client .users . me . retrieve ( {
106+ await client .tasks . create ({ task : ' Search for the top 10 Hacker News posts and return the title and url. ' }, {
100107 maxRetries: 5 ,
101108});
102109```
@@ -113,7 +120,7 @@ const client = new BrowserUse({
113120});
114121
115122// Override per-request:
116- await client .users . me . retrieve ( {
123+ await client .tasks . create ({ task: ' Search for the top 10 Hacker News posts and return the title and url. ' }, {
117124 timeout: 5 * 1000 ,
118125});
119126```
@@ -136,13 +143,17 @@ Unlike `.asResponse()` this method consumes the body, returning once it is parse
136143``` ts
137144const client = new BrowserUse ();
138145
139- const response = await client .users .me .retrieve ().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 ();
140149console .log (response .headers .get (' X-My-Header' ));
141150console .log (response .statusText ); // access the underlying Response object
142151
143- const { data : me, response : raw } = await client .users .me .retrieve ().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 ();
144155console .log (raw .headers .get (' X-My-Header' ));
145- console .log (me . additionalCreditsBalanceUsd );
156+ console .log (task . id );
146157```
147158
148159### Logging
@@ -222,7 +233,7 @@ parameter. This library doesn't validate at runtime that the request matches the
222233send will be sent as-is.
223234
224235``` ts
225- client .users . me . retrieve ({
236+ client .tasks . create ({
226237 // ...
227238 // @ts-expect-error baz is not yet public
228239 baz: ' undocumented option' ,
0 commit comments