PHPackages                             liplum/flarum-trends - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. liplum/flarum-trends

ActiveFlarum-extension[Utility &amp; Helpers](/categories/utility)

liplum/flarum-trends
====================

The trending discussions for Flarum

v0.3.0(1y ago)11.2k↓50%11MITPHP

Since Mar 16Pushed 1y ago1 watchersCompare

[ Source](https://github.com/liplum/flarum-trends)[ Packagist](https://packagist.org/packages/liplum/flarum-trends)[ RSS](/packages/liplum-flarum-trends/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (3)Dependencies (3)Versions (4)Used By (1)

Flarum Trends
=============

[](#flarum-trends)

A [Flarum](http://flarum.org) extension to serve API for trending discussions.

Get Started
-----------

[](#get-started)

### Installation

[](#installation)

To install the dependencies for this extension, run the following commands:

```
composer require michaelbelgium/flarum-discussion-views
composer require liplum/flarum-trends
```

### Update

[](#update)

```
composer update liplum/flarum-trends
```

Usage
-----

[](#usage)

This extension provides an API endpoint to retrieve trending discussions based on recent activity.

### Endpoint

[](#endpoint)

- **`GET /api/trends`**

### Query Parameters

[](#query-parameters)

- **`limit` (integer, optional):** The maximum number of discussions to return. Defaults to `10`.

### Response

[](#response)

The API returns a JSON array of discussion objects. Each discussion object contains the following properties:

- **`id` (string):** The discussion ID.
- **`title` (string):** The discussion title.
- **`commentCount` (integer):** The number of comments in the discussion.
- **`participantCount` (integer):** The number of participants in the discussion.
- **`viewCount` (integer):** The number of views of the discussion.
- **`createdAt` (string):** The creation time of the discussion in ISO 8601 format.
- **`lastActivityAt` (string):** The last activity time of the discussion in ISO 8601 format.
- **`shareUrl` (string):** The URL to share the discussion.
- **`trendingScore` (number):** The trending score of the discussion.
- **`user` (object):** An object containing the user's ID and username.
    - **`id` (string):** The user ID.
    - **`username` (string):** The username.

### Typing

[](#typing)

```
interface TrendingDiscussionsResponse {
  data: TrendingDiscussion[];
}

interface TrendingDiscussion {
  type: 'discussions';
  id: string;
  attributes: {
    title: string;
    commentCount: number;
    participantCount: number;
    viewCount: number;
    createdAt: string;
    lastActivityAt: string;
    shareUrl: string;
    trendingScore: number;
  };
  relationships: {
    user: {
      data: {
        type: 'users';
        id: string;
        attributes: {
          username: string;
        };
      };
    };
  };
}
```

### Example Request

[](#example-request)

```
GET /api/trends/recent?limit=5
```

### Example Response

[](#example-response)

```
{
  "data": [
    {
      "type": "discussions",
      "id": "123",
      "attributes": {
        "title": "Discussion Title 1",
        "commentCount": 50,
        "participantCount": 20,
        "viewCount": 1000,
        "createdAt": "2023-10-27T10:00:00+00:00",
        "lastActivityAt": "2023-10-27T11:30:00+00:00",
        "shareUrl": "https://discuss.flarum.org/d/123",
        "trendingScore": 1234.56
      },
      "relationships": {
        "user": {
          "data": {
            "type": "users",
            "id": "1",
            "attributes": {
              "username": "user1"
            }
          }
        }
      }
    },
    {
      "type": "discussions",
      "id": "456",
      "attributes": {
        "title": "Discussion Title 2",
        "commentCount": 30,
        "participantCount": 15,
        "viewCount": 750,
        "createdAt": "2023-10-26T15:30:00+00:00",
        "lastActivityAt": "2023-10-26T15:30:00+00:00",
        "shareUrl": "https://discuss.flarum.org/d/456",
        "trendingScore": 876.54
      },
      "relationships": {
        "user": {
          "data": {
            "type": "users",
            "id": "2",
            "attributes": {
              "username": "user2"
            }
          }
        }
      }
    }
  ]
}
```

### Trending Score Formula

[](#trending-score-formula)

$S$ = \[($W\_c \\times N\_c$) + ($W\_p \\times N\_p$) + ($W\_v \\times N\_v$)\] $\\times D(days)$

Where:

- $W\_c$: Weight assigned to comment count.
- $N\_c$: Number of comments in the discussion.
- $W\_p$: Weight assigned to participant count.
- $N\_p$: Number of participants in the discussion.
- $W\_v$: Weight assigned to view count.
- $N\_v$: Number of views of the discussion.
- $D(days)$: Decay factor that controls the rate of time decay. It gradually reduces the score over time, reaching zero at the specified time limit.

The trending score is calculated for each discussion, and discussions are then sorted in descending order based on their scores.

### Notes

[](#notes)

- Hidden, locked, and private discussions are excluded from the results.

###  Health Score

28

—

LowBetter than 54% of packages

Maintenance46

Moderate activity, may be stable

Popularity20

Limited adoption so far

Community10

Small or concentrated contributor base

Maturity29

Early-stage or recently created project

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~1 days

Total

3

Last Release

421d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/363621f300451b3ca1cff8e4d33000623eba78b7c6c5bbd456df5cdea721f1e2?d=identicon)[Liplum](/maintainers/Liplum)

---

Top Contributors

[![liplum](https://avatars.githubusercontent.com/u/41872415?v=4)](https://github.com/liplum "liplum (36 commits)")

---

Tags

flarumflarum-extflarum-extensionflarumflarum-extensiontrendstrendingpopularhotflarum-ext

### Embed Badge

![Health badge](/badges/liplum-flarum-trends/health.svg)

```
[![Health](https://phpackages.com/badges/liplum-flarum-trends/health.svg)](https://phpackages.com/packages/liplum-flarum-trends)
```

###  Alternatives

[datlechin/flarum-link-preview

Automatically display a rich preview of the link contents.

1715.9k](/packages/datlechin-flarum-link-preview)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
