Gathering detailed insights and metrics for recombee-js-api-client-for-gatsby
Gathering detailed insights and metrics for recombee-js-api-client-for-gatsby
Gathering detailed insights and metrics for recombee-js-api-client-for-gatsby
Gathering detailed insights and metrics for recombee-js-api-client-for-gatsby
JavaScript client for easy use of the Recombee recommendation API from frontend
npm install recombee-js-api-client-for-gatsby
Typescript
Module System
Node Version
NPM Version
JavaScript (99.17%)
HTML (0.83%)
Total Downloads
0
Last Day
0
Last Week
0
Last Month
0
Last Year
0
17 Commits
1 Forks
1 Branches
1 Contributors
Updated on Jul 05, 2023
Latest Version
2.4.9
Package Id
recombee-js-api-client-for-gatsby@2.4.9
Unpacked Size
612.15 kB
Size
164.00 kB
File Count
14
NPM Version
6.11.3
Node Version
6.11.2
Cumulative downloads
Total Downloads
Last Day
0%
NaN
Compared to previous day
Last Week
0%
NaN
Compared to previous week
Last Month
0%
NaN
Compared to previous month
Last Year
0%
NaN
Compared to previous year
1
A javascript library for easy use of the Recombee recommendation API.
It is intended for usage in browsers and other client side integrations (such as in React Native / NativeScript mobile apps). For Node.js SDK please see this repository.
Documentation of the API can be found at docs.recombee.com.
The library is UMD compatible.
You can download recombee-api-client.min.js and host it at your site, or use a CDN such as jsDelivr CDN:
1<script src="https://cdn.jsdelivr.net/gh/recombee/js-api-client@2.4.0/dist/recombee-api-client.min.js"></script>
npm install recombee-js-api-client-for-gatsby --save
bower install recombee-js-api-client-for-gatsby -S
This library allows you to request recommendations and send interactions between users and items (views, bookmarks, purchases ...) to Recombee. It uses the public token for authentication.
It is intentionally not possible to change item catalog (properties of items) with public token, so you should use one of the following ways to send it to Recombee:
1// Initialize client with name of your database and PUBLIC token 2var client = new recombee.ApiClient('name-of-your-db', '...db-public-token...'); 3 4//Interactions take Id of user and Id of item 5client.send(new recombee.AddBookmark('user-13434', 'item-256')); 6client.send(new recombee.AddCartAddition('user-4395', 'item-129')); 7client.send(new recombee.AddDetailView('user-9318', 'item-108')); 8client.send(new recombee.AddPurchase('user-7499', 'item-750')); 9client.send(new recombee.AddRating('user-3967', 'item-365', 0.5)); 10client.send(new recombee.SetViewPortion('user-4289', 'item-487', 0.3));
You can recommend items to user or recommend items to item.
It is possible to use callbacks or Promises.
Callback function take two parameters:
null
if request succeeds or Error
object1var callback = function(err, res) { 2 if (err) { 3 console.log(err); 4 // use fallback ... 5 return; 6 } 7 console.log(res.recomms); 8}; 9 10// Get 5 recommendations for user-13434 11client.send(new recombee.RecommendItemsToUser('user-13434', 5), callback);
1// Get 5 recommendations related to 'item-365' viewed by 'user-13434' 2client 3 .send(new recombee.RecommendItemsToItem('item-356', 'user-13434', 5)) 4 .then(function(res) { 5 console.log(res.recomms); 6 }) 7 .catch(function(error) { 8 console.log(error); 9 // use fallback ... 10 });
Recommendation requests accept various optional parameters (see the docs). Following example shows some of them:
1client.send( 2 new recombee.RecommendItemsToUser('user-13434', 5, { 3 returnProperties: true, // Return properties of the recommended items 4 includedProperties: ['title', 'img_url', 'url', 'price'], // Use these properties to show 5 // the recommended items to user 6 filter: "'title' != null AND 'availability' == \"in stock\"", 7 // Recommend only items with filled title 8 // which are in stock 9 scenario: 'homepage' // Label particular usage 10 }), 11 callback 12);
You can use a script or set a product feed at Recombee web admin. We will set following sample Google Merchant product feed: product_feed_sample.xml. You will see the items in web interface after the feed is processed.
Let's assume we want to show recommendations at product page of pants product-270
to user with id user-1539
. The following HTML+js sample send the detail view of the product by the user and request 3 related items from Recombee:
1<!DOCTYPE html> 2<html lang="en"> 3 <head> 4 <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" /> 5 </head> 6 <body> 7 <div class="container"> 8 <div class="row"> 9 <h1>Related products</h1> 10 <div class="col-md-12"> 11 <div class="row" id="relatedProducts"></div> 12 </div> 13 </div> 14 </div> 15 16 <script src="https://cdn.jsdelivr.net/gh/recombee/js-api-client@2.4.0/dist/recombee-api-client.min.js"></script> 17 18 <script type="text/javascript"> 19 // A simple function for rendering a box with recommended product 20 function showProduct(title, description, link, imageLink, price) { 21 return [ 22 '<div class="col-md-4 text-center col-sm-6 col-xs-6">', 23 ' <div class="thumbnail product-box" style="min-height:300px">', 24 ' <img src="' + imageLink + '" alt="" />', 25 ' <div class="caption">', 26 ' <h3><a href="' + link + '">' + title + '</a></h3>', 27 ' <p>Price : <strong>$ ' + price + '</strong> </p>', 28 ' <p>' + description + '</p>', 29 ' <a href="' + link + '" class="btn btn-primary" role="button">See Details</a></p>', 30 ' </div>', 31 ' </div>', 32 '</div>' 33 ].join('\n'); 34 } 35 36 // Initialize client 37 var client = new recombee.ApiClient( 38 'js-client-example', 39 'dXx2Jw4VkkYQP1XU4JwBAqGezs8BNzwhogGIRjDHJi39Yj3i0tWyIZ0IhKKw5Ln7' 40 ); 41 42 var itemId = 'product-270'; 43 var userId = 'user-1539'; 44 45 // Send detail view 46 client.send(new recombee.AddDetailView(userId, itemId)); 47 48 // Request recommended items 49 client.send( 50 new recombee.RecommendItemsToItem(itemId, userId, 3, { 51 returnProperties: true, 52 includedProperties: ['title', 'description', 'link', 'image_link', 'price'], 53 filter: "'title' != null AND 'availability' == \"in stock\"", 54 scenario: 'related_items' 55 }), 56 (err, resp) => { 57 if (err) { 58 console.log('Could not load recomms: ', err); 59 return; 60 } 61 // Show recommendations 62 var recomms_html = resp.recomms 63 .map((r) => r.values) 64 .map((vals) => 65 showProduct(vals['title'], vals['description'], vals['link'], vals['image_link'], vals['price']) 66 ); 67 document.getElementById('relatedProducts').innerHTML = recomms_html.join('\n'); 68 } 69 ); 70 </script> 71 </body> 72</html>
You should see something like this:
Please notice how the properties returned by returnProperties
&includedProperties
were used to show titles, images, descriptions and URLs.
In order to achieve personalization, you need a unique identifier for each user. An easy way can be using Google Analytics for this purpose. The example then becomes:
1ga('create', 'UA-XXXXX-Y', 'auto'); // Create a tracker if you don't have one 2 // Replace the UA-XXXXX-Y with your UA code from Google Analytics. 3 4var client = new recombee.ApiClient('js-client-example', 'dXx2Jw4VkkYQP1XU4JwBAqGezs8BNzwhogGIRjDHJi39Yj3i0tWyIZ0IhKKw5Ln7'); 5 6ga(function(tracker) { 7 var userId = tracker.get('clientId'); // Get id from GA 8 9 client.send(new recombee.RecommendItemsToUser(userId, 3, 10 { 11 returnProperties: true, 12 includedProperties: ['title', 'description', 'link', 'image_link', 'price'], 13 filter: "'title' != null AND 'availability' == \"in stock\"", 14 scenario: 'homepage' 15 }), 16 (err, resp) => { ... } 17 ); 18}); 19
This time RecommendItemsToUser is used - it can be used for example at your homepage.
No vulnerabilities found.
Reason
no binaries found in the repo
Reason
Found 0/17 approved changesets -- score normalized to 0
Reason
0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0
Reason
no SAST tool detected
Details
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
security policy file not detected
Details
Reason
license file not detected
Details
Reason
project is not fuzzed
Details
Reason
branch protection not enabled on development/release branches
Details
Reason
109 existing vulnerabilities detected
Details
Score
Last Scanned on 2025-07-07
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More