Skip to main content
Version: Next

Accept user input

This example accepts and logs user input:

import { Actor } from 'apify';

await Actor.init();

const input = await Actor.getInput();
console.log(input);

await Actor.exit();

To provide the actor with input, create a INPUT.json file inside the "default" key-value store:

{PROJECT_FOLDER}/storage/key_value_stores/default/INPUT.json

Anything in this file will be available to the actor when it runs. Locally, Actor.getInput() also accepts an INPUT.json (or a bare INPUT) file in the current working directory, and reads the directory above even when the storage backend doesn't (e.g. in-memory storage). The input must be in exactly one place: Actor.getInput() throws when it finds none, and when it finds more than one.

To learn about other ways to provide an actor with input, refer to the Apify Platform Documentation.