|
1 | 1 | --- |
2 | 2 | id: actor-input |
3 | 3 | title: Actor input |
| 4 | +description: Read and validate input data passed to your Actor at runtime. |
4 | 5 | --- |
5 | 6 |
|
6 | 7 | import RunnableCodeBlock from '@site/src/components/RunnableCodeBlock'; |
7 | 8 |
|
8 | 9 | import InputExample from '!!raw-loader!roa-loader!./code/02_input.py'; |
| 10 | +import RequestListExample from '!!raw-loader!roa-loader!./code/02_request_list.py'; |
| 11 | +import ApiLink from '@site/src/components/ApiLink'; |
9 | 12 |
|
10 | 13 | The Actor gets its [input](https://docs.apify.com/platform/actors/running/input) from the input record in its default [key-value store](https://docs.apify.com/platform/storage/key-value-store). |
11 | 14 |
|
12 | | -To access it, instead of reading the record manually, you can use the [`Actor.get_input`](../../reference/class/Actor#get_input) convenience method. It will get the input record key from the Actor configuration, read the record from the default key-value store,and decrypt any [secret input fields](https://docs.apify.com/platform/actors/development/secret-input). |
| 15 | +To access it, instead of reading the record manually, you can use the <ApiLink to="class/Actor#get_input">`Actor.get_input`</ApiLink> convenience method. It will get the input record key from the Actor configuration, read the record from the default key-value store,and decrypt any [secret input fields](https://docs.apify.com/platform/actors/development/secret-input). |
13 | 16 |
|
14 | 17 | For example, if an Actor received a JSON input with two fields, `{ "firstNumber": 1, "secondNumber": 2 }`, this is how you might process it: |
15 | 18 |
|
16 | 19 | <RunnableCodeBlock className="language-python" language="python"> |
17 | 20 | {InputExample} |
18 | 21 | </RunnableCodeBlock> |
| 22 | + |
| 23 | +## Loading URLs from Actor input |
| 24 | + |
| 25 | +Actors commonly receive a list of URLs to process via their input. The <ApiLink to="class/ApifyRequestList">`ApifyRequestList`</ApiLink> class (from `apify.request_loaders`) can parse the standard Apify input format for URL sources. It supports both direct URL objects (`{"url": "https://example.com"}`) and remote URL lists (`{"requestsFromUrl": "https://example.com/urls.txt"}`), where the remote file contains one URL per line. |
| 26 | + |
| 27 | +<RunnableCodeBlock className="language-python" language="python"> |
| 28 | + {RequestListExample} |
| 29 | +</RunnableCodeBlock> |
| 30 | + |
| 31 | +## Secret input fields |
| 32 | + |
| 33 | +The Apify platform supports [secret input fields](https://docs.apify.com/platform/actors/development/secret-input) that are encrypted before being stored. When you mark an input field as `"isSecret": true` in your Actor's [input schema](https://docs.apify.com/platform/actors/development/input-schema), the platform encrypts the value with the Actor's public key. |
| 34 | + |
| 35 | +No special handling is needed in your code — when you call <ApiLink to="class/Actor#get_input">`Actor.get_input`</ApiLink>, encrypted fields are automatically decrypted using the Actor's private key, which is provided by the platform via environment variables. You receive the plaintext values directly. |
| 36 | + |
| 37 | +For more details on Actor input and how to define input schemas, see the [Actor input](https://docs.apify.com/platform/actors/running/input) and [input schema](https://docs.apify.com/platform/actors/development/input-schema) documentation on the Apify platform. |
0 commit comments