1from apify_client import ApifyClient
2
3
4
5client = ApifyClient("<YOUR_API_TOKEN>")
6
7
8run_input = {
9 "blueprints": [{ "blueprint": {
10 "name": "Hourly Order Sync: HTTP to Iterator to Airtable",
11 "version": 1,
12 "metadata": {
13 "instant": False,
14 "version": 1,
15 "scheduling": {
16 "type": "indefinitely",
17 "interval": 3600,
18 },
19 "scenario": {
20 "roundtrips": 1,
21 "maxErrors": 3,
22 "autoCommit": True,
23 },
24 },
25 "flow": [
26 {
27 "id": 1,
28 "module": "http:ActionMakeRequest",
29 "version": 3,
30 "description": "Fetch Pending Orders Feed",
31 "mapper": {
32 "url": "https://orders.example.com/api/v1/pending",
33 "method": "GET",
34 "headers": [{
35 "name": "Accept",
36 "value": "application/json",
37 }],
38 "parseResponse": True,
39 },
40 "metadata": { "designer": {
41 "x": 0,
42 "y": 0,
43 } },
44 },
45 {
46 "id": 2,
47 "module": "builtin:BasicFeeder",
48 "version": 1,
49 "description": "Iterate Pending Order Items",
50 "mapper": { "array": "{{1.data.items}}" },
51 "metadata": { "designer": {
52 "x": 300,
53 "y": 0,
54 } },
55 },
56 {
57 "id": 3,
58 "module": "util:SetVariable2",
59 "version": 1,
60 "description": "Stamp Sync Date",
61 "filter": {
62 "name": "Only Active Orders",
63 "conditions": [[{
64 "a": "{{2.status}}",
65 "o": "TEXT_EQUAL",
66 "b": "active",
67 }]],
68 },
69 "mapper": {
70 "name": "syncedDate",
71 "value": "{{formatDate(now; \"YYYY-MM-DD\")}}",
72 },
73 "metadata": { "designer": {
74 "x": 600,
75 "y": 0,
76 } },
77 },
78 {
79 "id": 4,
80 "module": "airtable:ActionCreateRecord",
81 "version": 3,
82 "description": "Create Airtable Order Record",
83 "mapper": {
84 "base": "appOrderBase001",
85 "table": "Orders",
86 "fields": {
87 "ExternalId": "{{2.id}}",
88 "CustomerName": "{{ifempty(2.name; \"Unknown\")}}",
89 "SyncedOn": "{{3.syncedDate}}",
90 },
91 },
92 "metadata": { "designer": {
93 "x": 900,
94 "y": 0,
95 } },
96 },
97 {
98 "id": 5,
99 "module": "builtin:BasicAggregator",
100 "version": 1,
101 "description": "Aggregate Created Airtable Records",
102 "parameters": { "sourceModule": 2 },
103 "mapper": {
104 "externalId": "{{2.id}}",
105 "airtableId": "{{4.id}}",
106 },
107 "metadata": { "designer": {
108 "x": 1200,
109 "y": 0,
110 } },
111 },
112 {
113 "id": 6,
114 "module": "slack:ActionPostMessage",
115 "version": 1,
116 "description": "Post Hourly Batch Summary",
117 "mapper": {
118 "channel": "#ops-sync",
119 "text": "Synced {{length(5.array)}} active orders to Airtable on {{formatDate(now; \"YYYY-MM-DD\")}}",
120 },
121 "metadata": { "designer": {
122 "x": 1500,
123 "y": 0,
124 } },
125 },
126 ],
127 } }],
128 "monthlyRuns": 1000,
129}
130
131
132run = client.actor("bodacious_mistral/make-to-cloudflare-analyzer").call(run_input=run_input)
133
134
135print(f"💾 Check your data here: https://console.apify.com/storage/datasets/{run.default_dataset_id}")
136for item in client.dataset(run.default_dataset_id).iterate_items():
137 print(item)
138
139