Algolia CLI / Get started

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 set up command completion, the Algolia CLI completes the available profile names for you.

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 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 --profile 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> 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 use the --application-id and --admin-api-key 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?