Skip to main content
Version: Next

Actor input

The Actor gets its input from the input record in its default key-value store.

To access it, instead of reading the record manually, you can use the 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.

For example, if an Actor received a JSON input with two fields, { "firstNumber": 1, "secondNumber": 2 }, this is how you might process it:

Run on
import asyncio

from apify import Actor


async def main() -> None:
async with Actor:
actor_input = await Actor.get_input() or {}
first_number = actor_input.get('firstNumber', 0)
second_number = actor_input.get('secondNumber', 0)
Actor.log.info('Sum: %s', first_number + second_number)


if __name__ == '__main__':
asyncio.run(main())

Loading URLs from Actor input

Actors commonly receive a list of URLs to process via their input. The ApifyRequestList 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.

Run on
import asyncio

from apify import Actor
from apify.request_loaders import ApifyRequestList


async def main() -> None:
async with Actor:
actor_input = await Actor.get_input() or {}

# The input may contain a list of URL sources in the standard Apify format
request_list_sources = actor_input.get('requestListSources', [])

# Create a request list from the input sources.
# Supports direct URLs and remote URL lists.
request_list = await ApifyRequestList.open(
request_list_sources_input=request_list_sources,
)

total = await request_list.get_total_count()
Actor.log.info(f'Loaded {total} requests from input')

# Process requests from the list
while request := await request_list.fetch_next_request():
Actor.log.info(f'Processing {request.url}')


if __name__ == '__main__':
asyncio.run(main())

Secret input fields

The Apify platform supports secret input fields that are encrypted before being stored. When you mark an input field as "isSecret": true in your Actor's input schema, the platform encrypts the value with the Actor's public key.

No special handling is needed in your code — when you call Actor.get_input, 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.

For more details on Actor input and how to define input schemas, see the Actor input and input schema documentation on the Apify platform.