---
title: ViewerApi
summary: Java SDK: the Viewer operations, 1 method, each with its parameters, result and a complete example.
order: 20
languages: [java]
sdk-package: Java SDK · nl.bimbase.bimworks.sdk
link-terms: true
---

# ViewerApi

[[page:reference/sdk/java|Java SDK]] · `nl.bimbase.bimworks.sdk.api` · class · 1 method

What the viewers need to place and load models

Construct it with the client of [[page:reference/sdk/java#connect|the connect step]]: `new ViewerApi(client)`. Each method is one operation of the [[page:api|API part]], where it runs on its page.

<table class="dense">
<thead><tr><th>Method</th><th>Operation</th><th>Description</th></tr></thead>
<tbody>
<tr><td><code>[[page:reference/sdk/java/viewerapi#getgeometrymetadata|getGeometryMetaData]]</code></td><td>[[openapi:GetGeometryMetaData]]</td><td>What a viewer needs to place and load models</td></tr>
</tbody>
</table>

## `getGeometryMetaData` {#getgeometrymetadata}

```java
public Map<String, Map<String, Object>> getGeometryMetaData(GetGeometryMetaDataRequest getGeometryMetaDataRequest) throws ApiException
```

What a viewer needs to place and load models. Per Version (keyed by its uuid): the metadata of its geometry (bounds, units, the unquantization, the file types and the geometry encoding the viewer should load), and its placement (georeference, anchor point, alignment, grid convergence). The keys follow the indexed-model metadata, which the viewers read as they are.

<table class="dense">
<tbody>
<tr><th>Operation</th><td>[[openapi:GetGeometryMetaData]] · <code>POST /openapi/viewer/GetGeometryMetaData</code></td></tr>
<tr><th>Scope</th><td>[[scope:geometry:read]]</td></tr>
</tbody>
</table>

### Parameters

<table class="dense">
<thead><tr><th>Name</th><th>Type</th><th>Description</th></tr></thead>
<tbody>
<tr><td><code>getGeometryMetaDataRequest</code></td><td><code>[[page:reference/sdk/java/models#GetGeometryMetaDataRequest|GetGeometryMetaDataRequest]]</code><span class="req">required</span></td><td>The request: its properties are those of the model, its JSON that of [[openapi:GetGeometryMetaData]]'s request body.</td></tr>
</tbody>
</table>

### Returns

<code>Map&lt;String, Map&lt;String, Object&gt;&gt;</code> — The metadata per Version uuid

### Example

```java
import nl.bimbase.bimworks.sdk.api.AuthApi;
import nl.bimbase.bimworks.sdk.api.ViewerApi;
import nl.bimbase.bimworks.sdk.client.ApiClient;
import nl.bimbase.bimworks.sdk.model.Auth;
import nl.bimbase.bimworks.sdk.model.GetGeometryMetaDataRequest;
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("BIM_WORKS_ADDRESS/openapi");
        Auth auth = new AuthApi(client)
                .loginWithApiToken(new LoginWithApiTokenRequest().token("BIM_WORKS_API_TOKEN"))
                .getAuth();
        client.setRequestInterceptor(builder -> builder.setHeader("Authorization", "Bearer " + auth.getBase64()));

        // 2. The request
        GetGeometryMetaDataRequest request = client.getObjectMapper().readValue("""
                {
                  "models": [
                    {
                      "type": "UrlModelIdentifier"
                    }
                  ]
                }
                """, GetGeometryMetaDataRequest.class);

        // 3. The call
        var result = new ViewerApi(client).getGeometryMetaData(request);

        // 4. The result
        System.out.println(client.getObjectMapper().writerWithDefaultPrettyPrinter().writeValueAsString(result));
    }
}
```
