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 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
when using 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 ADMIN_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.