# Statistics

# Statistics

The Statistics API returns an ordered array of statistical data. It's usually used to render a table.

GET https://msp_domain/v2/stats/:type

Header

Name Value
Authorization required Personal access token

Path

Name Value
type required The type of statistic. Currently the following 3 are supported topBoxesByBlockedFlows topBoxesBySecurityAlarms topRegionsByBlockedFlows

Query String

Name Value
group Gets statistics for specific group, must be supplied with the ID of a box group. The API returns global statistics by default
limit Max number of results being returned. Defaults to 5

Response

200 Success

A JSON array of Statistics

[
    {
        "meta": {
            "gid":"00000000-0000-0000-0000-000000000000",
            "name":"My Gold",
            "model":"gold"
        },
        "value": 20
    },
    {
        "meta": {
            "gid":"00000000-0000-0000-0000-000000000001",
            "name":"My Purple",
            "model":"purple"
        },
        "value": 10
    }
]

401 Permission Denied

Examples

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 || "topBoxesByBlockedFlows";
const group = process.env.group || "137";


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

# Simple Statistics

This API gives a set of simple statistical numbers. Check out Simple Statistics for more details

GET https://msp_domain/v2/stats/simple

Header

Name Value
Authorization required Personal access token

Query String

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

Response

200 Success

A JSON representation of Simple Statistic

{
    "onlineBoxes": 12,
    "offlineBoxes": 4,
    "alarms": 48,
    "rules": 32
}

401 Permission Denied

Examples

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 group = process.env.end || "137";


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