You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: sources/platform/actors/publishing/monetize/pay_per_event.mdx
+19-54Lines changed: 19 additions & 54 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -18,6 +18,12 @@ PPE lets you define pricing for individual events. You can charge for specific e
18
18
19
19
The details on how your cost is computed can be found in [Example of a PPE pricing model](#example-of-a-ppe-pricing-model).
20
20
21
+
:::tip Additional benefits
22
+
23
+
Actors that implement PPE pricing receive additional benefits, including increased visibility in Apify Store and enhanced discoverability for users looking for monetized solutions.
24
+
25
+
:::
26
+
21
27
## How is profit computed
22
28
23
29
Your profit is calculated from the mentioned formula:
@@ -77,71 +83,30 @@ When using browser automation tools like Puppeteer or Playwright for web scrapin
77
83
78
84
:::
79
85
80
-
### Charge for `Actor start`
81
-
82
-
Charge for `Actor start` to prevent users from running your Actor for free.
83
-
84
-
<TabsgroupId="main">
85
-
<TabItemvalue="JavaScript"label="JavaScript">
86
-
87
-
```js
88
-
import { Actor } from'apify';
89
-
90
-
constchargeForActorStart=async () => {
91
-
constchargingManager=Actor.getChargingManager();
86
+
### Use synthetic start event `apify-actor-start`
92
87
93
-
// Don't charge the "Actor start" event again after Actor migration
94
-
if (chargingManager.getChargedEventCount("actor-start") ===0) {
95
-
awaitActor.charge({
96
-
"eventName":"actor-start",
97
-
});
98
-
}
99
-
}
88
+
This event is automatically charged by the Apify platform when an Actor is started or resurrected.
100
89
101
-
awaitActor.init();
90
+
You are charged one event for each GB of memory used by the Actor (at least one event per run). This also saves you the cost of 5 seconds of Actor runtime.
102
91
103
-
constmain=async () => {
104
-
awaitchargeForActorStart();
92
+
:::note Automatic charging of synthetic start event
105
93
106
-
// Rest of the Actor logic
107
-
};
94
+
You do **not** need to manually charge for the synthetic start event (`apify-actor-start`) in your Actor code.
108
95
109
-
awaitmain();
96
+
If you attempt to charge this event yourself, the operation will fail.
97
+
This event is **always** charged automatically by the Apify platform whenever your Actor starts or is resurrected.
110
98
111
-
awaitActor.exit();
112
-
```
113
-
114
-
</TabItem>
115
-
<TabItemvalue="Python"label="Python">
116
-
117
-
```py
118
-
from apify import Actor
119
-
120
-
asyncdefcharge_for_actor_start():
121
-
charging_manager = Actor.get_charging_manager()
122
-
123
-
# Don't charge the "Actor start" event again after Actor migration
124
-
if charging_manager.get_charged_event_count("actor-start") ==0:
125
-
await Actor.charge(event_name="actor-start")
126
-
127
-
asyncdefmain():
128
-
await Actor.init()
129
-
130
-
await charge_for_actor_start()
131
-
132
-
# Rest of the Actor logic
99
+
:::
133
100
134
-
await Actor.exit()
135
-
```
101
+
#### Synthetic start event for new Actors
136
102
137
-
</TabItem>
138
-
</Tabs>
103
+
For new Actors, this event is added automatically as you can see on the following screen:
139
104
140
-
:::note Actor migrations and charging
105
+

141
106
142
-
Actors can migrate between servers during execution, which restarts the process and clears memory. When using PPE pricing model, avoid charging the start event multiple times after a migration by checking your charging state.
107
+
#### Synthetic start event for existing Actors
143
108
144
-
:::
109
+
If you have existing Actors, you can add this event manually in the Apify Console.
0 commit comments