Integrations
/
Frameworks
/
Symfony
/
Direct API Access
Dec. 02, 2019
Direct API Access
Using Algolia Client
In some cases, you may want to access the Algolia client directly to perform advanced operations , like managing API keys and managing indices.
By default, the Algolia\AlgoliaSearch\SearchClient
is public in the Symfony container. That means that you only have to inject it, or retrieve it with the search.client
key to be able to use it (see how to inject the SearchService
as a reference).
Example
Here is an example of how to use the client.
Copy
1
2
3
4
5
6
7
8
9
10
11
class TestController extends AbstractController
{
/**
* @param SearchClient $client
* @return JsonResponse
*/
public function listApiKeysAction(SearchClient $client): JsonResponse
{
return new JsonResponse($client->listApiKeys());
}
}
Did you find this page helpful?