Get Stat History

POST /node/api/stat-history

Returns stat history records for specified entities (objects and/or links). Records are always sorted by their timestamps in descending order.

Request parameters

Body parameters

Parameter
Type
Description
after
string
optional
An upper-bound (excluding) timestamp for stat history records. This parameter is applied after the from and to parameters and used for live scrolling. It should NOT be used along with the skip parameter.
exclude
object
optional
A set of parameters used as a filter for history records. Each parameter should be specified in the following format: "payload.param_name": "value". The records that fit the filter will NOT be included to a response.
from
integer
optional
A lower-bound (including) timestamp for stat history records. If not specified, considered equal to the timestamp of the last record.
ids
array<string>
optional
An array of comma-separated entities' ids for which stat history records should be retrieved. Note that if you don't have permissions to some of the specified entities, its stat history won't be returned.
include
object
optional
A set of parameters used as a filter for history records. Each parameter should be specified in the following format: "payload.param_name": "value". The records that DO NOT fit the filter will NOT be included to a response.
limit
integer
optional
The maximum number of history records to be retrieved. The default value is equal to 10.
skip
integer
optional
The number of the first records to be skipped. This parameter is applied after the from and to parameters and used for pagination. It should NOT be used along with the after parameter.
to
integer
optional
An upper-bound (excluding) timestamp for stat history records. If not specified, considered equal to your current local time.

Response description

...

Examples

Request examples

Bash
JavaScript
NodeJS
Python
1
login=<...>
2
password=<...>
3
saymon_hostname=<...>
4
url=https://$saymon_hostname/node/api/stat-history
5
6
curl -X POST $url -u $login:$password \
7
-H "Content-Type: application/json" \
8
-d @- <<EOF
9
{
10
"ids": [
11
"5db30e30aec6940219d5f5fa",
12
"5db2c770aec6940219d5f179"
13
],
14
"limit": 20,
15
"after": 1587743543000,
16
"include": {
17
"payload.operation": 0
18
},
19
"exclude": {
20
"payload.inherited": true
21
}
22
}
23
EOF
Copied!
1
let login = <...>
2
let password = <...>
3
let saymonHostname = <...>
4
let path = "/node/api/stat-history";
5
let auth = "Basic " + btoa(login + ":" + password);
6
7
let headers = new Headers();
8
headers.append("Content-Type", "application/json");
9
headers.append("Authorization", auth);
10
11
let data = JSON.stringify({
12
"ids": [
13
"5db30e30aec6940219d5f5fa",
14
"5db2c770aec6940219d5f179"
15
],
16
"limit": 20,
17
"after": 1587743543000,
18
"include": {
19
"payload.operation": 0
20
},
21
"exclude": {
22
"payload.inherited": true
23
}
24
});
25
26
let requestOptions = {
27
method: "POST",
28
headers: headers,
29
body: data
30
};
31
32
fetch(saymonHostname + path, requestOptions)
33
.then(response => response.text())
34
.then(result => console.log(result))
35
.catch(error => console.log("error", error));
Copied!
1
const http = require("http");
2
3
let login = <...>
4
let password = <...>
5
let saymonHostname = <...>
6
let path = "/node/api/stat-history";
7
let auth = "Basic " + Buffer.from(login + ":" + password).toString("base64");
8
9
let options = {
10
"method": "POST",
11
"hostname": saymonHostname,
12
"path": path,
13
"headers": {
14
"Authorization": auth,
15
"Content-Type": "application/json"
16
}
17
};
18
19
let req = http.request(options, function (res) {
20
let chunks = [];
21
22
res.on("data", function (chunk) {
23
chunks.push(chunk);
24
});
25
26
res.on("end", function (chunk) {
27
let body = Buffer.concat(chunks);
28
console.log(body.toString());
29
});
30
31
res.on("error", function (error) {
32
console.error(error);
33
});
34
});
35
36
let data = JSON.stringify({
37
"ids": [
38
"5db30e30aec6940219d5f5fa",
39
"5db2c770aec6940219d5f179"
40
],
41
"limit": 20,
42
"after": 1587743543000,
43
"include": {
44
"payload.operation": 0
45
},
46
"exclude": {
47
"payload.inherited": true
48
}
49
});
50
51
req.write(data);
52
req.end();
Copied!
1
import requests
2
3
login = <...>
4
password = <...>
5
saymon_hostname = <...>
6
url = "https://" + saymon_hostname + "/node/api/stat-history"
7
8
body = {
9
"ids": [
10
"5db30e30aec6940219d5f5fa",
11
"5db2c770aec6940219d5f179"
12
],
13
"limit": 20,
14
"after": 1587743543000,
15
"include": {
16
"payload.operation": 0
17
},
18
"exclude": {
19
"payload.inherited": True
20
}
21
}
22
23
response = requests.request("POST", url, json=body, auth=(login, password))
24
print(response.text)
Copied!

Response example

1
[
2
{
3
"period": -1,
4
"payload": {
5
"operation": 0
6
},
7
"entityType": "obj",
8
"entityId": "5db2c770aec6940219d5f179",
9
"timestamp": 1577274603993
10
},
11
{
12
"period": -1,
13
"payload": {
14
"operation": 0
15
},
16
"entityType": "obj",
17
"entityId": "5db2c770aec6940219d5f179",
18
"timestamp": 1574855228252
19
},
20
{
21
"period": -1,
22
"payload": {
23
"operation": 0
24
},
25
"entityType": "obj",
26
"entityId": "5db2c770aec6940219d5f179",
27
"timestamp": 1573825706658
28
},
29
...
30
]
Copied!
Last modified 10mo ago