Skip to main content

Environment variables

Learn how to provide your actor with context that determines its behavior through a plethora of pre-defined environment variables offered by the Apify SDK.

Aside from custom environment variables, the actor's process has several environment variables set to provide it with context:

Environment VariableDescription
APIFY_ACTOR_IDID of the actor.
APIFY_ACTOR_RUN_IDID of the actor run.
APIFY_ACTOR_BUILD_IDID of the actor build used in the run.
APIFY_ACTOR_BUILD_NUMBERBuild number of the actor build used in the run.
APIFY_ACTOR_TASK_IDID of the actor task. It's empty if actor is run outside of any task, e.g. directly using the API.
APIFY_ACTOR_EVENTS_WS_URLWebsocket URL where actor may listen for events from Actor platform. See documentation for more information.
APIFY_DEFAULT_DATASET_IDID of the dataset where you can push the data.
APIFY_DEFAULT_KEY_VALUE_STORE_IDID of the key-value store where the actor's input and output data are stored.
APIFY_DEFAULT_REQUEST_QUEUE_IDID of the request queue that stores and handles requests that you enqueue.
APIFY_INPUT_KEYThe key of the record in the default key-value store that holds the actor input. Typically it's INPUT, but it might be something else.
APIFY_HEADLESSIf set to 1, the web browsers inside the actor should run in headless mode because there is no windowing system available.
APIFY_IS_AT_HOMEIs set to 1 if the actor is running on Apify servers.
APIFY_MEMORY_MBYTESIndicates the size of memory allocated for the actor run, in megabytes. It can be used by actors to optimize their memory usage.
APIFY_PROXY_PASSWORDThe Apify Proxy password of the user who started the actor.
APIFY_STARTED_ATDate when the actor was started.
APIFY_TIMEOUT_ATDate when the actor will time out.
APIFY_TOKENThe API token of the user who started the actor.
APIFY_USER_IDID of the user who started the actor. Note that it might be different than the owner of the actor.
APIFY_CONTAINER_PORTTCP port on which the actor can start a HTTP server to receive messages from the outside world. See Container web server section for more details.
APIFY_CONTAINER_URLA unique public URL under which the actor run web server is accessible from the outside world. See Container web server section for more details.

Dates are always in the UTC timezone and are represented in simplified extended ISO format (ISO 8601), e.g. 2022-07-13T14:23:37.281Z.

To access environment variables in Node.js, use the process.env object, for example:


To access environment variables in Python, use the os.environ dictionary, for example:

import os