Sep 20, 2024
Customize clients
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.
Copy
1
2
3
4
5
6
7
8
9
10
11
// Other imports and setup code omitted
import com.algolia.client.api.SearchClient
import com.algolia.client.configuration.ClientOptions
var client = SearchClient(
"ALGOLIA_APPLICATION_ID",
"ALGOLIA_API_KEY",
ClientOptions(
requester = CustomRequester()
)
)
Logging
You can provide a custom logger to your custom configuration. You can adjust the log level for more or less logging output.
Copy
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
// Other imports and setup code omitted
import com.algolia.client.configuration.ClientOptions
import io.ktor.client.plugins.logging.Logger
import io.ktor.client.plugins.logging.LogLevel
val options = ClientOptions(
// Adjust the log level
logLevel = LogLevel.ALL,
// Print everything to stdout
logger = object : Logger {
override fun log(message: String) {
println(message)
}
}
)
Did you find this page helpful?