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
+22-51Lines changed: 22 additions & 51 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,36 @@ 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();
92
-
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
-
}
100
-
101
-
awaitActor.init();
102
-
103
-
constmain=async () => {
104
-
awaitchargeForActorStart();
86
+
### Use synthetic start event `apify-actor-start`
105
87
106
-
// Rest of the Actor logic
107
-
};
88
+
This event is automatically charged by the Apify platform when an Actor is started or resurrected.
108
89
109
-
awaitmain();
90
+
Users of your Actor are charged one event for each GB of memory used by the Actor (at least one event per run). We _strongly_ suggest setting the price of this event to $0.0001 to remain competitive in the Store and attractive for your customers. If you define this event, you also save 5 seconds of Actor runtime from each Actor run, which won't be deducted from your payout profits.
110
91
111
-
awaitActor.exit();
112
-
```
92
+
:::note Automatic charging of synthetic start event
113
93
114
-
</TabItem>
115
-
<TabItemvalue="Python"label="Python">
94
+
You must _not_ manually charge for the synthetic start event (`apify-actor-start`) in your Actor code.
116
95
117
-
```py
118
-
from apify importActor
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.
119
98
120
-
asyncdefcharge_for_actor_start():
121
-
charging_manager = Actor.get_charging_manager()
99
+
:::
122
100
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")
101
+
#### Synthetic start event for new Actors
126
102
127
-
asyncdefmain():
128
-
await Actor.init()
129
-
130
-
await charge_for_actor_start()
103
+
For new Actors, this event is added automatically as you can see on the following screen:
131
104
132
-
# Rest of the Actor logic
105
+

133
106
134
-
await Actor.exit()
135
-
```
107
+
#### Synthetic start event for existing Actors
136
108
137
-
</TabItem>
138
-
</Tabs>
109
+
If you have existing Actors, you can add this event manually in Apify Console.
139
110
140
-
:::note Actor migrations and charging
111
+
#### Synthetic start event for Actors with start event
141
112
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.
113
+
Your Actor might already have a start event defined, such as `actor-start` or another variant of the event name. In this case, you can choose whether to use the synthetic start event or keep the existing start event.
143
114
144
-
:::
115
+
If you want to use the synthetic start event, remove the existing start event from your Actor and add the synthetic start event in Apify Console.
0 commit comments