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": "canvas-tote",
16 "title": "Canvas Tote",
17 "variants": [
18 {
19 "id": 2001,
20 "title": "Natural",
21 "sku": "TOTE-NAT",
22 "available": true,
23 "price": "24.00"
24 },
25 {
26 "id": 2002,
27 "title": "Black",
28 "sku": "TOTE-BLK",
29 "available": true,
30 "price": "24.00"
31 }
32 ]
33 },
34 {
35 "id": 1002,
36 "handle": "ceramic-mug",
37 "title": "Ceramic Mug",
38 "variants": [
39 {
40 "id": 2003,
41 "title": "White",
42 "sku": "MUG-WHT",
43 "available": false,
44 "price": "14.00"
45 },
46 {
47 "id": 2004,
48 "title": "Blue",
49 "sku": "MUG-BLU",
50 "available": true,
51 "price": "14.00"
52 }
53 ]
54 },
55 {
56 "id": 1003,
57 "handle": "notebook",
58 "title": "Notebook",
59 "variants": [
60 {
61 "id": 2005,
62 "title": "A5",
63 "sku": "NB-A5",
64 "available": true,
65 "price": "9.00"
66 }
67 ]
68 }
69 ]
70 },
71 "afterSnapshot": {
72 "products": [
73 {
74 "id": 1001,
75 "handle": "canvas-tote",
76 "title": "Canvas Tote",
77 "variants": [
78 {
79 "id": 2001,
80 "title": "Natural",
81 "sku": "TOTE-NAT",
82 "available": false,
83 "price": "24.00"
84 },
85 {
86 "id": 2002,
87 "title": "Black",
88 "sku": "TOTE-BLK",
89 "available": true,
90 "price": "24.00"
91 }
92 ]
93 },
94 {
95 "id": 1002,
96 "handle": "ceramic-mug",
97 "title": "Ceramic Mug",
98 "variants": [
99 {
100 "id": 2003,
101 "title": "White",
102 "sku": "MUG-WHT",
103 "available": true,
104 "price": "15.00"
105 },
106 {
107 "id": 2004,
108 "title": "Blue",
109 "sku": "MUG-BLU",
110 "available": false,
111 "price": "14.00"
112 }
113 ]
114 },
115 {
116 "id": 1003,
117 "handle": "notebook",
118 "title": "Notebook",
119 "variants": [
120 {
121 "id": 2005,
122 "title": "A5",
123 "sku": "NB-A5",
124 "available": false,
125 "price": "9.00"
126 },
127 {
128 "id": 2006,
129 "title": "A6",
130 "sku": "NB-A6",
131 "available": false,
132 "price": "7.00"
133 }
134 ]
135 }
136 ]
137 }
138};
139
140
141const run = await client.actor("practical_ai_lab_jp/pal-shopify-variant-availability-trends").call(input);
142
143
144console.log('Results from dataset');
145console.log(`💾 Check your data here: https://console.apify.com/storage/datasets/${run.defaultDatasetId}`);
146const { items } = await client.dataset(run.defaultDatasetId).listItems();
147items.forEach((item) => {
148 console.dir(item);
149});
150
151