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.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.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