Authenticate CLI commands
To authenticate CLI commands, use your Algolia application ID and an API key with appropriate permissions. You can find both in the Algolia dashboard.
You can provide your credentials in these ways:
-
Variables. Use the
--api-key
and--application-id
options to pass your credentials. This is useful if you want to read your credentials from environment variables, for example in continuous integration (CI) environments. -
Profiles. Create profiles to store your credentials in a configuration file
~/.confing/algolia/config.toml
. When running commands, you can reference the profile instead of entering the credentials. -
Environment variables (crawler commands only). See Crawler commands.
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 \
--api-key API_KEY
Now, you can use the option --profile NAME
to authenticate your commands.
In general, use an API key that has only the minimum required permissions to perform the tasks you want to perform.
For example, if you only want to search or browse your indices, use an API key that has the search
and browse
permissions.
Default profile
The first profile you add is created as default profile.
You can omit --profile
when using the default profile.
For example, if your 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 is the same as:
algolia search products --query "" --profile store
# This is the same as:
algolia search products --query "" \
--application-id APPLICATION_ID \
--api-key API_KEY
To change the default profile, use the algolia profile setdefault
command.
Crawler commands
The Crawler is available as an add-on and must be enabled for your Algolia application.
To authenticate algolia crawler
commands,
set these environment variables:
ALGOLIA_CRAWLER_USER_ID
for your Crawler User IDALGOLIA_CRAWLER_API_KEY
for your Crawler API key
You can find both in the Crawler dashboard.
You can also add them to your configuration file ~/.config/algolia/config.toml
,
to an application with the Crawler add-on.
1
2
3
4
5
[app_with_crawler] # Profile name
application_id = '...' # Your Algolia application ID
api_key = '...' # Your regular API key for the Algolia app
+ crawler_user_id = '...' # Your Crawler user ID
+ crawler_api_key = '...' # Your Crawler API key