Trending Items Ranking
Shaped can be used for non-personalized ranking of trending items. Trending items means more than just the most popular items because it also takes into account recency of the items and the rate-of-change of their popularity over a short period. This is a common use-case of Shaped, and can supplement the personalized recommendation options. For example, you might want to have a carousel or feed that shows trending items, but also have a personalized 'For You' feed that shows the most relevant items just to that user.
This guide will show you how easy it is to retrieve these trending item rankings after you've created your Shaped model.
Model Creation
You can use trending items ranking with any of Shaped's models. The popularity of the
items is determined by the counts of interactions and the recency of this popularity is
determined by the interactions created_at
timestamps. We automatically determine the
recency period for your trending items and can detect real-time micro-trends if you
attach a real-time event connector.
Fetching trending items from the Rank API
All you need to do to fetch trending items is make a
rank request
without specifying the user_id
argument. This will return the global top trending
items. Here's an example with our rank CLI:
- JavaScript
- Python
- CLI
npm install @shaped.ai/client
const shapedai = require('@shaped.ai/client');
async function trendingItems() {
const client = shapedai.Client('your_api_key');
const model_name = 'for_you_feed_v1';
const limit = 5;
const results = await client.rank({model_name, limit});
console.log(results);
}
pip install shaped
import shaped
api_key = 'your_api_key'
client = shaped.Client(api_key=api_key)
results = client.rank(
model_name='for_you_feed_v1',
limit=5,
)
pip install shaped
shaped rank --model-name for_you_feed_v1 --limit 5
And with our REST endpoint:
curl https://api.prod.shaped.ai/v1/models/{model_name}/rank \
-H "x-api-key: <API_KEY>" \
-H "Content-Type: application/json"
-d '{
"limit": 10,
}'
Conclusion
Now that you've seen how to use the Rank API to retrieve trending items, you can use it to build real-time popular item feeds and carousels for your users.