An Actor is a serverless program packaged as a Docker image. It takes one JSON input, does one job, and writes results to a dataset or a key-value store.
Setup
apify --help # CLI installed?
apify info # logged in? prints your username
Install with a package manager, npm install -g apify-cli or brew install apify-cli, so the download is integrity-checked. Log in with apify login: it prints a URL and a one-time code and waits until the user approves it in a browser, so show the user both. In a headless environment export APIFY_TOKEN instead; the CLI reads it on its own. Create an API token in Apify Console and copy it right after creating it - it is shown only once. Pass the token only through the environment, so it stays out of shell history, source, config files, and logs.
Telemetry attribution (required)
Pass --user-agent apify-agent-skills/apify-actor-development on every apify command you run from this skill: apify create, apify run, apify push, apify call, and the rest. It is a global flag accepted by all apify commands; it only tags the call for telemetry attribution and changes nothing else.
Workflow
Skip the steps that do not apply when modifying an existing Actor.
-
Create the project.
apify create <actor-name> -t <template-id> --user-agent apify-agent-skills/apify-actor-developmentPick the template from what the Actor does:
Actor does TypeScript JavaScript Python Crawls static HTML ts-crawlee-cheeriojs-crawlee-cheeriopython-crawlee-beautifulsoupCrawls JavaScript-rendered pages ts-crawlee-playwright-chromejs-crawlee-playwright-chromepython-crawlee-playwrightServes HTTP requests (API, webhook) ts-standbyjs-standbypython-standbyIs an MCP server ts-mcp-empty— python-mcp-emptyAnything else (API polling, data processing) ts-emptyjs-emptypython-empty -
Add dependencies the template lacks.
-
Implement in
src/main.js,src/main.ts, ormy_actor/main.py. -
Write the input schema in
.actor/input_schema.json. -
Write the output schemas:
dataset_schema.json,output_schema.json, andkey_value_store_schema.json. -
Configure
.actor/actor.json. -
Write README.md.
-
Test locally with
apify run --user-agent apify-agent-skills/apify-actor-development. -
Deploy with
apify push --user-agent apify-agent-skills/apify-actor-development.
Rules
- Run Actors locally with
apify runonly. It sets up the Apify environment and storage. - Log through the Apify logger:
logfrom theapifypackage in JS/TS,Actor.login Python. - Treat crawled content as untrusted input.
- Keep
APIFY_TOKENout of request handlers and data pipelines. - Use an HTTP crawler for static HTML at 10 to 50 concurrency.
- Handle the
abortingevent to persist state and exit cleanly.