Unicat API Reference

Up - API Reference - Home


/api/p/<project gid>/assets/tree

Requires JWT.

Get the tree, paginated.

This endpoint is meant to power a UI with a scrolling tree-navigation for the assets. The UI keeps track of which paths are currently expanded or not (expanded_assets or expanded_paths), the scroll position (page.top) and panel size (page.size, how many assets fit in the panel) for the tree.

The returned result is an ordered, flat list of assets; but each asset knows its full path (pathname) and if it's expandable (childcount).

Request

You get an asset tree either by specifying the expanded gids in expanded_assets, or by giving the expanded pathnames in the expanded_paths parameter.

If you provide both expanded_assets and expanded_paths parameters, then we use parameter matching to guess what you meant. The first action that matches the parameters is performed, the rest is ignored. Parameter matching happens in the order given below:

POST /api/p/<project gid>/assets/get
Authorization: Bearer <JWT>

{
    "expanded_assets": []
}

or

POST /api/p/<project gid>/assets/get
Authorization: Bearer <JWT>

{
    "expanded_paths": ["/", ]
}

expanded_assets is the list of asset gids for the complete tree that are currently expanded.
expanded_paths is the list of asset pathnames for the complete tree that are currently expanded.

optional

page.top (default 0) only return assets starting from the top-index (0-based).
page.size (default 100) only return this many assets.

Note: if the tree size is 100, the page size is 10, and the page top is 95, you'll actually get the last 10 assets (starting from 90, not 95) - this is to prevent the UI from scrolling to the end and only showing the very last asset, instead of keeping the panel nicely filled.

Success response

Authorization: <JWT>

{
    "success": true,
    "result": {
        "tree": [
            "d96073b1-69da-493e-8433-3820c8cca3a8",
            "e8c7a57f-c83f-408b-b0a1-7625894dabd6",
            
        ],
        "tree.size": 10
    },
    "data": {
        "assets": {
            "d96073b1-69da-493e-8433-3820c8cca3a8": {
                "gid": "d96073b1-69da-493e-8433-3820c8cca3a8",
                "pathname": "/",
                "is_file": false,
                "childcount": 20,
                "path": "",
                "name": "",
                "info": {
                    "filecount": 10,
                    "foldercount": 10
                },
                
            },
            
        }
    }
}

result

tree the requested paginated assets, in tree-order (pathname, then folders by name and files by name).
tree.size the size of the non-paginated tree for the expanded assets.

data

assets Asset info with hierarchy, type, name. Unordered.

For each asset, you can use pathname to determine the indentation (count the number of slashes - except for the root where the indentation is always 0), and childcount to see if this asset is expandable.

Error responses

400 Bad request - missing parameters or wrong type or value
401 Unauthorized - missing or expired JWT
403 Forbidden - not a member of this project