Actor

An Apify Actor is a serverless cloud program that runs on the Apify platform inside an isolated Docker container. Actors accept JSON input, perform a task — such as web scraping, data processing, browser automation, or serving an API — and output structured data to a Dataset or Key-Value Store. Think of an actor as a self-contained microservice you can run on demand without provisioning servers, managing infrastructure, or worrying about scaling. Each actor has versioned builds (immutable Docker images), an input schema that auto-generates a web UI form, and optionally a dataset schema that validates output format. Actors matter because they are the fundamental building block of the Apify ecosystem. Whether you are scraping product prices from e-commerce sites, monitoring competitor content, extracting leads from social media, or building AI agent tooling with MCP servers, everything on Apify runs as an actor. There are over 19,000 actors published on the Apify Store, and developers earn 80% of revenue from paid actors through the PPE (Pay Per Event) pricing model. For users, actors provide a no-code way to run complex scraping and automation tasks — just fill in the input form and click Start. To create and deploy an actor, install the Apify CLI with npm install -g apify-cli, then run apify create my-actor to scaffold a new project. The generated project includes a src/main.js entry point, a Dockerfile, and an .actor/actor.json configuration file. Write your logic inside Actor.main(async () => { ... }), which handles initialization and cleanup automatically. Push your actor to the platform with apify push, which triggers a Docker build on Apify's servers. Once built, you can run it from the Console, via the REST API at POST /v2/acts/{actorId}/runs, or from another actor using Actor.call('username/actor-name', input). Here is a minimal actor example as text: import { Actor } from 'apify'; Actor.main(async () => { const input = await Actor.getInput(); const { url } = input; const response = await fetch(url); const data = await response.json(); await Actor.pushData(data); }); This actor reads a URL from its input, fetches JSON from that URL, and pushes the result to the default dataset. Common mistakes when building actors include using Actor.init() and Actor.exit() instead of Actor.main() — always use Actor.main() as it handles the lifecycle correctly. Another frequent error is not defining an input schema, which means users see a raw JSON editor instead of a friendly form, dramatically reducing adoption. Forgetting to set memory allocation appropriately is also common: CheerioCrawler actors run fine on 256-512 MB, but PlaywrightCrawler actors need 1-4 GB. Setting memory too low causes out-of-memory crashes; setting it too high wastes compute units. Use actors when you need a managed, scalable execution environment for any task that can be containerized. If you need a simple one-off script, a local Node.js process may suffice. But if you need scheduling (run every hour), persistence (resume after crashes), proxy rotation, automatic retries, or a public API endpoint, actors are the right choice. For always-on services like MCP servers or webhook processors, combine actors with Standby Mode. Actors integrate with the broader Apify ecosystem: they read input from the Input Schema, write output to Datasets and Key-Value Stores, manage crawl state with Request Queues, rotate IPs with Apify Proxy, and trigger downstream workflows via Webhooks. The Apify Store provides discovery and monetization — publish your actor, set PPE pricing, and earn revenue every time someone uses it. Related concepts: PPE, Dataset, Input Schema, Actor Build, Actor Run, Compute Unit.

Related Terms