1import { ApifyClient } from 'apify-client';
2
3
4
5const client = new ApifyClient({
6 token: '<YOUR_API_TOKEN>',
7});
8
9
10const input = {
11 "mode": "players",
12 "playerNames": [
13 "Aaron Judge",
14 "Shohei Ohtani",
15 "Mookie Betts",
16 "Ronald Acuna Jr.",
17 "Juan Soto",
18 "Gerrit Cole",
19 "Freddie Freeman",
20 "Jose Ramirez",
21 "Tarik Skubal",
22 "Bobby Witt Jr."
23 ],
24 "playerIds": [],
25 "teamNames": [],
26 "teamIds": [],
27 "league": "both",
28 "leaderCategory": "homeRuns",
29 "maxItems": 10,
30 "statGroup": "auto",
31 "statType": "season",
32 "includeRoster": true,
33 "includeBoxScore": false
34};
35
36
37const run = await client.actor("fabri.ce/mlb-stats-scraper").call(input);
38
39
40console.log('Results from dataset');
41console.log(`💾 Check your data here: https://console.apify.com/storage/datasets/${run.defaultDatasetId}`);
42const { items } = await client.dataset(run.defaultDatasetId).listItems();
43items.forEach((item) => {
44 console.dir(item);
45});
46
47