Tools / CLI / Get started

Authenticate CLI commands

You need to authenticate and authorize your CLI commands with your Algolia credentials (application ID and API key). You can find both in the Algolia dashboard.

In general, use an API key with minimal permissions, just enough to run the commands you want to run. For more information, see API keys.

Environment variables

Set these environment variables:

  • ALGOLIA_APPLICATION_ID
  • ALGOLIA_API_KEY

Environment variables take precedence over command-line options and profiles. That means, you can’t switch profiles while using environment variables.

Command-line options

Provide these options when running commands:

  • --application-id
  • --api-key

Command-line options take precedence over profiles.

Profiles

Store your application ID and API key under a friendly name. Instead of providing the command-line options with every command, you can refer to the profile with the --profile option. For example: algolia index list -p PROFILE_NAME. For more information, see algolia profile add.

Profiles are stored in plain-text in the file ~/.config/algolia/config.toml. If you manage your configuration files (“dotfiles”) with GitHub, don’t commit this file.

The first profile you add is the default profile. You can omit the --profile option when using the default profile. To change the default profile, see algolia profile setdefault.

Crawler commands

Crawler commands require different credentials: a Crawler user ID, and a Crawler API key. You can find them in the Algolia dashboard:

  1. Go to the Algolia dashboard and select your Algolia application.
  2. On the left sidebar, select Data sources.
  3. Select Crawler and go to the Settings tab.

You can provide your credentials for Crawler commands in one of the following ways.

Environment variables
Export your Algolia Crawler user ID and Crawler API key as environment variables: ALGOLIA_CRAWLER_USER_ID and ALGOLIA_CRAWLER_API_KEY.
Profiles
Add the keys crawler_user_id and crawler_api_key to an application profile in ~/.config/algolia/config.toml.

An example profile for an Algolia application with Crawler could look like the following:

1
2
3
4
5
  [PROFILE_NAME]
  application_id = "ALGOLIA_APPLICATION_ID"
  api_key = "ALGOLIA_API_KEY"
+ crawler_user_id = "ALGOLIA_CRAWLER_ID"
+ crawler_api_key = "ALGOLIA_CRAWLER_API_KEY"
Did you find this page helpful?