# Trends
Each of these APIs returns a statistical trend as a time series. They are almost identical except for query strings. For simplicity of documentation, only unique parameters are listed here.

## Flows
The number of blocked flows captured each day.

[!badge variant="primary" text="GET"] <span style="color:grey">https://msp_domain</span>**/v2/trends/flows**

## Alarms
The number of alarms generated each day.

[!badge variant="primary" text="GET"] <span style="color:grey">https://msp_domain</span>**/v2/trends/alarms**

## Rules
The number of rules created each day.

[!badge variant="primary" text="GET"] <span style="color:grey">https://msp_domain</span>**/v2/trends/rules**

## Shared Definitions

<p class="header">Header</p>

| Name                                                       | Value                 |
| ---------------------------------------------------------- | --------------------- |
| Authorization <span style="color:orange">*required*</span> | Personal access token |

<p class="header">Query String</p>

| Name                                           | Value             |
| ---------------------------------------------- | ----------------- |
| group | Gets trends for a specific box group, must be supplied with the ID of a box group. The API returns global statistics by default

<p class="response">Response</p>

<p class="statusCode"><svg class="green" viewBox="0 0 8 16" preserveAspectRatio="xMidYMid meet"><path d="M0 8c0-2.2 1.8-4 4-4s4 1.8 4 4-1.8 4-4 4-4-1.8-4-4z" fill="currentColor" fill-rule="evenodd"></path></svg>
<span>200 Success</span>

</p>

A JSON array of [Trend](../data-models/trend.md/#trend)

```json
[
    { "ts": 1666915200, "value": 53 },
    { "ts": 1666828800, "value": 24 },
    { "ts": 1666742400, "value": 2 },
    { "ts": 1666656000, "value": 22 },
    { "ts": 1666569600, "value": 39 }
]
```

<p class="statusCode">
<svg viewBox="0 0 8 16" preserveAspectRatio="xMidYMid meet" class="brown"><path d="M0 8c0-2.2 1.8-4 4-4s4 1.8 4 4-1.8 4-4 4-4-1.8-4-4z" fill="currentColor" fill-rule="evenodd"></path></svg>
<span>401 Permission Denied</span>
</p>

<p class="examples">Examples</p>

+++ Node.js
```js
const axios = require('axios');

// Change these three configurations to what you need
const msp_domain = process.env.msp_domain || "mydomain.firewalla.net";
const token = process.env.token || "your_personal_access_token";
const type = process.env.type || "alarms";
const group = process.env.group || "137";


axios({
    method: 'get',
    url: `https://${msp_domain}/v2/trends/${type}?group=${group}`,
    headers: {
        Authorization: `Token ${token}`,
        "Content-Type": "application/json"
    }
}).then((res) => {
    let data = res.data;
    console.log(data);
})
```
+++ cURL
```bash
curl --request GET  \
--url "https://${msp_domain}/v2/trends/${type}?group=${group}" \
--header "Authorization: Token ${your_personal_access_token}"
```
+++
