Searching directly from the frontend significantly improves search response time,
and reduces load and traffic on your servers.
Generate search keys
For client-side implementations, always use a Search-only .
Your Admin API key is sensitive.
You should never share it with anyone and it must remain confidential.
To generate a search key for a given ,
use the SearchClientβs generateSecuredApiKey method.
$searchOnlyAPIKey = getenv('ALGOLIA_SEARCH_API_KEY');
$validUntil = time() + 3600;
// Generate a new secured API key
$searchKey = \Algolia\AlgoliaSearch\SearchClient::generateSecuredApiKey(
$searchOnlyAPIKey,
[
'restrictIndices' => $this->searchService->searchableAs(Post::class),
'validUntil' => $validUntil
]
);
Define the indices you want to access with this API key,
and change the validUntil parameter to set a validity period.
Integration with InstantSearch
Now that you know how to generate your secured API keys,
you can use them to create your frontend view with InstantSearch.
To learn more, see What is InstantSearch?. Last modified on March 16, 2026