You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
- How to create and run your first Actor locally using Apify CLI
15
+
- How to understand and configure Actor input, output, and storage
16
+
- How to deploy your Actor to the Apify platform
16
17
17
18
## Prerequisites
18
19
@@ -50,90 +51,107 @@ The Apify CLI will prompt you to:
50
51
51
52
## Step 2: Run your Actor
52
53
53
-
- tbd (see the result as soon as possible)
54
+
After creating your Actor, you can run it with:
54
55
55
-
## Step 3: Explore the Result
56
+
```bash
57
+
apify run
58
+
```
56
59
57
-
- tbd (see the result - AHA moment, I get data)
58
-
- explain the "code"
60
+
:::tip
59
61
60
-
## Step 4: Deploy your Actor
62
+
During development, use `apify run --purge`. This command clears all results from previous runs, so it’s as if you’re running the Actorfor the first time.
61
63
62
-
- tbd
64
+
:::
63
65
64
-
## Step 5: It's time to build!
66
+
This command runs your Actor, and you’ll see output similar to the following in your terminal:
65
67
66
-
- Encourage developers to edit actors, build interesting stuff, etc.
67
-
- Optional...
68
+
```bash
69
+
INFO System info {"apifyVersion":"3.4.3","apifyClientVersion":"2.12.6","crawleeVersion":"3.13.10","osType":"Darwin","nodeVersion":"v22.17.0"}
70
+
Extracted heading { level: 'h1', text: 'Your full‑stack platform for web scraping' }
As you can see in the logs, the Actor extracts text from a web page. All the main logic is defined in`src/main.js`. Depending on the template you chose, this file may also be `src/main.ts` (for TypeScript) or `src/main.py` (for Python).
70
77
71
-
- tbd (deploy)
78
+
In the next step, we’ll explore the results in more detail.
72
79
73
-
<!-- ## Explore the source code in your editor
80
+
## Step 3: Explore the Actor
74
81
75
-
After creating your Actor, explore the source code in your preferred code editor, We'll use the `Crawlee + Puppeteer + Chrome` template code as an example, but all Actor templates follow a similar organizational pattern. The important directories and filer are:
82
+
<!-- TODO: Add more examples -->
76
83
77
-
### `src` Directory
84
+
The following section will explain the Actor in more details.
78
85
79
-
- `src/main.js`: This file contains the actual code of your Actor
86
+
### The `.actor` folder
80
87
81
-
### `.actor` Directory
88
+
The Actor configuration is in the folder `.actor`. The file `actor.json` defines the Actor's configuration, such as name, description, etc. You can find more info in [actor.json](https://docs.apify.com/platform/actors/development/actor-definition/actor-json) definition.
82
89
83
-
- [`actor.json`](https://docs.apify.com/platform/actors/development/actor-definition/actor-json): This file defines the Actor's configuration, such as input and output specifications.
84
-
- [`Dockerfile`](https://docs.apify.com/platform/actors/development/actor-definition/dockerfile): This file contains instructions for building the Docker image for your Actor.
90
+
### Actor's `input`
85
91
86
-
### `storage` Directory
92
+
Each Actor accepts an `input object`, which tells it what it should do. The object is passed in JSON format, and you can find it in`storage/key_value_stores/default/INPUT.json`.
87
93
88
-
- This directory emulates the [Apify Storage](../../../storage/index.md)
To change the `INPUT.json`, edit first the `input_schema.json`in the `.actor` folder.
94
97
95
-
## Run it locally
98
+
This JSON Schema not only validates input automatically (so you don't need to handle input errors in your code), but also powers the Actor's user interface, generates API docs, and enables smart integration with tools like Zapier or Make by auto-linking input fields.
96
99
97
-
To run your Actor locally, use the following command:
100
+
:::
98
101
99
-
```bash
100
-
apify run
101
-
```
102
+
You can find more info in the [Input schema](/platform/actors/development/actor-definition/input-schema) documentation.
102
103
103
-
After executing this command, you will see the Actor's log output in your terminal. The results of the Actor's execution will be stored in the local dataset located in the `storage/datasets/default` directory.
The Actor system provides two specialized storages that can be used by Actors for storing files and results: `key-value` store and `dataset`.
106
107
107
-
:::note Local testing & debugging
108
+
#### Key-value store
108
109
109
-
Running the Actor locally allows you to test and debug your code before deploying it to the Apify platform.
110
+
The key-value store is a simple data storage that is used for saving and reading files or data records.
110
111
111
-
:::
112
+
Key-value stores are ideal for saving things like screenshots, PDFs, or to persist the state of Actors e.g. as a JSON file.
113
+
114
+
#### Dataset
115
+
116
+
The dataset is an append-only storage that allows you to store a series of data objects such as results from web scraping, crawling, or data processing jobs. You or your users can thenexport the dataset to formats such as JSON, CSV, XML, RSS, Excel, or HTML.
117
+
118
+
### Actor's `output`
112
119
113
-
## Deploy it to Apify platform
120
+
While the input object provides a standardized way to invoke Actors, Actors can also generate an output object, which is a standardized way to display, consume, and integrate Actors’ results.
121
+
122
+
You can define how the Actor output looks using the Output schema file. The system uses this information to automatically generate an immutable JSON file, which tells users where to find the results produced by the Actor.
123
+
124
+
## Step 4: Deploy your Actor
114
125
115
-
Once you are satisfied with your Actor, to deploy it to the Apify platform, follow these steps:
126
+
Let's now deploy your Actor to the Apify platform, where you can for example run the Actor on scheduled basis, or you can make the Actor public for other users.
116
127
117
-
1. _Sign in to Apify with the CLI tool_
128
+
1. First of all, you need to login:
118
129
119
130
```bash
120
131
apify login
121
132
```
122
133
123
-
This command will prompt you to provide your API token that you can find in Console.
134
+
:::info
135
+
After you succesfull login, your Apify token is stored in `~/.apify/auth.json`, or `C:\Users\<name>\.apify` based on your system.
136
+
:::
124
137
125
-
1. _Push your Actor to the Apify platform_
138
+
1. Now, you can push your Actor to the Apify platform:
126
139
127
140
```bash
128
141
apify push
129
142
```
130
143
131
-
This command will upload your Actor's code and configuration to the Apify platform, where it can be executed and managed.
144
+
## Step 5: It's time to build!
145
+
146
+
Good job, you have done it! 🎉 From here, you can develop your Actor.
132
147
133
-
:::note Actor monetization
148
+
:::tip Actor monetization
134
149
135
-
If you have successfully completed your first Actor, you may consider [sharing it with other users and monetizing it](../../publishing/index.mdx). The Apify platform provides opportunities to publish and monetize your Actors, allowing you to share your work with the community and potentially generate revenue.
150
+
If you have successfully completed your first Actor, you may consider [sharing it with other users and monetizing it](../../publishing/index.mdx). The Apify platform provides opportunities to publish and monetize your Actors, allowing you to share your work with the community and potentially generate revenue.
136
151
137
-
:::
152
+
:::
153
+
154
+
## Next Steps
138
155
139
-
By following these steps, you can seamlessly deploy your Actors to the Apify platform, enabling you to leverage its scalability, reliability, and advanced features for your web scraping and data processing projects. -->
156
+
- If you want to understand Actors in more details, read the [Actor Whitepaper](https://whitepaper.actor/).
157
+
- Check [Continuous integration](../deployment/continuous_integration.md) documentation to automate your Actor development process.
0 commit comments