Skip to main content
Version: Next

Environment variables

There are two options how you can set up environment variables for Actors.

Set up environment variables in .actor/actor.json

All keys from environmentVariables will be set as environment variables into Apify platform after you push Actor to Apify. Current values on Apify will be overridden.

{
"actorSpecification": 1,
"name": "dataset-to-mysql",
"version": "0.1",
"buildTag": "latest",
"environmentVariables": {
"MYSQL_USER": "my_username",
"MYSQL_PASSWORD": "@mySecretPassword"
}
}

Set up environment variables in Apify Console

In Apify Console select your Actor, you can set up variables into Source tab. After setting up variables in the app, remove the environmentVariables from .actor/actor.json. Otherwise, variables from .actor/actor.json will override variables in the app.

{
"actorSpecification": 1,
"name": "dataset-to-mysql",
"version": "0.1",
"buildTag": "latest"
}

How to set secret environment variables in .actor/actor.json

CLI provides commands to manage secrets environment variables. Secrets are stored to the ~/.apify directory. You can add a new secret using the command:

apify secrets add mySecretPassword pwd1234

After adding a new secret you can use the secret in .actor/actor.json.

{
"actorSpecification": 1,
"name": "dataset-to-mysql",
...
"environmentVariables": {
"MYSQL_PASSWORD": "@mySecretPassword"
},
...
}

Environment variables that configure the CLI

Use the following environment variable to point the CLI at a non-production Apify Console, such as a staging deployment or a local instance during development.

APIFY_CONSOLE_URL

Overrides the base URL of Apify Console used when the CLI prints links. For example, run, build, dataset and key-value store URLs, or the apify login browser flow. When unset, the production Console at https://console.apify.com is used.

Set it to point at a local Console instance during development:

export APIFY_CONSOLE_URL=http://localhost:3000

With a localhost Console, apify login also validates your token against the local API at http://localhost:3333.