Integrations / Frameworks / Laravel / Access API Directly
Jan. 14, 2019

Access API Directly

Access API directly

To access the API directly, you may need to interact with the Algolia’s PHP client.

The Algolia PHP client is designed to be a very low-level client, allowing you to use the most powerful features of Algolia (Synonyms, Query Rules, Personalization, and others) on the most customizable way as possible.

Please head over to Algolia’s PHP client Documentation to find the available methods and features.

If you are relying on the Algolia’s PHP client classes, you should perform a composer require algolia/algoliasearch-client-php to make sure that there are no breaking changes on major releases of the API Client.

Algolia::client

The client method returns an instance of AlgoliaSearch\Client:

1
2
3
4
5
6
7
8
9
use Algolia\ScoutExtended\Facades\Algolia;

$client = Algolia::client();

$apiKeys = $client->listApiKeys();
$indices = $client->listIndices();
$client->copyIndex('indexNameSrc', 'indexNameDest');
$client->moveIndex('indexNameSrc', 'indexNameDest');
// ...

Algolia::index

The index method returns an instance of AlgoliaSearch\Index:

1
2
3
4
5
6
7
8
use Algolia\ScoutExtended\Facades\Algolia;

$index = Algolia::index(App\Article::class);

$synonym = $index->getSynonym('a-unique-identifier');
$rule = $index->getRule('a-unique-identifier');
$index->delete();
// ...

Algolia::analytics

The analytics method returns an instance of AlgoliaSearch\Analytics:

1
2
3
4
5
use Algolia\ScoutExtended\Facades\Algolia;

$analytics = Algolia::analytics();
$test = $analytics->getABTest('a-unique-identifier');
// ...

Did you find this page helpful?