Skip to main content
Skip table of contents

Get а camera treе

Get a camera tree

The logic of building the tree is divided into 2 possible scenarios depending on the configured env variable TREE_CAMERA_SINGLE_REQUEST_MAX_CAMERAS_COUNT.

When the number of a user's cameras is greater than the value specified in the env variable TREE_CAMERA_SINGLE_REQUEST_MAX_CAMERAS_COUNT, then the tree will be constructed according to the following principle:

This query returns a list of groups at the <i>N</i>th level of nesting. To get the groups at the next level of nesting, you need to repeat the same query, additionally specifying the group_id parameter of the parent group.

In this scenario, the children parameter is not taken into account; it is always null.

Using the has_items parameter, we can determine whether a group contains cameras. If the parameter has_items= to true, it means that the group in question contains cameras and there is no need to query for child groups.

When the number of a user's cameras is less than the value specified in the env variable TREE_CAMERA_SINGLE_REQUEST_MAX_CAMERAS_COUNT, then the tree will return with a single query.

If the children parameter is empty and there are no elements in it, it means that the group is a leaf node.

If a user has bridges with cameras, a Devices folder will be created, containing subfolders for each bridge. These subfolders are terminal points, requiring a separate query to retrieve their cameras (see below).

If a user has cameras with an agent installed, a Cameras folder will be added inside the Devices folder. This group is considered a leaf node, and to retrieve information about the cameras within it, a separate query (described below) must be made.

In both cases, to obtain a list of cameras from a final group, you must use a request for a list of cameras in the group, specifying the group_id parameter and the search parameter, in case if a search was previously carried out in the camera tree
[VMS Client/Cameras/Common queries/List of cameras in the client group]

GET /api/v2/cameras/tree

Parameters

string search – search by address and camera name.

int group_id – an ID of a parent group.

200 OK

Returns a JSON tree object of the same nesting level

JSON
[
    {
        "id": 1,
        "name": "Test Chambers",
        "children": null,
        "has_items": false
    }
]

200 OK

Returns the entire JSON tree object

JSON
[
    {
        "id": 1,
        "name": "Test Chambers",
        "children": [
            {
                "id": 7,
                "name": "fake stream",
                "children": null,
                "has_items": true
            },
            {
                "id": 3,
                "name": "some kind of cameras",
                "children": null,
                "has_items": true
            },
            {
                "id": 4,
                "name": "cameras with archive",
                "children": null,
                "has_items": false
            }
        ],
        "has_items": false
    }
]

401 Unauthorized

The Authorization token not sent or invalid

422 Unprocessable Entity

Returns a JSON object with an error.

JSON
{
    "message": "There will be no informative message here",
    "errors": {
        "any_key": [
            "The cause of the error will be described here"
        ]
    }
}
cURL
BASH
curl -k --request POST \
	--url 'https://your-domain/api/v2/cameras/tree' \
	--header 'Content-Type: application/json' \
	--header 'Accept: application/json' \
	--data '{
    "search": "string",
    "group_id": 0
}'
PHP
PHP
$data = array (
  'search' => 'string',
  'group_id' => 0,
);
$context = stream_context_create([
	'ssl'=>['verify_peer' => false],
	'http' => [
		'method' => 'GET',
		'header' => "Content-Type: application/json\r
Accept: application/json",
		'content'=>json_encode($data)
	]
]);
$result = file_get_contents('https://your-domain/api/v2/cameras/tree', false, $context);
JavaScript errors detected

Please note, these errors can depend on your browser setup.

If this problem persists, please contact our support.