Get All Objects

Returns a list of all objects in the system.

This request doesn’t return all fields of objects by default. Check the Response section for more information.

Request

HTTP Request

GET /node/api/objects

Permissions

objectPermissions

Path parameters

No parameters required.

Query parameters

Parameter Type Description

fields

String

A comma-separated list of objects' fields to be retrieved. See the Object model for all fields.

Request body

The request body is empty.

Response

The response contains an array of all objects in the system in the JSON format.

Fields that are included in the response by default:

Field Type Description

id

String

Object’s ID. Always returned.

name

String

Object’s name.

parent_id

Array<String>

The IDs of an object’s parents.

class_id

Integer

The ID of an object class.

state_id

Integer

The ID of an object state.

last_state_update

Integer

A timestamp when object’s state was last updated.

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.

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.

You can get any fields from an object by specifying them in the fields query parameter. In this case, only specified fields and the object’s id will be included in the response. See the Object model for a list of all possible fields.

Example

Get default fields

Get a default set of fields for every object in the system.

Request

  • Bash

  • JavaScript

  • NodeJS

  • Python

login=<...>
password=<...>
saymon_hostname=<...>
url=https://$saymon_hostname/node/api/objects

curl -X GET $url -u $login:$password
let login = <...>
let password = <...>
let saymonHostname = <...>
let path = "/node/api/objects";
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 path = "/node/api/objects";
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 = <...>
url = "https://" + saymon_hostname + "/node/api/objects"

response = requests.request("GET", url, auth=(login, password))
print(response.text)

Response

[
    {
        "parent_id": [
            "62d7e58056d203149a08001b"
        ],
        "name": "Test Object",
        "class_id": 24,
        "geoposition": [],
        "geopositionRadius": 0,
        "state_id": 1,
        "last_state_update": 1658316250338,
        "child_ids": [],
        "child_link_ids": [],
        "child_ref_ids": [],
        "id": "62d7e5da56d203149a08002f"
    },
    {
        "parent_id": [
            "626a438c4a7f8827220e0ed3"
        ],
        "name": "wlan1",
        "class_id": 11,
        "state_id": 3,
        "last_state_update": 1660514277761,
        "child_ids": [],
        "child_link_ids": [],
        "child_ref_ids": [],
        "geoposition": [],
        "id": "626a438e4a7f8827220e0ede"
    },
    ...
]

Get specific fields

Specify the fields to retrieve during the request.

This example returns only name and parent_id fields from the default set, and a properties array that isn’t included by default. Note that the id field isn’t explicitly set in the query parameters, but is returned anyway.

Request

  • Bash

  • JavaScript

  • NodeJS

  • Python

login=<...>
password=<...>
saymon_hostname=<...>
url=https://$saymon_hostname/node/api/objects?fields=name,parent_id,properties

curl -X GET $url -u $login:$password
let login = <...>
let password = <...>
let saymonHostname = <...>
let queryParams = "fields=name,parent_id,properties";
let path = "/node/api/objects" + "?" + queryParams;
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 queryParams = "fields=name,parent_id,properties";
let path = "/node/api/objects" + "?" + queryParams;
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 = <...>
url = "https://" + saymon_hostname + "/node/api/objects?fields=name,parent_id,properties"

response = requests.request("GET", url, auth=(login, password))
print(response.text)

Response

[
    {
        "parent_id": [
            "62d7e58056d203149a08001b"
        ],
        "name": "Test Object",
        "properties": [
            {
                "type_id": 1,
                "name": "My Property",
                "value": "My Value",
                "id": "62f0f62293d1854858a1fa77",
                "owner_id": "62d7e5da56d203149a08002f",
                "owner_type": 1
            },
    ...
        ],
        "id": "62d7e5da56d203149a08002f"
    },
    {
        "parent_id": [
            "62d7e58056d203149a08001b"
        ],
        "name": "Test Object",
        "properties": [],
        "id": "62d7e5da56d203149a08002f"
    },
]