1import { ApifyClient } from 'apify-client';
2
3
4
5const client = new ApifyClient({
6 token: '<YOUR_API_TOKEN>',
7});
8
9
10const input = {
11 "beforeSnapshot": {
12 "products": [
13 {
14 "id": 1001,
15 "handle": "trail-bottle",
16 "title": "Trail Bottle",
17 "vendor": "Northline",
18 "product_type": "Drinkware",
19 "tags": "outdoor, steel",
20 "variants": [
21 {
22 "id": 5001,
23 "sku": "TB-500",
24 "title": "500 ml",
25 "price": "24.00",
26 "available": true
27 },
28 {
29 "id": 5002,
30 "sku": "TB-750",
31 "title": "750 ml",
32 "price": "28.00",
33 "available": true
34 }
35 ]
36 },
37 {
38 "id": 1002,
39 "handle": "camp-mug",
40 "title": "Camp Mug",
41 "vendor": "Northline",
42 "product_type": "Drinkware",
43 "tags": "outdoor",
44 "variants": [
45 {
46 "id": 5003,
47 "sku": "CM-1",
48 "title": "Default",
49 "price": "12.00",
50 "available": true
51 }
52 ]
53 }
54 ]
55 },
56 "afterSnapshot": {
57 "products": [
58 {
59 "id": 1001,
60 "handle": "trail-bottle",
61 "title": "Trail Bottle",
62 "vendor": "Northline Outdoors",
63 "product_type": "Drinkware",
64 "tags": "outdoor, steel, bestseller",
65 "variants": [
66 {
67 "id": 5001,
68 "sku": "TB-500",
69 "title": "500 ml",
70 "price": "26.00",
71 "available": true
72 },
73 {
74 "id": 5004,
75 "sku": "TB-1000",
76 "title": "1 L",
77 "price": "32.00",
78 "available": false
79 }
80 ]
81 },
82 {
83 "id": 1003,
84 "handle": "camp-stove",
85 "title": "Camp Stove",
86 "vendor": "Northline Outdoors",
87 "product_type": "Cooking",
88 "tags": "outdoor",
89 "variants": [
90 {
91 "id": 5005,
92 "sku": "CS-1",
93 "title": "Default",
94 "price": "59.00",
95 "available": true
96 }
97 ]
98 }
99 ]
100 }
101};
102
103
104const run = await client.actor("practical_ai_lab_jp/pal-shopify-store-catalog-diff").call(input);
105
106
107console.log('Results from dataset');
108console.log(`💾 Check your data here: https://console.apify.com/storage/datasets/${run.defaultDatasetId}`);
109const { items } = await client.dataset(run.defaultDatasetId).listItems();
110items.forEach((item) => {
111 console.dir(item);
112});
113
114