1import { ApifyClient } from 'apify-client';
2
3
4
5const client = new ApifyClient({
6 token: '<YOUR_API_TOKEN>',
7});
8
9
10const input = {
11 "sourceMode": "list",
12 "searchTerms": [
13 "posture corrector",
14 "dog harness",
15 "vitamin c serum"
16 ],
17 "productBrief": "An ergonomic laptop stand for people who work from home — adjustable height, folds flat, aluminium, $49.",
18 "maxDiscoveryChargeUsd": 0.5,
19 "maxQualified": 100,
20 "maxAdsToScan": 150,
21 "maxAdsPerSearch": 50,
22 "itemsList": [
23 {
24 "ad_archive_id": "1184500000000001",
25 "collation_id": "7300000000000011",
26 "collation_count": 12,
27 "page_id": "100000000000101",
28 "page_name": "Aligna Posture",
29 "is_active": true,
30 "start_date": 1781942400,
31 "end_date": null,
32 "publisher_platform": [
33 "FACEBOOK",
34 "INSTAGRAM",
35 "MESSENGER"
36 ],
37 "categories": [
38 "UNKNOWN"
39 ],
40 "contains_digital_created_media": false,
41 "impressions_with_index": {
42 "impressions_text": null
43 },
44 "snapshot": {
45 "page_name": "Aligna Posture",
46 "page_profile_uri": "https://www.facebook.com/alignaposture.example",
47 "page_like_count": 48210,
48 "page_categories": [
49 "Health & wellness website"
50 ],
51 "display_format": "VIDEO",
52 "title": "Sit taller in 7 days",
53 "body": {
54 "text": "Tired of that 3pm neck ache at your desk? Aligna gently pulls your shoulders back so you sit tall without thinking about it. 50,000+ happy customers. Get 30% OFF today + free shipping."
55 },
56 "link_description": "30-day money-back guarantee",
57 "cta_text": "Shop now",
58 "cta_type": "SHOP_NOW",
59 "link_url": "https://aligna.example/posture-corrector?utm_source=facebook&utm_campaign=q3&fbclid=IwAR0x",
60 "caption": "ALIGNA.EXAMPLE",
61 "images": [],
62 "videos": [
63 {
64 "video_hd_url": "https://video.example/aligna-hook-hd.mp4",
65 "video_preview_image_url": "https://img.example/aligna-preview.jpg"
66 }
67 ],
68 "cards": []
69 },
70 "searchTerm": "posture corrector",
71 "landingPage": {
72 "status": "ok",
73 "storePlatform": "shopify",
74 "pageType": "product",
75 "productTitle": "Aligna Posture Corrector",
76 "price": 39.95,
77 "currency": "USD",
78 "rating": 4.6,
79 "reviewsCount": 2184,
80 "pageTitle": "Aligna Posture Corrector – Aligna",
81 "fetchedUrl": "https://aligna.example/posture-corrector",
82 "sample": true
83 }
84 },
85 {
86 "ad_archive_id": "1184500000000002",
87 "collation_id": "7300000000000011",
88 "collation_count": 12,
89 "page_id": "100000000000101",
90 "page_name": "Aligna Posture",
91 "is_active": true,
92 "start_date": 1784361600,
93 "publisher_platform": [
94 "FACEBOOK",
95 "INSTAGRAM"
96 ],
97 "snapshot": {
98 "display_format": "VIDEO",
99 "title": "Sit taller in 7 days",
100 "body": {
101 "text": "Neck ache at your desk? Aligna pulls your shoulders back. Get 30% OFF today."
102 },
103 "cta_text": "Shop now",
104 "link_url": "https://aligna.example/posture-corrector?utm_source=facebook&utm_content=v2",
105 "caption": "aligna.example",
106 "videos": [
107 {
108 "video_sd_url": "https://video.example/aligna-v2-sd.mp4"
109 }
110 ]
111 },
112 "searchTerm": "posture corrector"
113 },
114 {
115 "adArchiveID": "1184500000000003",
116 "collationId": "7300000000000022",
117 "collationCount": 6,
118 "pageID": "100000000000202",
119 "pageName": "Pawtrail",
120 "isActive": true,
121 "startDateFormatted": "2026-08-01T09:00:00.000Z",
122 "publisherPlatform": [
123 "facebook",
124 "instagram"
125 ],
126 "containsDigitalCreatedMedia": false,
127 "snapshot": {
128 "pageProfileUri": "https://www.facebook.com/pawtrail.example",
129 "pageLikeCount": 12940,
130 "pageCategories": [
131 "Pet supplies"
132 ],
133 "displayFormat": "CAROUSEL",
134 "body": {
135 "text": "My dog pulled like a train until we tried the Pawtrail no-pull harness. Now walks are actually fun. Buy 1, get 1 50% off — this week only."
136 },
137 "ctaText": "Shop now",
138 "ctaType": "SHOP_NOW",
139 "caption": "pawtrail.example",
140 "cards": [
141 {
142 "title": "The harness that stops the pull",
143 "body": "My dog pulled like a train until we tried the Pawtrail no-pull harness.",
144 "linkUrl": "https://pawtrail.example/no-pull-harness?utm_source=meta",
145 "originalImageUrl": "https://img.example/pawtrail-card-1.jpg"
146 },
147 {
148 "title": "Fits in 30 seconds",
149 "body": "Two clips, no fuss.",
150 "linkUrl": "https://pawtrail.example/no-pull-harness",
151 "originalImageUrl": "https://img.example/pawtrail-card-2.jpg"
152 }
153 ]
154 },
155 "searchTerm": "dog harness"
156 },
157 {
158 "ad_archive_id": "1184500000000004",
159 "collation_id": "7300000000000033",
160 "collation_count": 4,
161 "page_id": "100000000000303",
162 "page_name": "Lumière Skin Lab",
163 "is_active": true,
164 "start_date": 1784102400,
165 "publisher_platform": [
166 "FACEBOOK",
167 "INSTAGRAM",
168 "AUDIENCE_NETWORK"
169 ],
170 "impressions_with_index": {
171 "impressions_text": "100K-200K",
172 "impressions_index": 4
173 },
174 "snapshot": {
175 "page_like_count": 30511,
176 "page_categories": [
177 "Beauty, cosmetic & personal care"
178 ],
179 "display_format": "IMAGE",
180 "title": "Brighter skin in 14 days",
181 "body": "Dermatologist-formulated 15% vitamin C serum for dull, tired skin. Brighter in 14 days or your money back. Now $29.99 (was $45).",
182 "link_description": "Free shipping on orders over $35",
183 "cta_text": "Learn more",
184 "cta_type": "LEARN_MORE",
185 "link_url": "https://lumiere-skinlab.example/vitamin-c?utm_source=fb&utm_medium=paid",
186 "caption": "lumiere-skinlab.example",
187 "images": [
188 {
189 "original_image_url": "https://img.example/lumiere-serum.jpg",
190 "resized_image_url": "https://img.example/lumiere-serum-600.jpg"
191 }
192 ]
193 },
194 "searchTerm": "vitamin c serum",
195 "reach_estimate": "80K-120K",
196 "landingPage": {
197 "status": "ok",
198 "storePlatform": "woocommerce",
199 "pageType": "product",
200 "productTitle": "15% Vitamin C Brightening Serum",
201 "price": 29.99,
202 "currency": "USD",
203 "rating": 4.4,
204 "reviewsCount": 612,
205 "pageTitle": "Vitamin C Serum | Lumière Skin Lab",
206 "fetchedUrl": "https://lumiere-skinlab.example/vitamin-c",
207 "sample": true
208 }
209 },
210 {
211 "ad_archive_id": "1184500000000005",
212 "collation_id": "7300000000000044",
213 "collation_count": 2,
214 "page_id": "100000000000404",
215 "page_name": "StandUp Co",
216 "is_active": true,
217 "start_date": 1788595200,
218 "publisher_platform": [
219 "FACEBOOK"
220 ],
221 "snapshot": {
222 "page_categories": [
223 "Furniture"
224 ],
225 "display_format": "VIDEO",
226 "title": "Any desk. Standing in 10 seconds.",
227 "body": {
228 "text": "Your back will thank you. The StandUp converter turns any desk into a standing desk in 10 seconds. Free delivery across the US."
229 },
230 "cta_text": "Shop now",
231 "link_url": "https://standup-co.example/converter",
232 "caption": "standup-co.example",
233 "videos": [
234 {
235 "video_hd_url": "https://video.example/standup-demo.mp4",
236 "video_preview_image_url": "https://img.example/standup-preview.jpg"
237 }
238 ]
239 },
240 "searchTerm": "posture corrector"
241 },
242 {
243 "ad_archive_id": "1184500000000006",
244 "page_id": "100000000000505",
245 "page_name": "Citizens for Cleaner Parks",
246 "is_active": true,
247 "start_date": 1780300800,
248 "categories": [
249 "POLITICAL"
250 ],
251 "political_countries": [
252 "US"
253 ],
254 "spend": {
255 "lower_bound": "1000",
256 "upper_bound": "1499"
257 },
258 "currency": "USD",
259 "publisher_platform": [
260 "FACEBOOK",
261 "INSTAGRAM"
262 ],
263 "snapshot": {
264 "display_format": "IMAGE",
265 "body": {
266 "text": "Vote yes on Measure 12 for cleaner city parks."
267 },
268 "cta_text": "Learn more",
269 "link_url": "https://cleanerparks.example/measure-12"
270 }
271 },
272 {
273 "ad_archive_id": "1184500000000007",
274 "collation_id": "7300000000000066",
275 "collation_count": 1,
276 "page_id": "100000000000606",
277 "page_name": "GlowBox",
278 "is_active": true,
279 "start_date": 1790150400,
280 "publisher_platform": [
281 "INSTAGRAM"
282 ],
283 "snapshot": {
284 "display_format": "IMAGE",
285 "body": {
286 "text": "New drop: the GlowBox LED mask. Link in bio."
287 },
288 "cta_text": "Shop now",
289 "link_url": "https://glowbox.example/led-mask"
290 },
291 "searchTerm": "vitamin c serum"
292 },
293 {
294 "ad_archive_id": "1184500000000008",
295 "collation_id": "7300000000000077",
296 "collation_count": 3,
297 "page_id": "100000000000707",
298 "page_name": "SnoozeWell",
299 "is_active": false,
300 "start_date": 1772352000,
301 "end_date": 1780128000,
302 "publisher_platform": [
303 "FACEBOOK",
304 "INSTAGRAM"
305 ],
306 "snapshot": {
307 "display_format": "IMAGE",
308 "body": {
309 "text": "Fall asleep in 10 minutes with the SnoozeWell weighted eye mask. Free trial for 30 nights."
310 },
311 "cta_text": "Try it free",
312 "link_url": "https://snoozewell.example/mask"
313 }
314 }
315 ],
316 "discoveryInput": {},
317 "proxyConfiguration": {
318 "useApifyProxy": true
319 }
320};
321
322
323const run = await client.actor("rich_minds/fb-ad-library-winning-ads").call(input);
324
325
326console.log('Results from dataset');
327console.log(`💾 Check your data here: https://console.apify.com/storage/datasets/${run.defaultDatasetId}`);
328const { items } = await client.dataset(run.defaultDatasetId).listItems();
329items.forEach((item) => {
330 console.dir(item);
331});
332
333