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
use Recombee\RecommApi\Client;
use Recombee\RecommApi\Requests as Reqs;
use Recombee\RecommApi\Exceptions as Ex;
$client = new Client('--your-database-id--', '--your-db-private-token--', ['region' => 'us-west']);
const NUM = 100;
const PROBABILITY_PURCHASED = 0.1;
try
{
// Generate some random purchases of items by users
$purchase_requests = array();
for($i=0; $i < NUM; $i++) {
for($j=0; $j < NUM; $j++) {
if(mt_rand() / mt_getrandmax() < PROBABILITY_PURCHASED) {
$request = new Reqs\AddPurchase("user-{$i}", "item-{$j}",
['cascadeCreate' => true] // Use cascadeCreate to create the
// yet non-existing users and items
);
array_push($purchase_requests, $request);
}
}
}
echo "Send purchases\n";
$res = $client->send(new Reqs\Batch($purchase_requests)); //Use Batch for faster processing of larger data
// Get 5 recommendations for user 'user-25'
$response = $client->send(new Reqs\RecommendItemsToUser('user-25', 5));
echo 'Recommended items: ' . json_encode($response, JSON_PRETTY_PRINT) . "\n";
// User scrolled down - get next 3 recommended items
$response = $client->send(new Reqs\RecommendNextItems($response['recommId'], 3));
echo 'Next recommended items: ' . json_encode($response, JSON_PRETTY_PRINT) . "\n";
}
catch(Ex\ApiException $e)
{
//use fallback
}