1import { ApifyClient } from 'apify-client';
2
3
4
5const client = new ApifyClient({
6 token: '<YOUR_API_TOKEN>',
7});
8
9
10const input = {
11 "postsFile": {
12 "posts": [
13 {
14 "newsletterName": "Field Notes (synthetic demo)",
15 "newsletterUrl": "https://field.example/",
16 "postTitle": "Fieldwork dispatch",
17 "postUrl": "https://field.example/issues/1",
18 "publishedAt": "2026-10-08T12:00:00Z",
19 "html": "<p>Sponsored by <a href='https://cedar.example'>Cedar</a> and <a href='https://birch.example'>Birch</a>.</p><p><a href='/contact'>Contact us</a></p>",
20 "subscriberObservation": {
21 "evidence": "1,240 total subscribers",
22 "observedAt": "2026-10-08",
23 "sourceUrl": "https://field.example/about",
24 "basis": "total"
25 }
26 },
27 {
28 "newsletterName": "Field Notes (synthetic demo)",
29 "newsletterUrl": "https://field.example/",
30 "postTitle": "Reading list",
31 "postUrl": "https://field.example/issues/2",
32 "publishedAt": "2026-10-15T12:00:00Z",
33 "html": "<p>Affiliate link: <a href='https://floor.example'>Floor Press</a>. We earn a commission.</p><p><a href='/contact'>Contact us</a></p>"
34 },
35 {
36 "newsletterName": "Field Notes (synthetic demo)",
37 "newsletterUrl": "https://field.example/",
38 "postTitle": "Editorial notebook",
39 "postUrl": "https://field.example/issues/3",
40 "publishedAt": "2026-10-22T12:00:00Z",
41 "html": "<p>We compared <a href='https://cedar.example'>Cedar</a> with other tools. Thousands of readers joined us.</p><p><a href='/contact'>Contact us</a></p>"
42 }
43 ]
44 },
45 "sponsorKeywords": [
46 "Cedar"
47 ]
48};
49
50
51const run = await client.actor("afkdigital/substack-newsletter-sponsor-intelligence").call(input);
52
53
54console.log('Results from dataset');
55console.log(`💾 Check your data here: https://console.apify.com/storage/datasets/${run.defaultDatasetId}`);
56const { items } = await client.dataset(run.defaultDatasetId).listItems();
57items.forEach((item) => {
58 console.dir(item);
59});
60
61