Get Link’s Parent Paths
Request
Response
Response contains two lists — paths
and objects
.
-
paths
contains IDs of every parent object (including the root object) and the ID of the requested link’s source object. The first element in the list is the link’s source object, the last is the root object. -
objects
list contains information about each object in the path. You can select returned fields with thefields
query parameter. You can see the list of all possible fields in the Object model article.
If the object has multiple paths to the root (for example, there is an object with multiple parents in the path), the path list will contain a list of all possible paths. Entries in the objects list will not be duplicated.
|
By default, each object includes the following fields:
Field | Type | Description |
---|---|---|
id |
String |
Object’s ID. |
name |
String |
Object’s name. |
class_id |
String |
The ID of an object class. |
child_ids |
Array<String> |
An array of object’s child objects IDs. |
child_link_ids |
Array<String> |
An array of object’s child links IDs. |
child_ref_ids |
Array<String> |
An array of object’s child references IDs. |
parent_id |
Array<String> |
The IDs of an object’s parents. |
geoposition |
Array<Float> |
Object’s position on a map. It’s specified as an array of two float numbers, where the first number is longitude, the second one is latitude. |
geopositionRadius |
Integer |
The radius of an object’s area displayed on a map. |
state_id |
String |
The ID of an object state. |
last_state_update |
Integer |
A timestamp when object’s state was last updated. |
Examples
Request
-
Bash
-
JavaScript
-
NodeJS
-
Python
login=<...>
password=<...>
saymon_hostname=<...>
link_id=<...>
url=https://$saymon_hostname/node/api/links/$link_id/paths
curl -X GET $url -u $login:$password
let login = <...>
let password = <...>
let saymonHostname = <...>
let linkId = <...>
let path = "/node/api/links/" + linkId + "/paths";
let auth = "Basic " + btoa(login + ":" + password);
let headers = new Headers();
headers.append("Authorization", auth);
let requestOptions = {
method: "GET",
headers: headers
};
fetch(saymonHostname + path, requestOptions)
.then(response => response.text())
.then(result => console.log(result))
.catch(error => console.log("error", error));
const http = require("http");
let login = <...>
let password = <...>
let saymonHostname = <...>
let linkId = <...>
let path = "/node/api/links/" + linkId + "/paths";
let auth = "Basic " + Buffer.from(login + ":" + password).toString("base64");
let options = {
"method": "GET",
"hostname": saymonHostname,
"headers": {
"Authorization": auth
},
"path": path
};
let req = http.request(options, function (res) {
let chunks = [];
res.on("data", function (chunk) {
chunks.push(chunk);
});
res.on("end", function (chunk) {
let body = Buffer.concat(chunks);
console.log(body.toString());
});
res.on("error", function (error) {
console.error(error);
});
});
req.end();
import requests
login = <...>
password = <...>
saymon_hostname = <...>
link_id = <...>
url = "https://" + saymon_hostname + "/node/api/links/" + link_id + "/paths"
response = requests.request("GET", url, auth=(login, password))
print(response.text)