1import { ApifyClient } from 'apify-client';
2
3
4
5const client = new ApifyClient({
6 token: '<YOUR_API_TOKEN>',
7});
8
9
10const input = {
11 "urls": [
12 "https://httpbin.org/get",
13 "https://example.com",
14 "https://api.ipify.org?format=json"
15 ],
16 "requests": [
17 {
18 "url": "https://httpbin.org/post",
19 "method": "POST",
20 "body": {
21 "hello": "world"
22 },
23 "label": "post-example"
24 }
25 ],
26 "headers": {},
27 "proxyConfiguration": {
28 "useApifyProxy": true
29 },
30 "concurrency": 10,
31 "maxRetries": 2,
32 "retryOnStatuses": [
33 "403",
34 "429",
35 "500",
36 "502",
37 "503",
38 "504"
39 ],
40 "timeoutSecs": 30,
41 "maxBodyChars": 500000,
42 "maxItems": 0
43};
44
45
46const run = await client.actor("seemuapps/http-request-runner").call(input);
47
48
49console.log('Results from dataset');
50console.log(`💾 Check your data here: https://console.apify.com/storage/datasets/${run.defaultDatasetId}`);
51const { items } = await client.dataset(run.defaultDatasetId).listItems();
52items.forEach((item) => {
53 console.dir(item);
54});
55
56