1import { ApifyClient } from 'apify-client';
2
3
4
5const client = new ApifyClient({
6 token: '<YOUR_API_TOKEN>',
7});
8
9
10const input = {
11 "mode": "items",
12 "items": [
13 {
14 "adId": "ad-long-1",
15 "pageName": "FlexKit",
16 "primaryText": "Tired of bulky gym gear in a small apartment? Our fold-flat home fitness kit helps busy parents get a quick full-body session before breakfast.",
17 "headline": "Train at home without losing your living room",
18 "callToAction": "Shop Now",
19 "landingPageUrl": "https://flexkit.example/products/fold-flat-kit",
20 "libraryUrl": "https://www.facebook.com/ads/library/?id=ad-long-1",
21 "mediaType": "video",
22 "publisherPlatform": [
23 "facebook",
24 "instagram"
25 ],
26 "startDate": "2026-05-01",
27 "endDate": "2026-07-09",
28 "countries": [
29 "US",
30 "CA"
31 ]
32 },
33 {
34 "libraryId": "ad-fresh-1",
35 "advertiserName": "Generic Gear",
36 "adText": "Big sale today. Save 10% on our best products.",
37 "title": "Limited time offer",
38 "ctaText": "Shop Now",
39 "linkUrl": "https://genericgear.example/",
40 "format": "image",
41 "startedAt": "2026-07-07",
42 "scrapedAt": "2026-07-09T00:00:00.000Z"
43 },
44 {
45 "id": "ad-risk-1",
46 "brand": "MetaHealth Finance",
47 "text": "Clinically proven to cure chronic pain and guarantee weight loss while improving your credit score in 30 days.",
48 "headline": "Guaranteed results",
49 "cta": "Apply Now",
50 "url": "https://metahealth.example/apply",
51 "mediaType": "image",
52 "startDate": "2026-05-20",
53 "endDate": "2026-07-09"
54 }
55 ],
56 "targetProfile": {
57 "brandName": "BrightNest",
58 "productCategory": "home fitness",
59 "targetCustomers": [
60 "busy parents",
61 "apartment renters"
62 ],
63 "competitors": [
64 "FlexKit",
65 "HomeTone"
66 ],
67 "currentAngles": [
68 "discount_offer"
69 ],
70 "priorityMarkets": [
71 "US",
72 "CA"
73 ],
74 "complianceKeywords": [
75 "guarantee",
76 "clinically proven"
77 ],
78 "disallowedClaims": [
79 "cure",
80 "guaranteed weight loss"
81 ]
82 },
83 "processedAt": "2026-07-09T00:00:00.000Z"
84};
85
86
87const run = await client.actor("rotvuvo/meta-ad-creative-opportunity-scorer").call(input);
88
89
90console.log('Results from dataset');
91console.log(`💾 Check your data here: https://console.apify.com/storage/datasets/${run.defaultDatasetId}`);
92const { items } = await client.dataset(run.defaultDatasetId).listItems();
93items.forEach((item) => {
94 console.dir(item);
95});
96
97