Get Object's State History

GET /node/api/objects/:id/state-history

Returns object's state history.
Permissions: objectPermissions.

Request parameters

Path parameters

Parameter
Type
Description
id
string
required
The ID or discovery ID of the object for which state history must be retrieved.

Query parameters

Parameter
Type
Description
from
string
optional
A lower-bound timestamp for an object's state history.
limit
string
optional
The maximum number of records to be retrieved.
skip
string
optional
The number of the first records to be skipped.
to
string
optional
An upper-bound timestamp for an object's state history.

Response description

...

Examples

Request examples

The code examples below show how to get the first 5 records of the object's state history for 24 hour (26.01.20 12.00 PM - 27.01.20 12.00 PM):
Bash
JavaScript
NodeJS
Python
1
login=<...>
2
password=<...>
3
saymon_hostname=<...>
4
object_id=<...>
5
url=https://$saymon_hostname/node/api/objects/$object_id/state-history
6
7
curl -X GET $url -u $login:$password -G \
8
--data-urlencode "from=1580029200000" \
9
--data-urlencode "to=1580115600000" \
10
--data-urlencode "limit=5"
Copied!
1
let login = <...>
2
let password = <...>
3
let saymonHostname = <...>
4
let objectId = <...>
5
let path = "/node/api/objects/" + objectId + "/state-history";
6
let auth = "Basic " + btoa(login + ":" + password);
7
8
let headers = new Headers();
9
headers.append("Authorization", auth);
10
11
let requestOptions = {
12
method: "GET",
13
headers: headers
14
};
15
16
fetch(saymonHostname + path, requestOptions)
17
.then(response => response.text())
18
.then(result => console.log(result))
19
.catch(error => console.log("error", error));
Copied!
1
const http = require("http");
2
const querystring = require("querystring");
3
4
let login = <...>
5
let password = <...>
6
let saymonHostname = <...>
7
let objectId = <...>
8
9
let queryParams = querystring.stringify({
10
"from" : "1580029200000",
11
"to" : "1580115600000",
12
"limit" : "5"
13
});
14
15
let path = "/node/api/objects/" + objectId + "/state-history" +
16
"?" + queryParams;
17
let auth = "Basic " + Buffer.from(login + ":" + password).toString("base64");
18
19
let options = {
20
"method": "GET",
21
"hostname": saymonHostname,
22
"headers": {
23
"Authorization": auth
24
},
25
"path": path
26
};
27
28
let req = http.request(options, function (res) {
29
let chunks = [];
30
31
res.on("data", function (chunk) {
32
chunks.push(chunk);
33
});
34
35
res.on("end", function (chunk) {
36
let body = Buffer.concat(chunks);
37
console.log(body.toString());
38
});
39
40
res.on("error", function (error) {
41
console.error(error);
42
});
43
});
44
45
req.end();
Copied!
1
import requests
2
3
login = <...>
4
password = <...>
5
saymon_hostname = <...>
6
object_id = <...>
7
url = "https://" + saymon_hostname + "/node/api/objects/" + \
8
object_id + "/state-history"
9
10
params = {
11
"from": "1580029200000",
12
"to": "1580115600000",
13
"limit": "5"
14
}
15
16
response = requests.request("GET", url, auth=(login, password), params=params)
17
print(response.text)
Copied!

Response example

1
[
2
{
3
"stateId": 1,
4
"timestamp": 1585301115993,
5
"id": "5e7dc67bc50bdc08abbf16b9"
6
},
7
{
8
"stateId": 3,
9
"reason": {
10
"branch": "...",
11
"data": "..."
12
},
13
"timestamp": 1585301127083,
14
"id": "5e7dc687c50bdc08abbf1728"
15
},
16
...
17
]
Copied!