marc-recommend v1.0.5
@flike/recommend
More information about Flike can be found here.
Table of contents
Installation
Quick Start
Classes
Interfaces
Installation
Install the @flike/recommend package:
npm install @flike/recommendQuick Guide
- Install the module as described in Installation.
Import the module into your code
import {Recommender} from '@flike/recommend'Instantiate the
Recommenderwith your API key.const recommender = new Recommender(<your API key>);Call the corresponding methods whenever a user interacts with a content item.
startwhen a user starts interacting with a content item.likewhen a user seems to like a content item. E.g. in the case of a video, calllikewhen the user watched more than 80% of a video.dislikewhen a user seems to dislike a content item. E.g., in the case of a video, calldislikewhen they stop watching after watching less than 50% of it.
- Retrieve recommendations for a user by calling the
recommendmethod. - Filter and sort the recommendations if any constraints need to be considered.
- Display/Use the recommendation in your application in whatever way applicable.
Class: Recommender
Flike Recommender lets you easily log relevant user interactions with content items and recommend content items to users based on their interactions.
Constructors
constructor
• new Recommender(api_key, server_url?, version?)
Parameters
| Name | Type | Description |
|---|---|---|
api_key | string | Your API key. |
server_url? | string | (only used for internal testing) |
version? | string | Version of the API to use. Defaults to the most current version. |
Methods
dislike
▸ dislike(user_id, item_id): Promise<boolean>
Registers a user-started item as 'disliked' by the user. 'Dislike' refers to any action indicating that a user dislikes the content item. E.g., for a video, this could be a user only watching 5% of the video and not finishing it.
Parameters
| Name | Type | Description |
|---|---|---|
user_id | string | The unique identifier of the user. |
item_id | string | The unique identifier of the content item. |
Returns
Promise<boolean>
Resolves to true if successful. Otherwise, it will throw an exception.
like
▸ like(user_id, item_id): Promise<boolean>
Registers a user-started item as 'liked' by the user. 'Like' refers to any action indicating that a user likes the content item. E.g. for a video, this could be a user watching more than 85% of the video.
Parameters
| Name | Type | Description |
|---|---|---|
user_id | string | The unique identifier of the user. |
item_id | string | The unique identifier of the content item. |
Returns
Promise<boolean>
Resolves to true if successful. Otherwise, it will throw an exception.
recommend
▸ recommend(user_id, num_items?): Promise<RecommendationsResponse>
Get an array of content items that a user is probable to consume/buy/subscribe/like or similar. Recommendations are sorted by descending probability of a user 'liking' them.
Parameters
| Name | Type | Description |
|---|---|---|
user_id | string | The unique identifier of the user. |
num_items? | number | Number of content items that should be suggested. |
Returns
Promise<RecommendationsResponse>
Resolves to a RecommendationResponse if successful. Otherwise, it will throw an exception.
start
▸ start(user_id, item_id, correlation_id?): Promise<boolean>
Registers a user starting to consume/interact with a content item.
Parameters
| Name | Type | Description |
|---|---|---|
user_id | string | The unique identifier of the user. |
item_id | string | The unique identifier of the content item. |
correlation_id? | string | The unique identifier of a recommendation. Set this value to attribute a user's interaction to a recommendation. |
Returns
Promise<boolean>
Resolves to true if successful. Otherwise, it will throw an exception.
validate
▸ validate(): Promise<boolean>
Validates the connectivity to the API.
Returns
Promise<boolean>
Resolves to true if the connection is successful, false otherwise.
Interface: Recommendation
Recommendation of a content item for a user.
Table of contents
Properties
Properties
item_id
• item_id: string
Unique identifier of the content item being recommended.
probability
• probability: number
Probability of a user 'liking' the recommended item.
Interface: RecommendationsResponse
Table of contents
Properties
Properties
correlation_id
• correlation_id: string
The unique identifier of this recommendation.
items
• items: Recommendation[]
Recommendations for a user.