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 "id": 101,
14 "storeHost": "demo-shop.myshopify.com",
15 "handle": "sky-blue-widget",
16 "title": "Sky Blue Everyday Widget",
17 "vendor": "PAL Demo",
18 "product_type": "Accessories",
19 "body_html": "<p>A reusable everyday accessory with durable materials, practical sizing and detailed care instructions for reliable daily use.</p>",
20 "images": [
21 {
22 "src": "https://cdn.example.org/widget-blue.jpg",
23 "alt": ""
24 }
25 ],
26 "variants": [
27 {
28 "id": 1001,
29 "sku": "WIDGET-BLUE",
30 "price": "29.00",
31 "compare_at_price": "39.00",
32 "available": true,
33 "option1": "Blue"
34 }
35 ]
36 },
37 {
38 "id": 102,
39 "storeHost": "demo-shop.myshopify.com",
40 "handle": "bright-red-widget",
41 "title": "Bright Red Everyday Widget",
42 "vendor": "PAL Demo",
43 "product_type": "Accessories",
44 "body_html": "<p>A colorful durable accessory with helpful product measurements, materials information and intended use explained clearly.</p>",
45 "images": [],
46 "variants": [
47 {
48 "id": 1002,
49 "sku": "WIDGET-RED",
50 "price": "21.00",
51 "available": false,
52 "option1": "Red"
53 }
54 ]
55 }
56 ],
57 "previousProducts": [
58 {
59 "id": 101,
60 "storeHost": "demo-shop.myshopify.com",
61 "handle": "sky-blue-widget",
62 "title": "Sky Blue Everyday Widget",
63 "vendor": "PAL Demo",
64 "product_type": "Accessories",
65 "body_html": "<p>A reusable everyday accessory with durable materials, practical sizing and detailed care instructions for reliable daily use.</p>",
66 "images": [
67 {
68 "src": "https://cdn.example.org/widget-blue.jpg",
69 "alt": ""
70 }
71 ],
72 "variants": [
73 {
74 "id": 1001,
75 "sku": "WIDGET-BLUE",
76 "price": "35.00",
77 "compare_at_price": "39.00",
78 "available": false,
79 "option1": "Blue"
80 }
81 ]
82 }
83 ],
84 "competitorProducts": [
85 {
86 "id": 201,
87 "storeHost": "sample-competitor.myshopify.com",
88 "handle": "blue-competitor-widget",
89 "title": "Competitor Blue Everyday Widget",
90 "vendor": "PAL Demo",
91 "product_type": "Accessories",
92 "body_html": "<p>A reusable everyday accessory with durable materials, practical sizing and detailed care instructions for reliable daily use.</p>",
93 "images": [
94 {
95 "src": "https://cdn.example.org/competitor-blue.jpg",
96 "alt": "Blue accessory"
97 }
98 ],
99 "variants": [
100 {
101 "id": 2001,
102 "sku": "WIDGET-BLUE",
103 "price": "27.50",
104 "available": true,
105 "option1": "Blue"
106 }
107 ]
108 }
109 ],
110 "publicStores": [],
111 "currencyByStore": {
112 "demo-shop.myshopify.com": "USD",
113 "sample-competitor.myshopify.com": "USD"
114 },
115 "costBySku": {
116 "WIDGET-BLUE": "12.00"
117 }
118};
119
120
121const run = await client.actor("practical_ai_lab_jp/pal-shopify-commerce-intelligence-suite").call(input);
122
123
124console.log('Results from dataset');
125console.log(`💾 Check your data here: https://console.apify.com/storage/datasets/${run.defaultDatasetId}`);
126const { items } = await client.dataset(run.defaultDatasetId).listItems();
127items.forEach((item) => {
128 console.dir(item);
129});
130
131