Batch Runner avatar
Batch Runner
Try for free

No credit card required

View all Actors
Batch Runner

Batch Runner

useful-tools/batch-runner
Try for free

No credit card required

Actor for starting several Runs from single Input. It also has capability to merge the Dataset items from the created batch.

The code examples below show how to run the Actor and get its results. To run the code, you need to have an Apify account. Replace <YOUR_API_TOKEN> in the code with your API token, which you can find under Settings > Integrations in Apify Console. Learn more

1import { ApifyClient } from 'apify-client';
2
3// Initialize the ApifyClient with your Apify API token
4const client = new ApifyClient({
5    token: '<YOUR_API_TOKEN>',
6});
7
8// Prepare Actor input
9const input = {
10    "batch": [
11        {
12            "actorId": "useful-tools/wait-and-finish",
13            "input": {
14                "minWaitTime": 30,
15                "dataset": {
16                    "items": [
17                        {
18                            "key": "value1"
19                        }
20                    ]
21                }
22            }
23        },
24        {
25            "actorId": "useful-tools/wait-and-finish",
26            "input": {
27                "dataset": {
28                    "items": [
29                        {
30                            "key": "value1"
31                        },
32                        {
33                            "key": "value2"
34                        }
35                    ]
36                }
37            }
38        }
39    ],
40    "maxConcurrency": 25,
41    "maxMemoryMb": 32768
42};
43
44(async () => {
45    // Run the Actor and wait for it to finish
46    const run = await client.actor("useful-tools/batch-runner").call(input);
47
48    // Fetch and print Actor results from the run's dataset (if any)
49    console.log('Results from dataset');
50    console.log(`πŸ’Ύ Check your data here: https://console.apify.com/storage/datasets/${run.defaultDatasetId}`);
51    const { items } = await client.dataset(run.defaultDatasetId).listItems();
52    items.forEach((item) => {
53        console.dir(item);
54    });
55})();
56
57// πŸ“š Want to learn more πŸ“–? Go to β†’ https://docs.apify.com/api/client/js/docs
Developer
Maintained by Community
Actor metrics
  • 1 monthly user
  • 0 stars
  • 100.0% runs succeeded
  • 2.1 hours response time
  • Created in Sep 2023
  • Modified 2 months ago