npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

marc-recommend

v1.0.5

Published

Wrapper for the Flike Recommendation API.

Downloads

4

Readme

@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/recommend

Quick Guide

  1. Install the module as described in Installation.

  2. Import the module into your code

    import {Recommender} from '@flike/recommend'

  3. Instantiate the Recommender with your API key.

    const recommender = new Recommender(<your API key>);

  4. Call the corresponding methods whenever a user interacts with a content item.

    • start when a user starts interacting with a content item.
    • like when a user seems to like a content item. E.g. in the case of a video, call like when the user watched more than 80% of a video.
    • dislike when a user seems to dislike a content item. E.g., in the case of a video, call dislike when they stop watching after watching less than 50% of it.
  5. Retrieve recommendations for a user by calling the recommend method.

  6. Filter and sort the recommendations if any constraints need to be considered.

  7. 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.