Kotlin API Client
This library allows you to request recommendations and send interactions between users and items (such as views, bookmarks, or purchases) to Recombee. It is a thin wrapper around the Recombee API and provides a simple way to interact with it.
This SDK is designed for usage in Android applications or other client-side applications (e.g. Compose Multiplatform).
For server-side integration with the Recombee API, use our dedicated Java library or other available server-side SDKs.
For security reasons, it is not possible to change the item catalog, such as the properties of items, using this SDK. To send your Catalog to Recombee, use one of the following methods:
- Use one of our server-side SDKs, for example using a script which runs periodically (see Managing Item Catalog for more details),
- Or set up a Catalog Feed in the Admin UI.
Install
The client is available in the Maven Central Repository, which is included in new Android projects by default.
Adding the client into your project is therefore as simple as adding the dependency into your build.gradle:
You can then find all the classes and methods in the com.recombee.apiclientkotlin package and its subpackages.
Configure
In order to use the API, you will need to create an instance of the RecombeeClient class. You will need:
- the ID of your database,
- the public token.
You can find these in the Admin UI, in your Database's Settings page, under API ID & Tokens. Along with this information, you can also find the full code snippet for initializing the client, including the above-mentioned parameters.
Ideally, you should only have one instance of the RecombeeClient in your application, as it is a lightweight object and can be reused for multiple requests.
We published a simple Android example app to help you with the integration. Feel free to use it as a reference.

You can initialize the client as follows:
You can also set several optional parameters when initializing the client:
Send Interactions
After you have initialized the client, you can send interactions between users and items.
The individual interactions are classes within the com.recombee.apiclientkotlin.requests package.
After you create an instance of the interaction, you can send it using one of two methods of the RecombeeClient class:
send- for callbackssendAsync- for coroutines (must be called from inside aCoroutineScope)
Each interaction has both mandatory and optional parameters.
The most important optional parameter is recommId - the ID of the recommendation to which the interaction belongs.
Providing this ID allows you to track successful recommendations.
For more information, read about Reported Metrics.
For a full list of interactions, along with their parameters, refer to the API Reference.
If you want to send multiple interactions at once, you can use the Batch request:
You can then use callbacks (or Result) to handle any exceptions that may occur.
Get Recommendations
With an initialized client, you can also request recommendations.
There are multiple types of recommendations, such as:
- Recommend Items to User,
- Recommend Items to Item,
- Recommend Item Segments to User (these can be categories, genres, artists, etc.),
- or others.
Each recommendation request is a class within the com.recombee.apiclientkotlin.requests package.
After you create an instance of the recommendation request, you can send it using the send or sendAsync methods of the client (depending on whether you want to use callbacks or coroutines).
For a full list of request parameters and possible responses, visit the API Reference.
Personalized Search
Personalized full-text search is requested in the same way as recommendations:
Recommend Next Items
If you are implementing features like infinite scroll or pagination, you can use the RecommendNextItems request to load recommendations progressively.
This means you can fetch the next set of recommended items without repeating the ones you have already displayed.
To use this functionality, you must provide the recommId from the initial recommendation request.
For more details, see the Recommend Next Items documentation.
Batch Requests
You may encounter a situation where you display recommendations in multiple places on your website.
In such cases, you can use the Batch request to send multiple recommendation requests at once. This can help reduce the number of HTTP requests and improve performance.
For example, you can request the most popular items, as well as items related to a specific user or item, in a single Batch:
The optional parameter distinctRecomms of the Batch ensures that the recommended items are not repeated across the responses.
You can find more information about Batch requests in the API Reference.
Optional Parameters
Recommendation requests support various optional parameters to customize their behavior. For a comprehensive list, refer to the API Reference. Below is an example showcasing some commonly used parameters:
Error Handling
The API client throws exceptions when an error occurs. The exceptions are part of the com.recombee.apiclientkotlin.exceptions package.
The possible exceptions are:
| Exception | Cause |
|---|---|
ApiException | Base class for all exceptions |
ResponseException : ApiException | The API returned an error code (e.g. invalid parameter) |
ApiIOException : ApiException | Request failed (e.g. network issues) |
ApiTimeoutException : ApiIOException | Request timed out |
We are doing our best to provide a reliable service, but sometimes things can go wrong. For this reason, we recommend that you always handle exceptions and provide fallbacks in your application.
For example, when requesting recommendations, a fallback could be to display a generic set of items or an error message to the user.