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.mdx
+7-5
Original file line number
Diff line number
Diff line change
@@ -79,8 +79,9 @@ Your profit is computed only from the first two users, since they are on Apify p
79
79
To ensure profitable operation:
80
80
81
81
- Set memory limits in your [`actor.json`](https://docs.apify.com/platform/actors/development/actor-definition/actor-json) file to control platform usage costs
82
-
- Implement the `ACTOR_MAX_PAID_DATASET_ITEMS` check to prevent excess result generation
82
+
- Implement the `ACTOR_MAX_PAID_DATASET_ITEMS` check to prevent excess result generation. You can copy [this simple solution](https://github.com/metalwarrior665/max-paid-items-example/blob/master/src/push-data.ts).
83
83
- Test your Actor with various result volumes to determine optimal pricing
84
+
- Push at least one "error item" to the dataset for invalid input or if search query didn't generate any result. This will prevent users running your Actor for free.
84
85
85
86
### Pay-per-event pricing model
86
87
@@ -119,9 +120,10 @@ Only paid user activity is included in profit calculations.
119
120
#### Best practices for PPE Actors
120
121
121
122
- Set memory limits in your [`actor.json`](/platform/actors/development/actor-definition/actor-json) file to control platform usage costs
122
-
- Avoid duplicate charges by not calling the start Actor event during migration.
123
-
- Ensure users are not charged beyond their set maximum. The [`ChargingManager`](https://github.com/metalwarrior665/actor-charge-manager-poc) or our SDKs ([JS](/sdk/js/reference/class/ChargingManager) and [Python](/sdk/python/reference/class/ChargingManager)) can handle this logic.
124
-
- Use idempotency keys in API calls to prevent double charges.
123
+
- Charge either for "Actor start" or for invalid input or empty search to prevent users from running your Actor for free.
124
+
- Don't charge the "Actor start" event again after Actor migration (check `ChargingManager` state).
125
+
- Finish the Actor run once charging reaches user-configured `Maximum cost per run`. Apify SDKs ([JS](/sdk/js/reference/class/Actor#charge) and [Python](/sdk/python/reference/class/Actor#charge)) return `ChargeResult` that helps determine when to finish.
126
+
- If you are not using the SDKs, use idempotency keys in API calls to prevent double charges.
125
127
- Try to limit the number of events. Fewer events make it easier for users to understand your pricing.
126
128
- Try to make your event have tangible artifacts that users can see and understand (this might not be possible when using external APIs) i.e:
127
129
- Get a record
@@ -130,7 +132,7 @@ Only paid user activity is included in profit calculations.
130
132
131
133
:::note `ChargingManager` usage
132
134
133
-
Use our [`ChargingManager`](https://github.com/metalwarrior665/actor-charge-manager-poc) or SDKs ([JS](/sdk/js/reference/class/ChargingManager) and, [Python](/sdk/python/reference/class/ChargingManager) or use [`apify actor charge`](/cli/docs/next/reference#apify-actor-charge-eventname) when using our Apify CLI) to simplify PPE implementation into your Actor. This tool can handle pricing, usage tracking, idempotency keys, API errors, and, event charging via an API.
135
+
Use our SDKs ([JS](/sdk/js/reference/class/ChargingManager) and, [Python](/sdk/python/reference/class/ChargingManager) or use [`apify actor charge`](/cli/docs/next/reference#apify-actor-charge-eventname) when using our Apify CLI) to simplify PPE implementation into your Actor. This tool can handle pricing, usage tracking, idempotency keys, API errors, and, event charging via an API.
134
136
135
137
You can also choose not to use it, but then you must handle API integration and possible edge cases manually. You can use `ChargingManager` code as a reference.
0 commit comments