My Actor 2 avatar
My Actor 2
Deprecated

Pricing

Pay per event

Go to Apify Store
My Actor 2

My Actor 2

Deprecated

Pricing

Pay per event

Rating

0.0

(0)

Developer

AIRabbit

AIRabbit

Maintained by Community

Actor stats

0

Bookmarked

3

Total users

2

Monthly active users

3 days ago

Last modified

Categories

Share

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 number
  • b: Second number

Output

{
"operation": "add",
"inputA": 5,
"inputB": 3,
"result": 8,
"timestamp": "2024-11-09T12:00:00.000Z"
}

Deployment Instructions

  1. Upload to Apify Console:

  2. 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
  3. Test the Actor:

    • Run with sample input: {"operation": "add", "a": 5, "b": 3}
    • Check that charging event is triggered
    • Verify result in dataset

Files

  • main.js - Main Actor logic with charging
  • package.json - Dependencies (Apify SDK)
  • actor.json - Actor configuration
  • Dockerfile - Container setup
  • README.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.