1import { ApifyClient } from 'apify-client';
2
3
4
5const client = new ApifyClient({
6 token: '<YOUR_API_TOKEN>',
7});
8
9
10const input = {
11 "currentProducts": [
12 {
13 "id": 1001,
14 "title": "Trail Jacket",
15 "handle": "trail-jacket",
16 "variants": [
17 {
18 "id": 2001,
19 "product_id": 1001,
20 "title": "Blue / S",
21 "sku": "TJ-BLU-S",
22 "image_id": 3001
23 },
24 {
25 "id": 2002,
26 "product_id": 1001,
27 "title": "Blue / M",
28 "sku": "TJ-BLU-S",
29 "image_id": 3999
30 }
31 ],
32 "images": [
33 {
34 "id": 3001,
35 "product_id": 1001,
36 "src": "https://cdn.example.com/trail-jacket-blue.jpg",
37 "alt": "",
38 "variant_ids": [
39 2001
40 ]
41 }
42 ]
43 }
44 ],
45 "baselineProducts": [
46 {
47 "id": 1001,
48 "title": "Trail Jacket",
49 "handle": "trail-jacket",
50 "variants": [
51 {
52 "id": 2001,
53 "product_id": 1001,
54 "title": "Blue / S",
55 "sku": "TJ-BLU-S",
56 "image_id": 3001
57 },
58 {
59 "id": 2002,
60 "product_id": 1001,
61 "title": "Blue / M",
62 "sku": "TJ-BLU-M",
63 "image_id": 3002
64 }
65 ],
66 "images": [
67 {
68 "id": 3001,
69 "product_id": 1001,
70 "src": "https://cdn.example.com/trail-jacket-blue.jpg",
71 "alt": "Blue trail jacket, front view",
72 "variant_ids": [
73 2001
74 ]
75 },
76 {
77 "id": 3002,
78 "product_id": 1001,
79 "src": "https://cdn.example.com/trail-jacket-blue-m.jpg",
80 "alt": "Blue trail jacket, size M",
81 "variant_ids": [
82 2002
83 ]
84 }
85 ]
86 }
87 ]
88};
89
90
91const run = await client.actor("practical_ai_lab_jp/pal-shopify-variant-image-association-audit").call(input);
92
93
94console.log('Results from dataset');
95console.log(`💾 Check your data here: https://console.apify.com/storage/datasets/${run.defaultDatasetId}`);
96const { items } = await client.dataset(run.defaultDatasetId).listItems();
97items.forEach((item) => {
98 console.dir(item);
99});
100
101