---
title: List the tree
summary: Find the root node, list a folder, walk a subtree, and look a node up by path or by one of its versions.
order: 30
languages: [javascript, java, csharp, php]
terms: [node, version, vid]
see-also: [how-to/models/create-a-folder, how-to/models/upload-a-model, explanation/nodes-versions-and-the-tree, explanation/identifiers]
---

# List the tree

For any integration that needs to know what is in BIM.works before it queries, views or uploads. The tree starts at the root [[term:node|node]] of your credential; each node is a folder or a model, and a model node carries its [[term:version|versions]], the newest as `last_version_uuid`.

## Before you start

- A login with the `fs:read` scope ([[page:how-to/auth/log-in-with-an-api-token]]).

## 1. Start at the root

```code-group {#root} classic
```javascript
const root = await client.fs.getNodeByPath("/");     // the node, or
const rootUuid = await client.fs.getRootNodeUuid();  // only its UUID
```
```java
TreeNode root = client.fs.getRootNode();
UUID rootUuid = client.fs.getRootNodeUuid();
```
```csharp
TreeNode root = client.Fs.GetRootNode();
Guid rootUuid = client.Fs.GetRootNodeUuid();
```
```

```sdk-example
operation: GetRootNodeUuid
```

The root depends on the credential: the account's folder, the folder an API token was created on, or the node of a delegated token. Over HTTP: [[openapi:GetRootNodeUuid]].

## 2. List a folder

```code-group {#list} classic
```javascript
const listing = await client.fs.listNodes(rootUuid);
for (const node of listing.nodes) {
	console.log(node.folder ? "folder" : "model", node.name, node.last_version_uuid);
}
```
```java
import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.node.ObjectNode;

ObjectNode listing = client.fs.listNodes(rootUuid, false);
for (JsonNode node : listing.get("nodes")) {
	System.out.println(node.get("folder").asBoolean() + " " + node.get("name").asText() + " " + node.path("last_version_uuid").asText());
}
```
```csharp
foreach (TreeNode node in client.Fs.ListNodes(rootUuid))
{
    Console.WriteLine($"{(node.IsFolder ? "folder" : "model")} {node.Name} {(node.Versions.Count > 0 ? node.GetLastVersion().Uuid.ToString() : "")}");
}
```
```

```sdk-example
operation: ListNodes
body: |
  {
    "path": "/"
  }
```

`listNodes` returns the direct children; deleted nodes are left out (an administrator can include them with `show_deleted_nodes`). The JavaScript and Java replies are the server's object: `nodes`, plus `fullpath` (the ancestors up to the root) and, for accounts, `parent`. The methods: [[js:@bimworks/jssdk/Fs|Fs]], [[java:nl.bimbase.bimworks.client.apis.FileSystemApi|FileSystemApi]], [[dotnet:BIM.works_SDK.Fs|Fs]], `FsApi::listNodes` in [[page:reference/sdk/php]]; over HTTP [[openapi:ListNodes]] with `uuid`, `path` or `version_uuid`:

```try-it
operation: ListNodes
method: POST
path: /openapi/fs/ListNodes
body: |
  {
    "path": "/"
  }
```

Every node in a listing has at least `uuid`, `name`, `folder`, `path` (relative to your root), `type`, `last_version_uuid` (null for a model without a finished version), `last_version_number`, `versions` and `errors`; [[openapi:GetNode]] documents the whole record.

## 3. Walk a subtree

`listNodesRecursive` returns every node below a folder as one flat list, each with its `path`; there is no paging, so use it on project folders rather than on a large root.

```code-group {#recursive} classic
```javascript
const all = await client.fs.listNodesRecursive(folderUuid);
const models = all.nodes.filter((node) => !node.folder && node.last_version_uuid);
```
```java
ObjectNode all = client.fs.listNodesRecursive(folderUuid);
```
```csharp
List<TreeNode> all = client.Fs.ListNodesRecursive(folderUuid);
```
```

```sdk-example
operation: ListNodesRecursive
body: |
  {
    "uuid": "<folder uuid>"
  }
```

Over HTTP: [[openapi:ListNodesRecursive]].

## 4. Look a node up

By path, relative to your root and with forward slashes, or by the UUID of one of its versions (the way back from a query result's [[term:vid|vid]] to its node):

```code-group {#lookup} classic
```javascript
const model = await client.fs.getNodeByPath("/Project A/house.ifc");
const byVersion = await client.fs.getNodeByVersionUuid(BIM_WORKS_FIRST_MODEL);
```
```java
TreeNode model = client.fs.getNodeByPath("/Project A/house.ifc");
TreeNode byVersion = client.fs.getNodeByVersionUuid(UUID.fromString(BIM_WORKS_FIRST_MODEL));
```
```csharp
TreeNode model = client.Fs.GetNodeByPath("/Project A/house.ifc");
TreeNode byVersion = client.Fs.GetNodeByVersionUuid(Guid.Parse(BIM_WORKS_FIRST_MODEL));
```
```

```sdk-example
operation: GetNode
body: |
  {
    "path": "/Project A/house.ifc"
  }
```

A path that does not exist fails with [[error:NODE_NOT_FOUND]]; over HTTP the operation is [[openapi:GetNode]] with `path`, `uuid` or `version_uuid`, and [[openapi:GetVersion]] returns one version record.

## Check

`getNodeByPath("/")` and `getNodeByUuid(rootUuid)` describe the same node, and every child in `listNodes(rootUuid)` has a `path` that starts with `/` followed by its name. A model you uploaded ([[page:how-to/models/upload-a-model]]) shows its version in `versions` and the same UUID in `last_version_uuid`.
