List the tree
Find the root node, list a folder, walk a subtree, and look a node up by path or by one of its versions.
For any integration that needs to know what is in BIM.works before it queries, views or uploads. The tree starts at the root node of your credential; each node is a folder or a model, and a model node carries its versions, the newest as last_version_uuid.
Before you start#
- A login with the
fs:readscope (Log in with an API token).
1. Start at the root#
const root = await client.fs.getNodeByPath("/"); // the node, or
const rootUuid = await client.fs.getRootNodeUuid(); // only its UUIDTreeNode root = client.fs.getRootNode();
UUID rootUuid = client.fs.getRootNodeUuid();TreeNode root = client.Fs.GetRootNode();
Guid rootUuid = client.Fs.GetRootNodeUuid();import nl.bimbase.bimworks.sdk.api.AuthApi;
import nl.bimbase.bimworks.sdk.api.FsApi;
import nl.bimbase.bimworks.sdk.client.ApiClient;
import nl.bimbase.bimworks.sdk.model.Auth;
import nl.bimbase.bimworks.sdk.model.LoginWithApiTokenRequest;
public class Example {
public static void main(String[] args) throws Exception {
// 1. Connect to BIM.works and log in with your API token
ApiClient client = new ApiClient();
client.updateBaseUri("https://bim.works/openapi");
Auth auth = new AuthApi(client)
.loginWithApiToken(new LoginWithApiTokenRequest().token("<your API token>"))
.getAuth();
client.setRequestInterceptor(builder -> builder.setHeader("Authorization", "Bearer " + auth.getBase64()));
// 2. The request
// (GetRootNodeUuid takes no request)
// 3. The call
var result = new FsApi(client).getRootNodeUuid();
// 4. The result
System.out.println(client.getObjectMapper().writerWithDefaultPrettyPrinter().writeValueAsString(result));
}
}using System.Text.Json;
using BIMworks.Sdk.Api;
using BIMworks.Sdk.Client;
using BIMworks.Sdk.Extensions;
using BIMworks.Sdk.Model;
using Microsoft.Extensions.DependencyInjection;
// 1. Connect to BIM.works and log in with your API token
IServiceProvider Connect(string bearer)
{
var services = new ServiceCollection();
services.AddApi(options =>
{
options.AddTokens(new BearerToken(bearer));
options.AddApiHttpClients(http =>
{
http.BaseAddress = new Uri("https://bim.works" + "/openapi");
http.Timeout = Timeout.InfiniteTimeSpan;
});
});
return services.BuildServiceProvider();
}
var login = await Connect("").GetRequiredService<IAuthApi>().LoginWithApiTokenAsync(new LoginWithApiTokenRequest("<your API token>"));
var auth = login.Ok()?.Auth ?? throw new HttpRequestException(login.RawContent, null, login.StatusCode);
var client = Connect(auth.Base64);
var json = client.GetRequiredService<JsonSerializerOptionsProvider>().Options;
// 2. The request
// (GetRootNodeUuid takes no request)
// 3. The call
var response = await client.GetRequiredService<IFsApi>().GetRootNodeUuidAsync();
// 4. The result
var result = response.Ok() ?? throw new HttpRequestException(response.RawContent, null, response.StatusCode);
Console.WriteLine(JsonSerializer.Serialize(result, json));import { AuthApi, Configuration, FsApi } from "@bimworks/sdk";
// 1. Connect to BIM.works and log in with your API token
const basePath = "https://bim.works/openapi";
const auth = await new AuthApi(new Configuration({ basePath }))
.loginWithApiToken({ loginWithApiTokenRequest: { token: "<your API token>" } });
const client = new Configuration({ basePath, accessToken: typeof auth === "string" ? auth : auth.base64 });
// 2. The request
// (GetRootNodeUuid takes no request)
// 3. The call
const result = await new FsApi(client).getRootNodeUuid();
// 4. The result
console.log(result);<?php
require __DIR__ . '/vendor/autoload.php';
use BIMworks\Api\AuthApi;
use BIMworks\Api\FsApi;
use BIMworks\Configuration;
use BIMworks\Model\LoginWithApiTokenRequest;
// 1. Connect to BIM.works and log in with your API token
$client = (new Configuration())->setHost('https://bim.works/openapi');
$auth = (new AuthApi(config: $client))->loginWithApiToken(new LoginWithApiTokenRequest(['token' => "<your API token>"]));
$client->setAccessToken($auth->getBase64());
// 2. The request
// (GetRootNodeUuid takes no request)
// 3. The call
$result = (new FsApi(config: $client))->getRootNodeUuid();
// 4. The result
echo $result, PHP_EOL;import json
import bimworks
# 1. Connect to BIM.works and log in with your API token
client = bimworks.ApiClient(bimworks.Configuration(host="https://bim.works/openapi"))
auth = bimworks.AuthApi(client).login_with_api_token(
bimworks.LoginWithApiTokenRequest(token="<your API token>"))
client.configuration.access_token = auth.actual_instance.var_base64
# 2. The request
# (GetRootNodeUuid takes no request)
# 3. The call
result = bimworks.FsApi(client).get_root_node_uuid()
# 4. The result
print(json.dumps(client.sanitize_for_serialization(result), indent=2))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: GetRootNodeUuid.
2. List a folder#
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);
}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());
}foreach (TreeNode node in client.Fs.ListNodes(rootUuid))
{
Console.WriteLine($"{(node.IsFolder ? "folder" : "model")} {node.Name} {(node.Versions.Count > 0 ? node.GetLastVersion().Uuid.ToString() : "")}");
}import nl.bimbase.bimworks.sdk.api.AuthApi;
import nl.bimbase.bimworks.sdk.api.FsApi;
import nl.bimbase.bimworks.sdk.client.ApiClient;
import nl.bimbase.bimworks.sdk.model.Auth;
import nl.bimbase.bimworks.sdk.model.ListNodesRequest;
import nl.bimbase.bimworks.sdk.model.LoginWithApiTokenRequest;
public class Example {
public static void main(String[] args) throws Exception {
// 1. Connect to BIM.works and log in with your API token
ApiClient client = new ApiClient();
client.updateBaseUri("https://bim.works/openapi");
Auth auth = new AuthApi(client)
.loginWithApiToken(new LoginWithApiTokenRequest().token("<your API token>"))
.getAuth();
client.setRequestInterceptor(builder -> builder.setHeader("Authorization", "Bearer " + auth.getBase64()));
// 2. The request
ListNodesRequest request = client.getObjectMapper().readValue("""
{
"path": "/"
}
""", ListNodesRequest.class);
// 3. The call
var result = new FsApi(client).listNodes(request);
// 4. The result
System.out.println(client.getObjectMapper().writerWithDefaultPrettyPrinter().writeValueAsString(result));
}
}using System.Text.Json;
using BIMworks.Sdk.Api;
using BIMworks.Sdk.Client;
using BIMworks.Sdk.Extensions;
using BIMworks.Sdk.Model;
using Microsoft.Extensions.DependencyInjection;
// 1. Connect to BIM.works and log in with your API token
IServiceProvider Connect(string bearer)
{
var services = new ServiceCollection();
services.AddApi(options =>
{
options.AddTokens(new BearerToken(bearer));
options.AddApiHttpClients(http =>
{
http.BaseAddress = new Uri("https://bim.works" + "/openapi");
http.Timeout = Timeout.InfiniteTimeSpan;
});
});
return services.BuildServiceProvider();
}
var login = await Connect("").GetRequiredService<IAuthApi>().LoginWithApiTokenAsync(new LoginWithApiTokenRequest("<your API token>"));
var auth = login.Ok()?.Auth ?? throw new HttpRequestException(login.RawContent, null, login.StatusCode);
var client = Connect(auth.Base64);
var json = client.GetRequiredService<JsonSerializerOptionsProvider>().Options;
// 2. The request
var request = JsonSerializer.Deserialize<ListNodesRequest>("""
{
"path": "/"
}
""", json);
// 3. The call
var response = await client.GetRequiredService<IFsApi>().ListNodesAsync(request);
// 4. The result
var result = response.Ok() ?? throw new HttpRequestException(response.RawContent, null, response.StatusCode);
Console.WriteLine(JsonSerializer.Serialize(result, json));import { AuthApi, Configuration, FsApi, ListNodesRequestFromJSON, NodeToJSON } from "@bimworks/sdk";
// 1. Connect to BIM.works and log in with your API token
const basePath = "https://bim.works/openapi";
const auth = await new AuthApi(new Configuration({ basePath }))
.loginWithApiToken({ loginWithApiTokenRequest: { token: "<your API token>" } });
const client = new Configuration({ basePath, accessToken: typeof auth === "string" ? auth : auth.base64 });
// 2. The request
const request = ListNodesRequestFromJSON({
"path": "/"
});
// 3. The call
const result = await new FsApi(client).listNodes({ listNodesRequest: request });
// 4. The result
console.log(JSON.stringify(result.map(NodeToJSON), null, 2));<?php
require __DIR__ . '/vendor/autoload.php';
use BIMworks\Api\AuthApi;
use BIMworks\Api\FsApi;
use BIMworks\Configuration;
use BIMworks\Model\ListNodesRequest;
use BIMworks\Model\LoginWithApiTokenRequest;
use BIMworks\ObjectSerializer;
// 1. Connect to BIM.works and log in with your API token
$client = (new Configuration())->setHost('https://bim.works/openapi');
$auth = (new AuthApi(config: $client))->loginWithApiToken(new LoginWithApiTokenRequest(['token' => "<your API token>"]));
$client->setAccessToken($auth->getBase64());
// 2. The request
$request = ObjectSerializer::deserialize(<<<'JSON'
{
"path": "/"
}
JSON, ListNodesRequest::class);
// 3. The call
$result = (new FsApi(config: $client))->listNodes($request);
// 4. The result
echo json_encode($result, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES), PHP_EOL;import json
import bimworks
# 1. Connect to BIM.works and log in with your API token
client = bimworks.ApiClient(bimworks.Configuration(host="https://bim.works/openapi"))
auth = bimworks.AuthApi(client).login_with_api_token(
bimworks.LoginWithApiTokenRequest(token="<your API token>"))
client.configuration.access_token = auth.actual_instance.var_base64
# 2. The request
request = bimworks.ListNodesRequest.from_json(r"""
{
"path": "/"
}
""")
# 3. The call
result = bimworks.FsApi(client).list_nodes(request)
# 4. The result
print(json.dumps(client.sanitize_for_serialization(result), indent=2))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: Fs, FileSystemApi, Fs, FsApi::listNodes in PHP SDK; over HTTP ListNodes with uuid, path or version_uuid:
Bearer <auth token>application/jsonAuthorization: Bearer <auth token>
Content-Type: application/json
Accept: application/jsoncurl -X POST "$BIMWORKS_URL/openapi/fs/ListNodes" \
-H "Authorization: Bearer $BIMWORKS_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"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; 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.
const all = await client.fs.listNodesRecursive(folderUuid);
const models = all.nodes.filter((node) => !node.folder && node.last_version_uuid);ObjectNode all = client.fs.listNodesRecursive(folderUuid);List<TreeNode> all = client.Fs.ListNodesRecursive(folderUuid);import nl.bimbase.bimworks.sdk.api.AuthApi;
import nl.bimbase.bimworks.sdk.api.FsApi;
import nl.bimbase.bimworks.sdk.client.ApiClient;
import nl.bimbase.bimworks.sdk.model.Auth;
import nl.bimbase.bimworks.sdk.model.ListNodesRecursiveRequest;
import nl.bimbase.bimworks.sdk.model.LoginWithApiTokenRequest;
public class Example {
public static void main(String[] args) throws Exception {
// 1. Connect to BIM.works and log in with your API token
ApiClient client = new ApiClient();
client.updateBaseUri("https://bim.works/openapi");
Auth auth = new AuthApi(client)
.loginWithApiToken(new LoginWithApiTokenRequest().token("<your API token>"))
.getAuth();
client.setRequestInterceptor(builder -> builder.setHeader("Authorization", "Bearer " + auth.getBase64()));
// 2. The request
ListNodesRecursiveRequest request = client.getObjectMapper().readValue("""
{
"uuid": "<folder uuid>"
}
""", ListNodesRecursiveRequest.class);
// 3. The call
var result = new FsApi(client).listNodesRecursive(request);
// 4. The result
System.out.println(client.getObjectMapper().writerWithDefaultPrettyPrinter().writeValueAsString(result));
}
}using System.Text.Json;
using BIMworks.Sdk.Api;
using BIMworks.Sdk.Client;
using BIMworks.Sdk.Extensions;
using BIMworks.Sdk.Model;
using Microsoft.Extensions.DependencyInjection;
// 1. Connect to BIM.works and log in with your API token
IServiceProvider Connect(string bearer)
{
var services = new ServiceCollection();
services.AddApi(options =>
{
options.AddTokens(new BearerToken(bearer));
options.AddApiHttpClients(http =>
{
http.BaseAddress = new Uri("https://bim.works" + "/openapi");
http.Timeout = Timeout.InfiniteTimeSpan;
});
});
return services.BuildServiceProvider();
}
var login = await Connect("").GetRequiredService<IAuthApi>().LoginWithApiTokenAsync(new LoginWithApiTokenRequest("<your API token>"));
var auth = login.Ok()?.Auth ?? throw new HttpRequestException(login.RawContent, null, login.StatusCode);
var client = Connect(auth.Base64);
var json = client.GetRequiredService<JsonSerializerOptionsProvider>().Options;
// 2. The request
var request = JsonSerializer.Deserialize<ListNodesRecursiveRequest>("""
{
"uuid": "<folder uuid>"
}
""", json);
// 3. The call
var response = await client.GetRequiredService<IFsApi>().ListNodesRecursiveAsync(request);
// 4. The result
var result = response.Ok() ?? throw new HttpRequestException(response.RawContent, null, response.StatusCode);
Console.WriteLine(JsonSerializer.Serialize(result, json));import { AuthApi, Configuration, FsApi, ListNodesRecursiveRequestFromJSON, NodeToJSON } from "@bimworks/sdk";
// 1. Connect to BIM.works and log in with your API token
const basePath = "https://bim.works/openapi";
const auth = await new AuthApi(new Configuration({ basePath }))
.loginWithApiToken({ loginWithApiTokenRequest: { token: "<your API token>" } });
const client = new Configuration({ basePath, accessToken: typeof auth === "string" ? auth : auth.base64 });
// 2. The request
const request = ListNodesRecursiveRequestFromJSON({
"uuid": "<folder uuid>"
});
// 3. The call
const result = await new FsApi(client).listNodesRecursive({ listNodesRecursiveRequest: request });
// 4. The result
console.log(JSON.stringify(result.map(NodeToJSON), null, 2));<?php
require __DIR__ . '/vendor/autoload.php';
use BIMworks\Api\AuthApi;
use BIMworks\Api\FsApi;
use BIMworks\Configuration;
use BIMworks\Model\ListNodesRecursiveRequest;
use BIMworks\Model\LoginWithApiTokenRequest;
use BIMworks\ObjectSerializer;
// 1. Connect to BIM.works and log in with your API token
$client = (new Configuration())->setHost('https://bim.works/openapi');
$auth = (new AuthApi(config: $client))->loginWithApiToken(new LoginWithApiTokenRequest(['token' => "<your API token>"]));
$client->setAccessToken($auth->getBase64());
// 2. The request
$request = ObjectSerializer::deserialize(<<<'JSON'
{
"uuid": "<folder uuid>"
}
JSON, ListNodesRecursiveRequest::class);
// 3. The call
$result = (new FsApi(config: $client))->listNodesRecursive($request);
// 4. The result
echo json_encode($result, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES), PHP_EOL;import json
import bimworks
# 1. Connect to BIM.works and log in with your API token
client = bimworks.ApiClient(bimworks.Configuration(host="https://bim.works/openapi"))
auth = bimworks.AuthApi(client).login_with_api_token(
bimworks.LoginWithApiTokenRequest(token="<your API token>"))
client.configuration.access_token = auth.actual_instance.var_base64
# 2. The request
request = bimworks.ListNodesRecursiveRequest.from_json(r"""
{
"uuid": "<folder uuid>"
}
""")
# 3. The call
result = bimworks.FsApi(client).list_nodes_recursive(request)
# 4. The result
print(json.dumps(client.sanitize_for_serialization(result), indent=2))Over HTTP: 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 vid to its node):
const model = await client.fs.getNodeByPath("/Project A/house.ifc");
const byVersion = await client.fs.getNodeByVersionUuid("<version uuid of the first demo model>");TreeNode model = client.fs.getNodeByPath("/Project A/house.ifc");
TreeNode byVersion = client.fs.getNodeByVersionUuid(UUID.fromString("<version uuid of the first demo model>"));TreeNode model = client.Fs.GetNodeByPath("/Project A/house.ifc");
TreeNode byVersion = client.Fs.GetNodeByVersionUuid(Guid.Parse("<version uuid of the first demo model>"));import nl.bimbase.bimworks.sdk.api.AuthApi;
import nl.bimbase.bimworks.sdk.api.FsApi;
import nl.bimbase.bimworks.sdk.client.ApiClient;
import nl.bimbase.bimworks.sdk.model.Auth;
import nl.bimbase.bimworks.sdk.model.GetNodeRequest;
import nl.bimbase.bimworks.sdk.model.LoginWithApiTokenRequest;
public class Example {
public static void main(String[] args) throws Exception {
// 1. Connect to BIM.works and log in with your API token
ApiClient client = new ApiClient();
client.updateBaseUri("https://bim.works/openapi");
Auth auth = new AuthApi(client)
.loginWithApiToken(new LoginWithApiTokenRequest().token("<your API token>"))
.getAuth();
client.setRequestInterceptor(builder -> builder.setHeader("Authorization", "Bearer " + auth.getBase64()));
// 2. The request
GetNodeRequest request = client.getObjectMapper().readValue("""
{
"path": "/Project A/house.ifc"
}
""", GetNodeRequest.class);
// 3. The call
var result = new FsApi(client).getNode(request);
// 4. The result
System.out.println(client.getObjectMapper().writerWithDefaultPrettyPrinter().writeValueAsString(result));
}
}using System.Text.Json;
using BIMworks.Sdk.Api;
using BIMworks.Sdk.Client;
using BIMworks.Sdk.Extensions;
using BIMworks.Sdk.Model;
using Microsoft.Extensions.DependencyInjection;
// 1. Connect to BIM.works and log in with your API token
IServiceProvider Connect(string bearer)
{
var services = new ServiceCollection();
services.AddApi(options =>
{
options.AddTokens(new BearerToken(bearer));
options.AddApiHttpClients(http =>
{
http.BaseAddress = new Uri("https://bim.works" + "/openapi");
http.Timeout = Timeout.InfiniteTimeSpan;
});
});
return services.BuildServiceProvider();
}
var login = await Connect("").GetRequiredService<IAuthApi>().LoginWithApiTokenAsync(new LoginWithApiTokenRequest("<your API token>"));
var auth = login.Ok()?.Auth ?? throw new HttpRequestException(login.RawContent, null, login.StatusCode);
var client = Connect(auth.Base64);
var json = client.GetRequiredService<JsonSerializerOptionsProvider>().Options;
// 2. The request
var request = JsonSerializer.Deserialize<GetNodeRequest>("""
{
"path": "/Project A/house.ifc"
}
""", json);
// 3. The call
var response = await client.GetRequiredService<IFsApi>().GetNodeAsync(request);
// 4. The result
var result = response.Ok() ?? throw new HttpRequestException(response.RawContent, null, response.StatusCode);
Console.WriteLine(JsonSerializer.Serialize(result, json));import { AuthApi, Configuration, FsApi, GetNodeRequestFromJSON, NodeToJSON } from "@bimworks/sdk";
// 1. Connect to BIM.works and log in with your API token
const basePath = "https://bim.works/openapi";
const auth = await new AuthApi(new Configuration({ basePath }))
.loginWithApiToken({ loginWithApiTokenRequest: { token: "<your API token>" } });
const client = new Configuration({ basePath, accessToken: typeof auth === "string" ? auth : auth.base64 });
// 2. The request
const request = GetNodeRequestFromJSON({
"path": "/Project A/house.ifc"
});
// 3. The call
const result = await new FsApi(client).getNode({ getNodeRequest: request });
// 4. The result
console.log(JSON.stringify(NodeToJSON(result), null, 2));<?php
require __DIR__ . '/vendor/autoload.php';
use BIMworks\Api\AuthApi;
use BIMworks\Api\FsApi;
use BIMworks\Configuration;
use BIMworks\Model\GetNodeRequest;
use BIMworks\Model\LoginWithApiTokenRequest;
use BIMworks\ObjectSerializer;
// 1. Connect to BIM.works and log in with your API token
$client = (new Configuration())->setHost('https://bim.works/openapi');
$auth = (new AuthApi(config: $client))->loginWithApiToken(new LoginWithApiTokenRequest(['token' => "<your API token>"]));
$client->setAccessToken($auth->getBase64());
// 2. The request
$request = ObjectSerializer::deserialize(<<<'JSON'
{
"path": "/Project A/house.ifc"
}
JSON, GetNodeRequest::class);
// 3. The call
$result = (new FsApi(config: $client))->getNode($request);
// 4. The result
echo json_encode($result, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES), PHP_EOL;import json
import bimworks
# 1. Connect to BIM.works and log in with your API token
client = bimworks.ApiClient(bimworks.Configuration(host="https://bim.works/openapi"))
auth = bimworks.AuthApi(client).login_with_api_token(
bimworks.LoginWithApiTokenRequest(token="<your API token>"))
client.configuration.access_token = auth.actual_instance.var_base64
# 2. The request
request = bimworks.GetNodeRequest.from_json(r"""
{
"path": "/Project A/house.ifc"
}
""")
# 3. The call
result = bimworks.FsApi(client).get_node(request)
# 4. The result
print(json.dumps(client.sanitize_for_serialization(result), indent=2))A path that does not exist fails with NODE_NOT_FOUND; over HTTP the operation is GetNode with path, uuid or version_uuid, and 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 (Upload a model) shows its version in versions and the same UUID in last_version_uuid.