On macOS (or Linux), you can install the Apify CLI via the Homebrew package manager.
brew install apify/tap/apify-cli
First, make sure you have Node.js version 16 or higher with NPM installed on your computer:
Install or upgrade Apify CLI by running:
npm -g install apify-cli
If you receive an
EACCES error, you might need to run the command as root:
sudo npm -g install apify-cli
Alternativaly, you can use Node Version Manager (nvm) and install Apify CLI only into a selected user-level Node version without requiring root privileges:
nvm install 16
nvm use 16
npm -g install apify-cli
Finally, verify that Apify CLI was installed correctly by running:
which should print something like:
apify-cli/0.10.0 darwin-x64 node-v16.14.2
The following examples demonstrate the basic usage of Apify CLI.
Create a new actor from scratch
apify create my-hello-world
First, you will be prompted to select a template with the boilerplate for the actor, to help you get started quickly.
The command will create a directory called
my-hello-world that contains a Node.js project
for the actor and a few configuration files.
Create a new actor from existing project
This command will only set up local actor development environment in an existing directory,
i.e. it will create the
.actor/actor.json file and
Before you can run your project locally using
apify run, you have to set up the right start command in
package.json under scripts.start. For example:
"start": "node your_main_file.js",
You can find more information about by running
apify help run.
Run the actor locally
This command runs the actor on your local machine. Now's your chance to develop the logic - or magic 😏
Login with your Apify account
Before you can interact with the Apify cloud, you need to create an Apify account
and log in to it using the above command. You will be prompted for
your Apify API token.
Note that the command will store the API token and other sensitive information to
Push the actor to the Apify cloud
This command uploads your project to the Apify cloud and builds an actor from it. On the platform, actor needs to be built before it can be run.
Run an actor on the Apify cloud
Runs the actor corresponding to the current directory on the Apify platform.
This command can also be used to run other actors, for example:
apify call apify/hello-world
So what's in this
This file associates your local development project with an actor on the Apify platform. It contains information such as actor name, version, build tag and environment variables. Make sure you commit this file to the Git repository.
.actor/actor.json file can look as follows:
If you specify the path to your Docker file under the
dockerfile field, this file will be used for actor builds on the platform. If not specified, the system will look for Docker files at
Dockerfile in this order of preference.
If you specify the path to your readme file under the
readme field, the readme at this path will be used on the platform. If not specified, readme at
README.md will be used in this order of preference.
You can embed your input schema object directly in
input field. Alternatively, you can provide a path to a custom input schema. If not provided, the input schema at
INPUT_SCHEMA.json is used in this order of preference.
You can define the schema of the items in your dataset under the
storages.dataset field. This can be either an embedded object or a path to a JSON schema file. You can read more about the schema of your actor output here.
Note on migration from deprecated config "apify.json"
Note that previously, actor config was stored in the
apify.json file that has been deprecated. You can find the (very slight) differences and migration info in migration guidelines.