-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path3.getTask.js
More file actions
124 lines (110 loc) · 3.87 KB
/
3.getTask.js
File metadata and controls
124 lines (110 loc) · 3.87 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
/**
* Description:
* Retrieve detailed information about the workflow task, including current status, completed steps,
* output from finished tasks, and other metadata.
*
* Documentation:
* https://www.browseract.com/reception/integrations/api-workflow
*
* curl -X GET 'https://api.browseract.com/v2/workflow/get-task?task_id=16429034742537847' -H 'Authorization: Bearer app-abcdefghijklmn'
*/
const https = require('https');
function main() {
// API Key Required for API Call, generated from: https://www.browseract.com/reception/integrations
const authorization = "app-abcdefghijklmn";
// The task ID, returned by endpoints like /run-task.
// Please refer to "1.runTask.js"
const taskId = "16429034742537847";
try {
const options = {
hostname: 'api.browseract.com',
port: 443,
path: `/v2/workflow/get-task?task_id=${taskId}`,
method: 'GET',
headers: {
'Authorization': `Bearer ${authorization}`
}
};
const req = https.request(options, (res) => {
let responseData = '';
res.on('data', (chunk) => {
responseData += chunk;
});
res.on('end', () => {
if (res.statusCode === 200) {
// success example: Please refer to the bottom of this file
console.log('api-call-ok:', responseData);
const response = JSON.parse(responseData);
console.log('\nTask Details:');
console.log('ID:', response.id);
console.log('Status:', response.status);
console.log('Workflow ID:', response.workflow_id);
if (response.output && response.output.string) {
console.log('Output:', response.output.string);
}
} else {
// error example:
// {"code": 401, "msg": "Invalid authorization", "data": null, "ts": 1759917250113, "time": "2025-10-08 09:54:10", "traceId": "bcdef"}
// {"code": 10112, "msg": "Task is not exist.", "data": null, "ts": 1759918566040, "time": "2025-10-08 10:16:06", "traceId": "cdefg"}
console.log(`api-call-error: status=${res.statusCode}`, responseData);
}
});
});
req.on('error', (error) => {
console.log('run-error:', error.message);
});
req.end();
} catch (error) {
console.log('run-error:', error.message);
}
}
main();
/*
success example:
{
"id": "16429034742537847",
"workflow_id": "16217357109956214",
"input_parameters": [
{
"name": "target_url",
"value": "https://www.google.com/search?q=iphone17"
},
{
"name": "product_limit",
"value": "10"
}
],
"output": {
"string": "Workflow completed successfully! Extracted 10 products from the search results.",
"files": ["Workflow output file url"]
},
"status": "finished",
"steps": [
{
"id": "184549",
"step": 1,
"status": "succeed",
"step_goal": "Navigate to the target URL and load the page",
"screenshots_url": "Step screenshot file url"
},
{
"id": "184551",
"step": 2,
"status": "succeed",
"step_goal": "Extract product information from the page",
"screenshots_url": "Step screenshot file url"
}
],
"live_url_info": {
"width": 1280,
"height": 1024,
"live_url": "https://www.browseract.com/remote/aaaaa"
},
"live_url": "https://www.browseract.com/remote/aaaaa",
"profile_id": "abcde",
"created_at": "2025-10-09T08:08:35Z",
"finished_at": "2025-10-09T08:09:55Z",
"task_failure_info": null,
"task_gif_url": null
}
*/