---
title: Classic Java SDK
summary: 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.
order: 92
languages: [java]
terms: [sdk, qid, api-token, auth-token]
see-also: [reference/sdk/java, reference/sdk, how-to/install/java, how-to/auth/log-in-with-an-api-token, how-to/query/run-a-bql-query]
---

# Classic Java SDK

```note title="Classic SDK"
This is the classic, hand-written Java [[term:sdk|SDK]]. For a new integration use the [[page:reference/sdk/java|Java SDK]] generated from the OpenAPI document; [[page:reference/sdk]] 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 {#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` ([[page:how-to/install/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 {#pom}
<dependency>
    <groupId>nl.bimbase.bimworks</groupId>
    <artifactId>client</artifactId>
    <version>${bimworks.version}</version>
</dependency>
```

## Client factory {#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 [[term:api-token|API token]] — the normal way. |
| `createClientWithUsernamePassword(String, String)` | A user's credentials; for testing. |
| `createClientWithAuth(ObjectNode)` | An [[term:auth-token|auth token]] as its JSON object. |
| `createAnonymousClient()` | No credentials; a very small set of calls. |

```java {#factory-example}
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("BIM_WORKS_ADDRESS")) {
    try (BimWorksClient client = factory.createClientWithApiToken("BIM_WORKS_API_TOKEN")) {
        UUID version = UUID.fromString("BIM_WORKS_FIRST_MODEL");
        ArrayNode results = client.bim.query("GET qid, attribute.Name WHERE type = IFCWALL", Set.of(version));
        System.out.println(results);
    }
}
```

## Sub-APIs {#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 {#errors}

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

```java {#error-example}
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 {#client2}

The client generated from the OpenAPI document is the [[page:reference/sdk/java|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 [[page:api|OpenAPI]] operations and is the choice for a new integration.

## Generated reference {#generated}

The [[page:reference/java/api|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 {#used-in}

- [[page:how-to/install/java]] — settings.xml, pom, shaded artifact.
- [[page:how-to/auth/log-in-with-an-api-token]] — the factory and the token.
- [[page:how-to/query/run-a-bql-query]] — `client.bim.query`.
