Skip to main content

JavaScript

PreviousLatestDescription
@algolia@experimental-api-clients-automationDuring the beta phase, the clients are available under the NPM @experimental-api-clients-automation namespace, you can find a full list here.
searchsearchClientExported clients are suffixed by Client.
destroyremovedThis method has not been implemented in the new clients, if you feel the need for it, please open an issue

Usage

To get started, first install the algoliasearch client.

bash
yarn add @experimental-api-clients-automation/algoliasearch
# or
npm install @experimental-api-clients-automation/algoliasearch
bash
yarn add @experimental-api-clients-automation/algoliasearch
# or
npm install @experimental-api-clients-automation/algoliasearch

You can now uninstall the previously added client.

Make sure to update all your imports.

bash
yarn remove algoliasearch
# or
npm uninstall algoliasearch
bash
yarn remove algoliasearch
# or
npm uninstall algoliasearch

You can continue this guide on our installation page.

Methods targeting an indexName

Prior to the initIndex removal stated in the common breaking changes, all methods previously available at the initIndex level requires the indexName to be sent with the query.

js
import { algoliasearch } from '@experimental-api-clients-automation/algoliasearch';
const client = algoliasearch('<YOUR_APP_ID>', '<YOUR_API_KEY>');
// only query string
const searchResults = await client.search({
requests: [
{
indexName: '<YOUR_INDEX_NAME>',
query: '<YOUR_QUERY>',
},
],
});
// with params
const searchResults2 = await client.search({
requests: [
{
indexName: '<YOUR_INDEX_NAME>',
query: '<YOUR_QUERY>',
attributesToRetrieve: ['firstname', 'lastname'],
hitsPerPage: 50,
},
],
});
js
import { algoliasearch } from '@experimental-api-clients-automation/algoliasearch';
const client = algoliasearch('<YOUR_APP_ID>', '<YOUR_API_KEY>');
// only query string
const searchResults = await client.search({
requests: [
{
indexName: '<YOUR_INDEX_NAME>',
query: '<YOUR_QUERY>',
},
],
});
// with params
const searchResults2 = await client.search({
requests: [
{
indexName: '<YOUR_INDEX_NAME>',
query: '<YOUR_QUERY>',
attributesToRetrieve: ['firstname', 'lastname'],
hitsPerPage: 50,
},
],
});