1from apify_client import ApifyClient
2
3
4
5client = ApifyClient("<YOUR_API_TOKEN>")
6
7
8run_input = {
9 "steps": [
10 {
11 "actor": "nerolabs/dataset-filter-transform",
12 "label": "Keep the active Pro accounts",
13 "input": {
14 "data": [
15 {
16 "email": "ana@example.com",
17 "plan": "Pro",
18 "mrr": 49,
19 "active": True,
20 },
21 {
22 "email": "ben@example.com",
23 "plan": "Starter",
24 "mrr": 19,
25 "active": True,
26 },
27 {
28 "email": "cara@example.com",
29 "plan": "Pro",
30 "mrr": 99,
31 "active": False,
32 },
33 {
34 "email": "dan@example.com",
35 "plan": "Pro",
36 "mrr": 149,
37 "active": True,
38 },
39 ],
40 "filters": [
41 {
42 "field": "plan",
43 "operator": "equals",
44 "value": "Pro",
45 },
46 {
47 "field": "active",
48 "operator": "isTrue",
49 },
50 ],
51 "filterMode": "AND",
52 },
53 },
54 {
55 "actor": "nerolabs/dataset-aggregate-pivot",
56 "label": "Total the revenue by plan",
57 "input": {
58 "groupByFields": ["plan"],
59 "aggregations": [{
60 "field": "mrr",
61 "function": "sum",
62 "as": "totalMrr",
63 }],
64 },
65 },
66 ],
67 "dryRun": True,
68}
69
70
71run = client.actor("nerolabs/actor-pipeline-runner").call(run_input=run_input)
72
73
74print(f"💾 Check your data here: https://console.apify.com/storage/datasets/{run.default_dataset_id}")
75for item in client.dataset(run.default_dataset_id).iterate_items():
76 print(item)
77
78