You can customize the Search API client, for example, by using a custom HTTP client, or by changing the user agent information.

To customize individual requests, for example, with headers or query parameters, see Request options.

Custom HTTP requester

You can create your own client for making HTTP requests when initializing the API client. For example, to use the echoRequester, which returns the full request payload:

1
2
3
4
5
6
7
import { searchClient } from "@algolia/client-search";
import { echoRequester } from "@algolia/requester-node-http";

const client = searchClient("ALGOLIA_APPLICATION_ID", "ALGOLIA_API_KEY", {
  // The first parameter is the status to return
  requester: echoRequester(200),
});

Custom user agent

The JavaScript Search API client send user agent information as x-algolia-agent query parameter. To append your own information to this parameter, use the addAlgoliaAgent function:

1
2
3
4
import { searchClient } from "@algolia/client-search";

const client = searchClient("ALGOLIA_APPLICATION_ID", "ALGOLIA_API_KEY");
client.addAlgoliaAgent("custom javascript client", "optional version");

This appends “custom javascript client (optional version)” to the x-algolia-agent query parameter.

Did you find this page helpful?
JavaScript API clients v5