Algolia CLI / Authentication

Authenticate CLI commands

To make authenticating with Algolia easier, you can create profiles for different Algolia applications. A profile stores the application ID and API key under a friendly name. If you’ve set up command completion, the Algolia CLI completes the available profile names for you. Alternatively, you can also provide the application ID and API key as a command-line option.

You can find your application ID and API key in the Algolia dashboard.

Create profiles

To create a new profile, use the algolia profile add command:

1
2
3
4
algolia profile add \
        --name <NAME> \
        --application-id <APPLICATION_ID> \
        --admin-api-key <ADMIN_API_KEY>

Now, you can use the command-line option --profile <NAME> to authenticate your CLI commands.

Profiles are stored in a configuration file in your home directory: ~/.config/algolia/config.toml

Default profile

The first profile you add is set as default profile. You can omit the --profile command-line option for the default profile.

For example, if the name of the default profile is store, and you want to search the products index, you can use one of the following commands:

1
2
3
4
5
6
7
algolia search products --query "" 
# This has the same effect as:
algolia search products --query "" --profile store
# This has the same effect as:
algolia search products --query "" \
                        --application-id <APPLICATION_ID> \
                        --admin-api-key <API_KEY>

To change the default profile, use the algolia profile setdefault command.

Using profiles

To run commands for different profiles, use the --profile <NAME> command-line option.

For example, to list all indices in different profiles, run:

1
2
3
4
# List all indices of the default profile:
algolia indices list 
# List all indices in the _ecommerce_ profile:
algolia indices list --profile ecommerce

To get a list of all your profiles, use the algolia profile list command.

Authentication without profiles

If you don’t want to create profiles, you can also use the --application-id and --admin-api-key command-line options for every command. This can be useful if you want to store your Algolia credentials elsewhere and reference them using environment variables, for example, in continuous deployment.

Did you find this page helpful?