# Popular & Trending

> Source: https://docs.recombee.com/recipes/video/fully-personalized-homepage/popular-and-trending

> For the complete documentation index, see [llms.txt](/llms.txt).

**Table of contents**

* [Introduction](#introduction)
* [Scenario Setup](#scenario-setup)
* [Logic](#logic)
* [Filters](#filters)
* [Boosters](#boosters)
* [Constraints](#constraints)  
   * [Diversify the Genres of Recommended Assets](#diversify-the-genres-of-recommended-assets)
* [Requesting Recommendations](#requesting-recommendations)

# Popular & Trending

![](/img/recipes/video/popular-and-trending.png) 

## Introduction

This scenario brings your users the hottest and most trending videos in real-time. From viral hits to rising stars, your users can immerse themselves in a dynamic selection that reflects the pulse of the video community.

## Scenario Setup

In the Recombee Admin UI, navigate to the **[Scenarios](/scenarios)** section and choose **Create Scenario**.

1. Enter a **Scenario ID**, such as _"popular-movies-and-series"_
2. Choose **Recommendation type** \- _[Items to User](/api#recommend-items-to-user)_

![Admin UI - Scenario Setup](/img/recipes/video/popular-and-trending-create-scenario.png)

## Logic

The [Logic](/recommendation_logics) defines the behavior of the recommendation engine.

* Choose the **[video:popular](/recommendation_logics#video-popular)** logic type from the **Video** models to get the popular assets among the users

The `timePeriod` specifies the time period in which the the popularity is measured. Therefore you can have e.g. _Popular This Month_ by setting the parameter to 30 days, or get recently trending content by setting the parameter to 7 days.

More advanced use cases such as _Popular in Your Country_ can be achieved by setting the `userSegmentFilter` parameter, which specifies which users will be considered when computing the popularity.

The parameter accepts a ReQL filter on top of the user properties - only the users that pass the filter will considered. Assuming that the users have a property called country and you want to recommend assets popular in the particular user’s country, the parameter shall be set to `‘country’ == context_user[“country”]`.

The `assetType` parameter specifies what type of assets will be returned (e.g. movies, series, episodes, movies and episodes, etc.).

![Admin UI - Logic](/img/recipes/video/popular-and-trending-logic.png)

## Filters

Available Assets (Global Settings)

You always want to recommend only movies, series, and episodes that are currently available to watch for your users. Therefore you need to apply a [**Filter**](/scenarios#filters) rule to allow only such assets.

As it would be tedious and prone to error to add this rule to all the Scenarios, this rule shall be added to the [**Global Settings**](/scenarios#global-settings), so it is always applied everywhere.

**The particular filter depends on how you specify such assets in your catalog:**

* If you have a **boolean property** that marks the asset as available you can use the predefined _Available items \[boolean\]_ rule.
* If you have a **timestamp property** that specifies when the asset is published (becomes available) you can use the predefined _Published items rule_.
* Or if you have a **licensing window (start date, end date)** you can use the predefined _Items within their licensing window_ rule.
* In every other case, you can create a [**custom filter rule**](/reql) to allow only the available assets according to your own logic.

![Admin UI - Global Settings - Filter](/img/recipes/video/filter.png)

## Boosters

Boost Content Picked by the Editorial Team

You may want to boost the assets the editorial team picked as preferred.

If you export this flag from your CMS as a **boolean property,** you can apply the _Boost editors' picks_ predefined rule in the **Boosters** tab of the **Scenario**.

[![Admin UI - Booster - Boost editors' picks](/img/recipes/video/booster-editor-picks.png)](/img/recipes/video/booster-editor-picks.png)

You can find the appropriate level of boosting using the **Preview.**

[![Admin UI - Booster - Boost editors' picks - Preview](/img/recipes/video/booster-editor-picks-preview.png)](/img/recipes/video/booster-editor-picks-preview.png)

## Constraints

### Diversify the Genres of Recommended Assets

You may want to show the user popular content from various genres, preventing the situation when all the content is from the same category, and may not attract the user.

In order to do this, navigate to the [Constraints](/scenarios#constraints) tab of the Scenario, and add a new Constraint.

The Constraint will be based on an Item [Segmentation](/segmentations) that splits the items by their genre. If you already have such Segmentation and you can pick it from the list, otherwise, you can create a new Segmentation based on the property that specifies the genre of the assets.

Now you can specify the limit and allow e.g. up to 3 assets from a single genre, or up to 50% (with `Limit` type set to percentage) of the recommended items in the row to be of a single genre.

## Requesting Recommendations

There are three ways to get recommendations.

1. **[No-Code Widget](/no-code-widgets)** \- create a No-Code Widget using the **visual editor in the Admin UI.**
2. **[Widget SDKs](/widget-sdks)** \- use the SDK for a [Carousel](/widget-sdks#carousel), [Grid](/widget-sdks#grid) or [Feed](/widget-sdks#feed) to display the recommendations in the design of your choice. Use the [Recommend Items to User endpoint](/api#recommend-items-to-user) when initializing the widget.
3. **[API SDK](/api_clients)** \- request the [Recommend Items to User endpoint](/api#recommend-items-to-user) of the Recombee API using an SDK of your choice.

For more information navigate to the Integration tab of the Scenario in the Admin UI.

In order to request content for multiple rows with a single API request, use the [Batch endpoint](/api#batch) and put the recommendation requests inside it. Set the parameter `distinctRecomms` in order to [deduplicate the assets among the rows](/api#batch-example-using-distinctrecomms-parameter-to-deduplicate-results-in-multiple-boxes).