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.
Store your search-only API key in your environment variables,
or generate a new one using the Clientsβ addApiKey method.
PHP
Report incorrect code
Copy
$searchOnlyAPIKey = getenv('ALGOLIA_SEARCH_ONLY_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.
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?.