Skip to content

Commit bbe2038

Browse files
patrikbraborecvladfranguTC-MO
authored
docs: Update cli docs (#880)
Co-authored-by: Vlad Frangu <[email protected]> Co-authored-by: Michał Olender <[email protected]>
1 parent f2ded90 commit bbe2038

File tree

8 files changed

+188
-209
lines changed

8 files changed

+188
-209
lines changed

docs/index.md

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
title: Apify CLI
2+
title: Overview
33
---
44

55
Apify command-line interface (Apify CLI) helps you create, develop, build and run
@@ -14,6 +14,10 @@ using <a href="https://github.com/apify/apify-sdk-js">Apify SDK</a>
1414
and only push the Actors to the Apify cloud during deployment.
1515
This is where the Apify CLI comes in.
1616

17-
Note that Actors running on the Apify platform are executed in Docker containers, so with an appropriate `Dockerfile`
17+
:::note Run Actors in Docker
18+
19+
Actors running on the Apify platform are executed in Docker containers, so with an appropriate `Dockerfile`
1820
you can build your Actors in any programming language.
19-
However, we recommend using JavaScript / Node.js, for which we provide most libraries and support.
21+
However, we recommend using JavaScript/Node.js and Python, for which we provide most libraries and support.
22+
23+
:::

docs/installation.md

Lines changed: 31 additions & 153 deletions
Original file line numberDiff line numberDiff line change
@@ -1,189 +1,67 @@
11
---
22
title: Installation
3-
description: Learn how to install Apify CLI, and how to create, run, and manage Actors through it.
4-
sidebar_label: Installation
3+
description: Learn how to install Apify CLI using installation scripts, Homebrew, or NPM.
54
---
65

7-
## Installation
6+
Learn how to install Apify CLI using installation scripts, Homebrew, or NPM.
87

9-
You can install Apify CLI either using [Homebrew package manager](https://brew.sh) on macOS or Linux or using NPM on all platforms including Windows.
10-
11-
### Via Homebrew
12-
13-
Run the following command:
14-
15-
```bash showLineNumbers
16-
brew install apify-cli
17-
```
18-
19-
### Via NPM
20-
21-
First, make sure you have [Node.js](https://nodejs.org) version 18 or higher with NPM installed on your computer:
22-
23-
```bash showLineNumbers
24-
node --version
25-
npm --version
26-
```
27-
28-
Install or upgrade Apify CLI by running:
29-
30-
```bash showLineNumbers
31-
npm -g install apify-cli
32-
```
33-
34-
If you receive a permission error, read npm's [official guide](https://docs.npmjs.com/resolving-eacces-permissions-errors-when-installing-packages-globally) on installing packages globally.
8+
---
359

36-
Alternatively, you can use [Node Version Manager (nvm)](https://github.com/nvm-sh/nvm) and install Apify CLI only into a selected user-level Node version without requiring root privileges:
10+
The recommended way to install Apify CLI is by using our installation scripts. This means you don't need to install Node.js to use the CLI, which is useful for Python users or anyone who doesn't want to manage Node.js dependencies.
3711

38-
```bash showLineNumbers
39-
nvm install 18
40-
nvm use 18
41-
npm -g install apify-cli
42-
```
12+
## Preferred methods
4313

44-
After using either of these methods , verify that Apify CLI was installed correctly by running:
14+
### MacOS / Unix
4515

46-
```bash showLineNumbers
47-
apify --version
16+
```bash
17+
curl -fsSL https://apify.com/install-cli.sh | bash
4818
```
4919

50-
which should print something like:
20+
### Windows
5121

52-
```bash showLineNumbers
53-
apify-cli/0.19.1 linux-x64 node-v18.17.0
22+
```powershell
23+
irm https://apify.com/install-cli.ps1 | iex
5424
```
5525

56-
## Basic Usage
57-
58-
The following examples demonstrate the basic usage of Apify CLI.
26+
## Other methods
5927

60-
### Create a New Actor from Scratch
28+
### Homebrew
6129

62-
```bash showLineNumbers
63-
apify create my-hello-world
30+
```bash
31+
brew install apify-cli
6432
```
6533

66-
First, you will be prompted to select a template with the boilerplate for the Actor, to help you get started quickly.
67-
The command will create a directory called `my-hello-world` that contains a Node.js project
68-
for the Actor and a few configuration files.
34+
### NPM
6935

70-
### Create a New Actor from Existing Project
71-
72-
:::tip Automatic Actor directory initialization
73-
When you create an Actor using the `apify create` command, the directory will already be initialized.
74-
:::
36+
First, make sure you have [Node.js](https://nodejs.org) version 22 or higher with NPM installed on your computer:
7537

7638
```bash showLineNumbers
77-
cd ./my/awesome/project
78-
apify init
79-
```
80-
81-
This command will only set up local Actor development environment in an existing directory,
82-
i.e. it will create the `.actor/actor.json` file and `apify_storage` directory.
83-
84-
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:
85-
86-
```json showLineNumbers
87-
{
88-
...
89-
"scripts": {
90-
"start": "node your_main_file.js",
91-
},
92-
...
93-
}
39+
node --version
40+
npm --version
9441
```
9542

96-
You can find more information about by running `apify help run`.
97-
98-
### Run the Actor Locally
43+
Install or upgrade Apify CLI by running:
9944

100-
```bash showLineNumbers
101-
cd my-hello-world
102-
apify run
45+
```bash
46+
npm install -g apify-cli
10347
```
10448

105-
This command runs the Actor on your local machine.
106-
Now's your chance to develop the logic - or magic :smirk:
107-
108-
### Login with your Apify account
49+
:::tip Troubleshooting
10950

110-
```bash showLineNumbers
111-
apify login
112-
```
113-
114-
Before you can interact with the Apify cloud, you need to [create an Apify account](https://console.apify.com/)
115-
and log in to it using the above command. You will be prompted for
116-
your [Apify API token](https://console.apify.com/settings/integrations).
51+
If you receive a permission error, read npm's [official guide](https://docs.npmjs.com/resolving-eacces-permissions-errors-when-installing-packages-globally) on installing packages globally.
11752

118-
:::note API token save directory
119-
The command will store the API token and other sensitive information to `~/.apify`.
12053
:::
12154

122-
### Push the Actor to the Apify Cloud
123-
124-
```bash showLineNumbers
125-
apify push
126-
```
127-
128-
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.
55+
## Verify installation
12956

130-
### Run an Actor on the Apify Cloud
57+
You can verify the installation process by running the following command:
13158

132-
```bash showLineNumbers
133-
apify call
59+
```bash
60+
apify --version
13461
```
13562

136-
Runs the Actor corresponding to the current directory on the Apify Platform.
137-
138-
This command can also be used to run other Actors, for example:
139-
140-
```bash showLineNumbers
141-
apify call apify/hello-world
142-
```
63+
The output should resemble the following (exact details like version or platform may vary):
14364

144-
### So what's in this `.actor/actor.json` File?
145-
146-
This file associates your local development project with an Actor on the Apify Platform.
147-
It contains information such as Actor name, version, build tag and environment variables.
148-
Make sure you commit this file to the Git repository.
149-
150-
For example, `.actor/actor.json` file can look as follows:
151-
152-
```json showLineNumbers
153-
{
154-
"actorSpecification": 1,
155-
"name": "name-of-my-scraper",
156-
"version": "0.0",
157-
"buildTag": "latest",
158-
"environmentVariables": {
159-
"MYSQL_USER": "my_username",
160-
"MYSQL_PASSWORD": "@mySecretPassword"
161-
},
162-
"dockerfile": "./Dockerfile",
163-
"readme": "./ACTOR.md",
164-
"input": "./input_schema.json",
165-
"storages": {
166-
"dataset": "./dataset_schema.json"
167-
}
168-
}
65+
```bash
66+
apify-cli/1.0.1 (0dfcfd8) running on darwin-arm64 with bun-1.2.19 (emulating node 24.3.0), installed via bundle
16967
```
170-
171-
**`Dockerfile` field**
172-
173-
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 `.actor/Dockerfile` and `Dockerfile` in this order of preference.
174-
175-
**`Readme` field**
176-
177-
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 `.actor/README.md` and `README.md` will be used in this order of preference.
178-
179-
**`Input` field**
180-
181-
You can embed your [input schema](https://docs.apify.com/actors/development/input-schema#specification-version-1) object directly in `actor.json` under `input` field. Alternatively, you can provide a path to a custom input schema. If not provided, the input schema at `.actor/INPUT_SCHEMA.json` and `INPUT_SCHEMA.json` is used in this order of preference.
182-
183-
**`Storages.dataset` field**
184-
185-
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](https://docs.apify.com/actors/development/output-schema#specification-version-1).
186-
187-
:::note Migration from deprecated config "apify.json"
188-
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](https://github.com/apify/apify-cli/blob/master/MIGRATIONS.md).
189-
:::

docs/integrating-scrapy.md

Lines changed: 12 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -6,29 +6,15 @@ sidebar_label: Integrating Scrapy projects
66

77
[Scrapy](https://scrapy.org/) is a widely used open-source web scraping framework for Python. Scrapy projects can now be executed on the Apify platform using our dedicated wrapping tool. This tool allows users to transform their Scrapy projects into [Apify Actors](https://docs.apify.com/platform/actors) with just a few simple commands.
88

9-
## Getting started
9+
## Prerequisites
1010

11-
### Install Apify CLI
12-
13-
To run the migration tool, you need to have the Apify CLI installed. You can install it using Homebrew with the following command:
14-
15-
```bash showLineNumbers
16-
brew install apify-cli
17-
```
18-
19-
Alternatively, you can install it using NPM with the following command:
20-
21-
```bash showLineNumbers
22-
npm i -g apify-cli
23-
```
24-
25-
In case of any issues, please refer to the [installation guide](./installation.md).
11+
Before you begin, make sure you have the Apify CLI installed on your system. If you haven't installed it yet, follow the [installation guide](./installation.md).
2612

2713
## Actorization of your existing Scrapy spider
2814

2915
Assuming your Scrapy project is set up, navigate to the project root where the `scrapy.cfg` file is located.
3016

31-
```bash showLineNumbers
17+
```bash
3218
cd your_scraper
3319
```
3420

@@ -48,7 +34,7 @@ your_spider.py __init__.py
4834

4935
To convert your Scrapy project into an Apify Actor, initiate the wrapping process by executing the following command:
5036

51-
```bash showLineNumbers
37+
```bash
5238
apify init
5339
```
5440

@@ -70,25 +56,25 @@ For example, here is a [source code](https://github.com/apify/actor-scrapy-books
7056

7157
Create a Python virtual environment by running:
7258

73-
```bash showLineNumbers
59+
```bash
7460
python -m virtualenv .venv
7561
```
7662

7763
Activate the virtual environment:
7864

79-
```bash showLineNumbers
65+
```bash
8066
source .venv/bin/activate
8167
```
8268

8369
Install Python dependencies using the provided requirements file named `requirements_apify.txt`. Ensure these requirements are installed before executing your project as an Apify Actor locally. You can put your own dependencies there as well.
8470

85-
```bash showLineNumbers
71+
```bash
8672
pip install -r requirements-apify.txt [-r requirements.txt]
8773
```
8874

8975
Finally execute the Apify Actor.
9076

91-
```bash showLineNumbers
77+
```bash
9278
apify run [--purge]
9379
```
9480

@@ -98,7 +84,7 @@ If [ActorDatasetPushPipeline](https://github.com/apify/apify-sdk-python/blob/mas
9884

9985
The project remains executable as a Scrapy project.
10086

101-
```bash showLineNumbers
87+
```bash
10288
scrapy crawl your_spider -o books.json
10389
```
10490

@@ -108,15 +94,15 @@ scrapy crawl your_spider -o books.json
10894

10995
You will need to provide your [Apify API Token](https://console.apify.com/settings/integrations) to complete this action.
11096

111-
```bash showLineNumbers
97+
```bash
11298
apify login
11399
```
114100

115101
### Deploy your Actor
116102

117103
This command will deploy and build the Actor on the Apify platform. You can find your newly created Actor under [Actors -> My Actors](https://console.apify.com/actors?tab=my).
118104

119-
```bash showLineNumbers
105+
```bash
120106
apify push
121107
```
122108

@@ -166,9 +152,8 @@ it is recommended to use Apify's instance of the nested event loop. Refer to the
166152
inspiration from Apify's Scrapy components, such as the
167153
[ApifyScheduler](https://github.com/apify/apify-sdk-python/blob/v1.5.0/src/apify/scrapy/scheduler.py#L114).
168154

169-
```python showLineNumbers
155+
```python
170156
from apify.scrapy.utils import nested_event_loop
171-
172157
...
173158

174159
# Coroutine execution inside a spider

0 commit comments

Comments
 (0)