1import { ApifyClient } from 'apify-client';
2
3
4
5const client = new ApifyClient({
6 token: '<YOUR_API_TOKEN>',
7});
8
9
10const input = {
11 "products": [
12 {
13 "sku": "BOOK-ATTIC",
14 "name": "A Light in the Attic",
15 "yourPrice": 49.99,
16 "currency": "GBP",
17 "costPrice": 20,
18 "competitors": [
19 {
20 "name": "Books to Scrape",
21 "url": "https://books.toscrape.com/catalogue/a-light-in-the-attic_1000/index.html"
22 }
23 ]
24 },
25 {
26 "sku": "BOOK-VELVET",
27 "name": "Tipping the Velvet",
28 "yourPrice": 55,
29 "currency": "GBP",
30 "costPrice": 25,
31 "competitors": [
32 {
33 "name": "Books to Scrape",
34 "url": "https://books.toscrape.com/catalogue/tipping-the-velvet_999/index.html"
35 }
36 ]
37 },
38 {
39 "sku": "RUNNER-TREE-M8",
40 "name": "Men's Tree Runner (size 8)",
41 "yourPrice": 105,
42 "currency": "USD",
43 "costPrice": 45,
44 "competitors": [
45 {
46 "name": "Allbirds (Shopify)",
47 "url": "https://www.allbirds.com/products/mens-tree-runners"
48 }
49 ]
50 }
51 ]
52};
53
54
55const run = await client.actor("prevailing_glow/competitor-price-monitor").call(input);
56
57
58console.log('Results from dataset');
59console.log(`💾 Check your data here: https://console.apify.com/storage/datasets/${run.defaultDatasetId}`);
60const { items } = await client.dataset(run.defaultDatasetId).listItems();
61items.forEach((item) => {
62 console.dir(item);
63});
64
65