User Documentation
API Clients & Integrations
Scenario Recipes
Documentation Index
Fetch the complete index at:https://docs.recombee.com/llms.txt
Use this file to discover all available pages before exploring further.
Other Resources
- To see a complete guide for AI assistants carrying out a Recombee integration, go to:https://docs.recombee.com/ai_assistant_guide.md
- To access the entire documentation in a single Markdown file, go to:https://docs.recombee.com/llms-full.txt
- Every page has a Markdown twin: append
.mdto its URL (for example https://docs.recombee.com/getting_started.md), or request the normal URL with the headerAccept: text/markdown.
Example
require 'recombee_api_client'
include RecombeeApiClient
client = RecombeeClient.new('--your-database-id--', '--your-db-private-token--', {:region => 'us-west'})
# Generate some random purchases of items by users
NUM = 100
PROBABILITY_PURCHASED = 0.1
users = (1..NUM).map { |i| "user-#{i}" }
items = (1..NUM).map { |i| "item-#{i}" }
purchases = []
users.each do |user_id|
purchased = items.select { |_| rand(0.0..1.0) < PROBABILITY_PURCHASED }
purchased.each { |item_id| purchases.push(
AddPurchase.new(user_id, item_id,'cascadeCreate' => true)
# Use cascadeCreate to create the
# yet non-existing users and items
)}
end
begin
# Send the data to Recombee, use Batch for faster processing of larger data
client.send(Batch.new(purchases))
# Get recommendations for user 'user-25'
response = client.send(RecommendItemsToUser.new('user-25', 5))
puts "Recommended items for user-25: #{response}"
# User scrolled down - get next 3 recommended items
response = client.send(RecommendNextItems.new(response['recommId'], 3))
puts "Next recommended items for user-25: #{response}"
rescue APIError => e
puts e
# Use fallback
end