Learn how to build, run, and inspect Actors on your own machine with the local Actor runtime.
The runtime is a single container that emulates the parts of the Apify platform the development loop needs. You use the same Apify CLI commands as against the platform, but builds and runs happen on your computer and no platform compute is used. It is a development tool, not a place to host Actors.
-
Install a container engine. Docker or Podman, running. The CLI takes the first one on your
PATH; setAPIFY_CONTAINER_ENGINE=podmanto choose. -
Install the Apify CLI from the
runtimechannel. Theapify runtimecommands are still in preview:npm install -g apify-cli@runtime apify --versionThe version must read
1.10.1-runtime.x ... installed via npm.
It reports an older version, or Error: Command runtime not found
Your shell is resolving a different apify. The bundle installer puts one in ~/.local/bin and Homebrew in its own prefix; npm install -g replaces neither. Run hash -r, or open a new terminal. which -a apify shows which copy wins.
A local install avoids the clash and leaves your stable apify alone:
npm install apify-cli@runtime
./node_modules/.bin/apify --version
apify runtime install
apify runtime start --detach
install pulls apify/actor-runtime:latest, or a tag you name. start publishes the API on port 3333 and the console on port 3000, and keeps data in ~/.apify/actor-runtime/data unless --data-dir says otherwise.
Both ports and the container name are fixed, so only one runtime runs at a time. It serves as many Actors as you like.
apify runtime status
It prints the image, data directory, ports, and which API your CLI talks to, and exits 1 when the runtime is down.
apify runtime connect
Every Apify CLI command now goes to the runtime, in every terminal, until apify runtime disconnect. Your login is untouched.
The setting is global to your machine - there is no per-project scope and no named profiles. To aim a single shell instead, set these, which take precedence over connect:
export APIFY_CLIENT_BASE_URL=http://localhost:3333
export APIFY_CONSOLE_URL=http://localhost:3000
If you are not logged in already, any non-empty token will do - the runtime does not check it against a real account:
apify login --token local-dev-token
No Actor yet? Create one with apify create, or use sample_actor_ts from this repository.
-
Navigate to your Actor directory:
cd your-actor-name -
Push the Actor:
apify pushThe first build takes about a minute; later ones reuse the engine's layer cache. Pushing unmodified source again is refused - use
apify push --force. -
Compile the Actor, if your language needs it:
npm install && npm run buildSkip this only for Python and plain JavaScript. Your push registered this directory as the Actor's dev folder, and runs mount it over the built image, hiding the
dist/the build produced. Without a localdist/, the first run fails withCannot find module '/usr/src/app/dist/main.js'. -
Run the Actor:
apify callPass input with
--input '{"key": "value"}', or--input-file input.jsonto read it from a JSON file. The CLI streams the log and prints the run's storage ids.
Lines the runtime itself wrote carry a blue [actor-runtime] prefix. Your Actor's output is passed through untouched.
apify runstill executes your Actor as a plain local process, with no container around it. Useapify callfor anything that should behave like the platform.
Open the console at http://localhost:3000, or use the ids apify call printed:
| Command | Shows |
|---|---|
apify runs ls |
Every run of the Actor |
apify runs log <runId> |
The run log |
apify datasets info <datasetId> |
Dataset metadata, including item count |
apify datasets get-items <datasetId> --format json |
Dataset items |
apify api v2/key-value-stores/<storeId>/records/OUTPUT |
One key-value store record |
apify api reaches every endpoint the runtime implements. The raw files are in the data directory - read them freely, but change state through the API.
Your first apify push registers the pushed directory as the Actor's dev folder, and every later run mounts it over the built image. Edit, recompile locally, and call again - no push, no build:
npm run build
apify call
- Edits apply to the next run, not one already in progress.
node_modulescomes from the built image, so a change topackage.jsonorrequirements.txtneedsapify push --force.apify call --no-dev-folderruns from the built image alone, once, leaving the registration in place.- Register another folder with
apify api POST /actor-runtime/dev-folder/<actorId> --body '"/abs/path"', or clear it with--body '""'. The Actor's console page has the same field.
The path is resolved on the machine your container engine runs on, which under podman machine or Docker Desktop is not your own filesystem.
- Stop:
apify runtime stop, or Ctrl+C if you started it in the foreground. - Keep your data: start again with the same data directory.
- Read the runtime's own reference for IDE debugging, browser view, migration testing, and platform fallback:
apify runtime skill, orapify runtime skill --installto install it as an Agent Skill. A running runtime also serves it athttp://localhost:3333/actor-runtime/skill. - For every CLI command, see the command reference.
- For the runtime's exact behaviour, see
requirements/*.mdin this repository.