Skip to main content
In some cases, you might want to access the Algolia client directly to perform advanced operations, like managing API keys and managing indices. The bundle exposes two ways to obtain the Algolia\AlgoliaSearch\Api\SearchClient:
  • Preferred: inject it by type-hinting the constructor. Symfony autowires the client for you.
  • From the container: retrieve it with the public search.client service ID — for example, $container->get('search.client').
For example:
PHP
use Algolia\AlgoliaSearch\Api\SearchClient;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\JsonResponse;

class TestController extends AbstractController
{
    public function listApiKeysAction(SearchClient $client): JsonResponse
    {
        return new JsonResponse($client->listApiKeys());
    }
}
Last modified on April 27, 2026