My Actor 2
Pricing
Pay per event
Go to Apify Store
Deprecated
My Actor 2
Calculator Actor - Pay-Per-Event Test
Simple calculator Actor that charges for each math operation to test Apify's pay-per-event system.
Features
- Basic math operations: add, subtract, multiply, divide
- Pay-per-event charging: $0.001 per calculation
- Simple input/output for easy testing
Input
{"operation": "add","a": 5,"b": 3}
Parameters:
operation: "add", "subtract", "multiply", or "divide"a: First numberb: Second number
Output
{"operation": "add","inputA": 5,"inputB": 3,"result": 8,"timestamp": "2024-11-09T12:00:00.000Z"}
Deployment Instructions
-
Upload to Apify Console:
- Go to console.apify.com
- Click "Create Actor"
- Upload all files from this directory
-
Set Pay-Per-Event Pricing:
- Go to Actor settings → Monetization
- Select "Pay per event" pricing model
- Set price for "calculation" event: $0.001
- Save settings
-
Test the Actor:
- Run with sample input:
{"operation": "add", "a": 5, "b": 3} - Check that charging event is triggered
- Verify result in dataset
- Run with sample input:
Files
main.js- Main Actor logic with chargingpackage.json- Dependencies (Apify SDK)actor.json- Actor configurationDockerfile- Container setupREADME.md- This file
Pay-Per-Event Logic
The Actor calls await Actor.charge({ eventName: 'calculation' }) before each math operation, triggering a billable event that you can set pricing for in the Apify Console.
