You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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](https://github.com/recombee/node-api-client).
The library is [UMD](https://github.com/umdjs/umd) compatible.
28
+
## 🚀 Getting Started
12
29
13
-
### <script> tag
30
+
There are two ways to include the library in your project:
14
31
15
-
You can download [recombee-api-client.min.js](./dist/recombee-api-client.min.js) and host it at your site, or use a CDN such as [jsDelivr](https://www.jsdelivr.com/) CDN:
The library ships with types, so you should get autocomplete in your IDE out of the box.
44
-
If you're using TypeScript, it should recognize these correctly and warn you about any type errors.
45
-
46
-
## How to use
47
-
48
-
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.
49
-
50
-
It is intentionally not possible to change the item catalog (properties of items) with the public token, so you should use one of the following ways to send it to Recombee:
51
-
52
-
- Use one of the server-side SDKs (Node.js, PHP, Java...). The synchronization can done for example by a peridodically run script. See [this section](https://docs.recombee.com/gettingstarted.html#managing-item-catalog) for more details.
53
-
- Set a catalog feed at [Recombee web admin](https://admin.recombee.com/).
54
-
55
-
### Sending interactions
56
-
57
-
```javascript
58
-
// Initialize client with name of your database and PUBLIC token
You can [recommend items to user](https://docs.recombee.com/api.html#recommend-items-to-user), [recommend items to item](https://docs.recombee.com/api.html#recommend-items-to-item) or even [recommend Item Segments](https://docs.recombee.com/api#recommend-item-segments-to-user) such as categories, genres or artists.
73
-
74
-
It is possible to use Promises or callbacks.
62
+
### 🏗️ Example
75
63
76
-
#### Promise
64
+
With the `recombee` object, you can send user-item interactions and receive recommendations as follows:
77
65
78
-
```javascript
79
-
// Get 5 recommendations related to 'item-365' viewed by 'user-13434'
Recombee can return items that shall be shown to a user as next recommendations when the user e.g. scrolls the page down (infinite scroll) or goes to the next page. See [Recommend next items](https://docs.recombee.com/api.html#recommend-next-items) for more info.
// notice we're using recommId from previous request ^
158
-
);
159
-
```
160
-
161
-
### Optional parameters
162
-
163
-
Recommendation requests accept various optional parameters (see [the docs](https://docs.recombee.com/api.html#recommendations)). Following example shows some of them:
You can use a [script](https://docs.recombee.com/gettingstarted.html#managing-item-catalog) or set a product feed at [Recombee web admin](https://admin.recombee.com/). We will set following sample Google Merchant product feed: [product_feed_sample.xml](./examples/product_feed_sample.xml).
189
-
You will see the items in web interface after the feed is processed.
190
-
191
-
### 3. Use client to send interaction and get recommendations
108
+
## 📝 Documentation
192
109
193
-
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:
110
+
Discover the full [JavaScript API Client documentation](https://docs.recombee.com/js_client) for comprehensive guides and examples.
We welcome all contributions—whether it’s fixing a bug, improving documentation, or suggesting a new feature.
271
117
272
-
Please notice how the properties returned by `returnProperties` & `includedProperties` were used to show titles, images, descriptions and URLs.
118
+
To contribute, simply fork the repository, make your changes, and submit a pull request. Be sure to provide a clear description of your changes.
273
119
274
-
### Remark on user identification
120
+
Thanks for helping make this project better!
275
121
276
-
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:
122
+
## 🔧 Troubleshooting
277
123
278
-
```javascript
279
-
ga('create', 'UA-XXXXX-Y', 'auto'); // Create a tracker if you don't have one
280
-
// Replace the UA-XXXXX-Y with your UA code from Google Analytics.
124
+
Are you having issues? We recommend checking [our documentation](https://docs.recombee.com/js_client) to see if it contains a possible solution.
If you want to reach out, you can either [open a GitHub issue](https://github.com/recombee/js-api-client/issues/new) or send an email to [email protected].
283
127
284
-
ga(function(tracker) {
285
-
constuserId=tracker.get('clientId'); // Get id from GA
0 commit comments