Classic Java SDK

The classic, hand-written Java SDK (nl.bimbase.bimworks:client) — Maven coordinates and repository, the client factory and its login methods, the sub-APIs of a client, exceptions and error codes, and the Javadoc.

Classic SDK

This is the classic, hand-written Java SDK. For a new integration use the Java SDK generated from the OpenAPI document; SDKs compares the two. The classic SDK stays supported.

The classic Java SDK is a thin, typed client over the task API, the same one the web UI uses. It uploads, queries, runs checks, downloads BCF and reports, issues tokens and manages nodes; long-running tasks report progress and can be awaited.

Artifact#

Coordinates nl.bimbase.bimworks:client, version equal to your BIM.works server
Repository https://maven.bim.works/artifactory/BIM.works with the credentials your BIM.works contact provides, in settings.xml under the server id BIM.works (Java)
Java 17 or later
Transport HTTP/1.1 or HTTP/2 by default; new ClientSettings(ConnectionType.WEB_SOCKET) (or HTTP_1_ONLY, HTTP_2_ONLY) selects another
XML#
<dependency>
    <groupId>nl.bimbase.bimworks</groupId>
    <artifactId>client</artifactId>
    <version>${bimworks.version}</version>
</dependency>

Client factory#

BimWorksClientFactory(address) or BimWorksClientFactory(address, ClientSettings) is created once; it and every BimWorksClient are AutoCloseable, so use try-with-resources.

Method Logs in with
createClientWithApiToken(String) An API token — the normal way.
createClientWithUsernamePassword(String, String) A user's credentials; for testing.
createClientWithAuth(ObjectNode) An auth token as its JSON object.
createAnonymousClient() No credentials; a very small set of calls.
Java#
import java.util.Set;
import java.util.UUID;
import com.fasterxml.jackson.databind.node.ArrayNode;
import nl.bimbase.bimworks.client.BimWorksClient;
import nl.bimbase.bimworks.client.BimWorksClientFactory;

try (BimWorksClientFactory factory = new BimWorksClientFactory("https://bim.works")) {
    try (BimWorksClient client = factory.createClientWithApiToken("<your API token>")) {
        UUID version = UUID.fromString("<version uuid of the first demo model>");
        ArrayNode results = client.bim.query("GET qid, attribute.Name WHERE type = IFCWALL", Set.of(version));
        System.out.println(results);
    }
}

Sub-APIs#

The client exposes its APIs as public final fields (package nl.bimbase.bimworks.client.apis):

Field Class What it does
client.auth AuthApi Login, registration and the signed-in account: account info, settings, password changes and resets, sign-out, and the account's login tokens (listTokens, deleteToken). API tokens are on AdminApi.
client.fs FileSystemApi Nodes and versions: getRootNodeUuid, paths, listing, createNode, moving, deleting.
client.upload UploadApi uploadModel(UploadBuilder): a model from a path, file, stream, bytes or URL (new UploadBuilder(nodeUuid).fromPath(path), .url(url), …), with an optional progress listener on the builder. It waits until the new version is checked in and returns an UploadModelResponse.
client.bim BimApi BQL: query, queryCount, queryQids, validate, parseQuery, tableExport, textSearch, resolveBvl, disciplines.
client.ifc IfcApi IFC-level calls and exports.
client.modelChecks ModelChecksApi Check definition sets and runChecks, BCL checks (runCheck), IDS checks (runIdsCheck), results and validation reports, and check results as BCF (downloadCheckResultsAsBcf, downloadCheckResultsAsBcfDirect).
client.bcf BcfApi createBcf: a BCF file of viewpoint topics; augment: an existing BCF file with a snapshot of a version rendered for each topic's camera.
client.tokens TokensApi Versions, nodes and recursive-node tokens.
client.gis GisApi Geo-references (getGeoReference, setGeoReference, extractGeoReference, getMapConversion), CityGML export (downloadCityGml), 3D Tiles URLs (generate3DTilesUrl) and listModelsForGis.
client.geometry2d, client.geometry3d Geometry2dApi, Geometry3dApi 2D geometry and SVG export (exportSvg); glTF, bounds, geometry metadata and the geometry streams.
client.render RenderApi Server-side renders.
client.actions ActionsApi The Actions tree: listing and reading actions, adding folders and BQL queries (QUERY3), updating queries, deleting and restoring actions.
client.ai AiApi Text-to-action (textToAction).
client.conversations ConversationsApi The comment pins of a model: starting a conversation at a point (optionally on an object), listing, commenting, closing, reopening, deleting.
client.workspaces WorkspacesApi Workspaces.
client.admin, client.superadmin AdminApi, SuperAdminApi Administration: API tokens of a folder (createApiToken, listFolderApiTokens, updateApiToken, rotateApiTokenSecret, deleteApiToken), accounts, organisations and user features; server statistics, health, reindexing and e-mails.

The check calls of client.modelChecks return a task (RunChecksTask, RunIdsCheckTask, …): executeAsync() sends it, get() waits for the typed result, and setProgressListener reports progress; polling through client.getNodeClient().getProgress(...) works too. client.createRequest(project, taskName) with client.executeAsyncTask(request) reaches any task the SDK has no method for.

Errors#

Every call throws BimWorksException; getErrorCode() returns the ErrorCode constant (BimWorksErrorCode, BimWorksQueryError, DefaultErrorCode, …) and getMessage() the server's message. Codes are listed on the error codes page; a closed client throws BimWorksClientClosedException.

Java#
try {
    client.bim.query("GET qid WHERE type = IFCWAL", Set.of(version));
} catch (BimWorksException e) {
    System.err.println(e.getErrorCode() + ": " + e.getMessage()); // UNKNOWN_TYPE: …
}

The Java SDK generated from the OpenAPI#

The client generated from the OpenAPI document is the Java SDK, nl.bimbase.bimworks:sdk (packages nl.bimbase.bimworks.sdk.api and .model). It replaces nl.bimbase.bimworks:client2, the generated client of 2.x: one class per group of operations (AuthApi, FsApi, ModelApi, IfcApi, GisApi, …), with typed request and response models. It covers exactly the OpenAPI operations and is the choice for a new integration.

Generated reference#

The Java API catalogue documents the types and members of the client artifact, generated by a Javadoc doclet. It shares this site's navigation, styling and search, including signatures, overloads, parameters and inherited documentation.

Used in#

Pages#