Recombee Docs
Visit recombee.comStart Free
docs20User Documentation
adminuiAdmin UI
reql32ReQL
codeAPI Clients & Integrations
cookhatScenario Recipes
suitcaseMisc

Kotlin API Client

The library allows you to request recommendations and send interactions between users and items (views, bookmarks, purchases …).

It is intended for usage in Android applications.

Example

Kotlin
import com.recombee.apiclientkotlin.RecombeeClient
import com.recombee.apiclientkotlin.bindings.RecommendationResponse
import com.recombee.apiclientkotlin.exceptions.ApiException
import com.recombee.apiclientkotlin.requests.*
import com.recombee.apiclientkotlin.util.Region

fun main() {

    val client = RecombeeClient(
        databaseId = "--your-database-id--",
        publicToken = "--your-db-public-token--",
        region = Region.UsWest
    )

    client.send(SetViewPortion(userId = "user-4289", itemId = "item-487", portion = 0.3))

    val recommRequest = RecommendItemsToUser(userId = "user-4289", count = 10)

    client.send(recommRequest,
        { response: RecommendationResponse ->
            // Show recommendations
            for (recommendedItem in response.recomms) {
                println("ID: ${recommendedItem.id}")
            }
        },
        { exception: ApiException ->
            println("Exception: $exception")
            // use fallback ...
        }
    )
}
© Copyright 2024, Recombee s.r.o
docs.recombee.com