1import { ApifyClient } from 'apify-client';
2
3
4
5const client = new ApifyClient({
6 token: '<YOUR_API_TOKEN>',
7});
8
9
10const input = {
11 "reports": [
12 {
13 "format": "csv",
14 "data": "acct,network,from,to,post,shown,unique_reach\nbrand-a,instagram,2026-10-01,2026-10-07,p-1,10,7",
15 "mapping": {
16 "business_account_key": "acct",
17 "platform": "network",
18 "period_start": "from",
19 "period_end": "to",
20 "post_key": "post",
21 "impressions": "shown",
22 "reach": "unique_reach"
23 },
24 "metric_definition_ids": {
25 "impressions": "post_impressions_v1",
26 "reach": "account_reach_v1"
27 }
28 },
29 {
30 "format": "json",
31 "data": "[{\"business\":\"brand-a\",\"channel\":\"instagram\",\"start_date\":\"2026-10-08\",\"end_date\":\"2026-10-14\",\"content\":\"p-2\",\"views_total\":14,\"reach_total\":9}]",
32 "mapping": {
33 "business_account_key": "business",
34 "platform": "channel",
35 "period_start": "start_date",
36 "period_end": "end_date",
37 "post_key": "content",
38 "impressions": "views_total",
39 "reach": "reach_total"
40 },
41 "metric_definition_ids": {
42 "impressions": "post_impressions_v1",
43 "reach": "account_reach_v1"
44 }
45 }
46 ]
47};
48
49
50const run = await client.actor("althorlabs/social-metrics-reconciler").call(input);
51
52
53console.log('Results from dataset');
54console.log(`💾 Check your data here: https://console.apify.com/storage/datasets/${run.defaultDatasetId}`);
55const { items } = await client.dataset(run.defaultDatasetId).listItems();
56items.forEach((item) => {
57 console.dir(item);
58});
59
60