Skip to main content
To change the settings for all requests, you can initialize the API client with a custom configuration. To configure individual requests, see Request options.
Not all API clients support all customization options.

Custom configuration

Customize the API client by creating a configuration object or by passing additional options when instantiating the client.

Adjust timeouts

The following example shows how to adjust the default timeouts for all requests.
For more information about these timeouts, see Request options.

Enable compression

Enable gzip compression to reduce the size of request bodies sent to Algolia’s servers. When enabled, POST and PUT request bodies that exceed a minimum size are compressed before sending.
The JavaScript client only supports compression in Node.js builds. Browser and worker builds don’t support compression.The Kotlin client supports compression on JVM only.

Customize user agent information

The following example shows how to add a custom user agent string to the default.

Add default headers

The following example shows how to add a custom header to all API requests.
If you use the JavaScript API client in a browser — including when you use InstantSearch or Autocomplete, which rely on the API client — you can’t send arbitrary HTTP headers.Browsers enforce cross-origin resource sharing (CORS) rules. During the OPTIONS preflight request, the API explicitly lists which headers it accepts in the access-control-allow-headers response header. Any header not listed there is blocked by the browser.To see which headers are allowed, check the access-control-allow-headers value in the preflight response in your browser’s developer tools.

Logging

You can set a custom logger to enable more or less logging output.

Custom hosts

The following example shows how to add your own servers.

Custom HTTP clients

The following example shows how to use a custom HTTP client to make requests.

Transformation options and the ingestion transporter

To use the WithTransformation helper methods, set transformationOptions on the search client. This creates a dedicated ingestion transporter that handles requests to the transformation pipeline. The ingestion transporter starts from the Ingestion API defaults: 25-second connect, read, and write timeouts, hosts derived from your region, and no compression. It only overrides those defaults with the options you explicitly set in transformationOptions. The transporter doesn’t inherit the configuration of the parent search client. Custom hosts, timeouts, headers, or compression set on the search client don’t apply to transformation requests. To customize the transformation requests, set the corresponding option on transformationOptions instead.
region is required in transformationOptions. The client throws an error if you call a WithTransformation helper method without it.
You can override the following options on transformationOptions, depending on the language: region (required), custom hosts, connect, read, and write timeouts, default headers, and compression. Any option you don’t set keeps its Ingestion API default. For example, to keep the region-derived hosts but raise the timeouts:

DNS caching (Java)

By default, the JVM caches DNS resolutions infinitely. Since Algolia uses multiple IP addresses for load balancing, you should reduce the time to live (TTL) of the cache. For example, set the TTL of the cache to 60 seconds:
Java
Last modified on June 11, 2026