---
title: Output
summary: What a query returns — the record and leaf value shapes, the value types, the plain and compact JSON formats, grouped results and groupPath slicing, qid-only and count results, table export, and the IFC and ifcXML output of the OpenAPI Query.
order: 400
terms: [qid, vid, oid]
see-also: [reference/bql/index, reference/bql/group-by, api]
---

# Output

A query returns JSON: an array of records, one per selected object or per group. This page describes that JSON and the other forms a result can take.

## Records {#records}

Each record is an object keyed by the selected features. A plain feature (`qid`, `type`, `niceType`) is a scalar; a family feature is nested by its path (`attribute` → `Name`, `property` → `Pset_WallCommon` → `IsExternal`); a relation nests the related object's record under the relation name, as a list for multi-target relations. Such a feature keeps its path whatever its `AS` alias, and a column BIM.works computes — an arithmetic expression, a feature with `UNIT`, an aggregate, `eval(...)` — is keyed by its text: an alias names a column in the answer's [columns](#columns) and in a table, and moves no value ([[bql:get#alias]]). A feature the object has no value for is absent from the record (an arithmetic or `UNIT` column without a value is `null`), and a record with nothing in it is dropped.

```json {#record}
{
  "qid": "797e993c-a87f-4aa7-9587-c59d30ec5c4e-1316",
  "type": "IFCDOOR",
  "attribute": {"Name": {"name": "Name", "type": "STRING", "value": "Door 12", "classType": "IfcLabel"}},
  "quantity": {"Qto_DoorBaseQuantities": {"Width": {"name": "Width", "type": "DOUBLE", "value": 900.0, "unit": "MILLI_METER", "symbol": "mm", "classType": "IFCQUANTITYLENGTH", "quantitySetName": "Qto_DoorBaseQuantities"}}},
  "buildingStorey": {"attribute": {"Name": {"name": "Name", "type": "STRING", "value": "Level 1", "classType": "IfcLabel"}}}
}
```

## Leaf values {#values}

A leaf is an object with `name`, `type`, `value` and, depending on the family, `classType`, `propertySetName` or `quantitySetName`, `description`, `unit` and `symbol`, and `origin` (`"type"` for data merged from the type object). Converted values add `original_value`, `original_unit` and `original_symbol` ([[bql:using#result]]).

`type` is the value's basic type:

| `type` | JSON value |
|---|---|
| `STRING`, `ENUM` | string |
| `BOOLEAN` | `true` / `false`; `TRISTATE` adds `"UNKNOWN"` |
| `INT`, `LONG`, `FLOAT`, `DOUBLE` | number |
| `REFERENCE` | the qid of the referenced entity, as a string |
| `DATE`, `DATETIME` | a date object / an ISO string |
| `COLOR`, `CIRCLE`, `COORDINATE`, `BINARY` | structured values |

Aggregates are leaves too: `COUNT(qid)` appears as `"COUNT": {"name": "COUNT", "type": "int", "value": 58, "unit": "UNITLESS"}`, and the other aggregates likewise under their keyword (`MAX`, `AVG`, `FIRST`, …), except `SUM` and `COLLECT`, which are keyed by their full text (`"SUM(quantity.*.NetVolume)"`); a `SUM` has the unit of its argument. A second aggregate of the same kind without an alias is keyed by its full text too (`"MAX(quantity.*.Height)"`), so it does not overwrite the first. An alias does not change the key.

## Columns {#columns}

Next to its records an answer names its columns: one entry per `GET` item, in `GET` order, with its alias, its text and the path of its value in a record. Label a column with `label` and read its values at `path`; you need not know where BIM.works writes each kind of feature, or what an alias does to that.

```json {#columns-example}
"columns": [
  {"item": 0, "alias": null, "source": "attribute.Name", "label": "attribute.Name", "path": ["attribute", "Name"], "kind": "attribute"},
  {"item": 1, "alias": "Width", "source": "quantity.Qto_DoorBaseQuantities.Width", "label": "Width", "path": ["quantity", "Qto_DoorBaseQuantities", "Width"], "kind": "quantity"}
]
```

- `path` is an array of keys, because a key can hold a dot (`SUM(quantity.*.NetVolume)`). `*` stands for every key at that level, and an array met on the way holds one value per element. A relation and a `COLLECT` carry `columns` of their own, relative to one of their elements.
- `aggregate` is the keyword of an aggregate column, `unit` the unit of a `UNIT` clause, `groupKey` marks the keys of a grouped result, `hidden` an item the workspace hides (it has no values) and `added` the `qid` that `forceGetQid` adds.
- The JavaScript SDK puts the table on the records it returns, as `records.columns` (not enumerable, so walking the records does not meet it), and reads values through it with `QueryColumns`: `QueryColumns.get(record, "ext", records.columns)` is the value of the column with alias `ext`, `QueryColumns.byLabel(records)` the records as objects keyed by column label. Read an aliased value that way rather than as `record.ext`: the alias names the column and moves no value. A request with `aliasKeys: true` (`"alias_keys": true` on [[openapi:Query]]) gets the placement of before 3.0, where an alias was the key of most values; `columns` then describe that placement. `Query2` and a compact or sliced [[openapi:Query]] answer always carry `columns`; a plain [[openapi:Query]] answers a bare array, and `{objects, columns}` when the request says `"columns": true`.

## Plain and compact format {#compression}

The default (`compression: 0`) is the readable form above. `compression: 1` is the compact form the JavaScript SDK uses on the wire: version UUIDs and IFC classes are listed once in top-level `vids` and `types` arrays and every record references them by index, `{"_v": 0, "_t": 3, "_o": 1316}` standing for the qid and type. The SDK unpacks it into the plain form before handing it to you; ask for it explicitly (the `compression` field of [[openapi:Query]]) only when response size matters.

## Grouped results {#groups}

A grouped query returns one record per group: the key features under their paths, the aggregates under their names ([[bql:group-by#result]]). For a multi-key `GROUP BY` the flat form has one record per key combination.

The `groupPath` option of the query call slices such a result level by level: an empty array returns the first-level groups, `[2]` the second-level groups inside the third first-level group, and a path that consumes every key returns the member objects of that group under `objects`. Group records in slice mode carry `groupKey` and `groupValue`. Objects without a value for a key form a `[none]` group, so every level partitions its parent; indices are stable for the same models and query.

## Qids only and counts {#qids}

Two calls avoid building records at all. The qid-only form (`client.bim.queryQids(...)` in JavaScript, `onlyQids` on the internal task) returns just the Qids of the matching objects, which is what the viewers need to select, hide or colour. The count form (`client.bim.queryCount(...)`, `QueryCount`) returns the number of matching objects without fetching them ([[page:how-to/query/count-results]]).

## Tables {#tables}

The table export runs a query and returns it as a flat table with one column per feature (`attribute.Name`, `property.Pset_WallCommon.IsExternal`, …) in CSV, XLS or XLSX (`client.bim.tableExport(type, query, versions)` in Java; the Export button of the query editor in the UI). The header is the alias of each feature, or its text. The table is read from the same records a query returns: a feature without a value is an empty cell, numbers (and `COUNT`, `SUM`, …) are numeric cells, a `COLLECT` or a multi-valued feature is its different values joined with a comma, and computed doubles are rounded to nine decimals. A relation is a column per feature inside it (`system(attribute.Name, attribute.ObjectType)`; in `system.attribute.Name AS "System"` the alias names that one column), a feature that ends in a wildcard (`property."Pset_WallCommon".*`) a column per name found in the result. Send `virtual_features` as for a query, or virtual columns stay empty.

## IFC and ifcXML {#ifc}

The [[openapi:Query]] operation returns the selected objects as an IFC model when the request carries `"format": "ifc"`, and as ifcXML with `"format": "ifcxml"`; the dialect follows the models' schema. Without a `format`, `Accept: application/ifc` and `application/xml` select the same. The optional `filename` field sets the `Content-Disposition` of the download. This is the way to cut a partial model out of a version with a query. As a download of model content it needs the `model:read` scope as well as `query:run`. `colors` (qid → `[r, g, b, a]`, each 0 to 1) or `bvl`, a BVL text, colour the exported objects as styled items. With `bvl` the export keeps the selected objects the BVL shows, as the SDKs' BVL export does: begin it with `SHOW;` to keep them all.

## Errors {#errors}

A query that fails returns an error with a code from [[page:reference/errors#BimWorksQueryError|BimWorksQueryError]]: `SYNTAX_ERROR` for text the parser rejects (the message carries the line and column), `UNKNOWN_TYPE` for an IFC class that does not exist, `INCOMPATIBLE_UNIT_TYPES` for a unit of the wrong dimension, `FEATURE_NOT_ENABLED` when the instance lacks a capability, `TOO_MANY_OBJECTS` or a too-large result when the response would be unreasonable, `MISSING_PARAMETER` and `PARAMETER_TYPE_MISMATCH` for parameter binding, and `MISSING_QUERY` when the request has none. The OpenAPI maps them to HTTP status codes ([[page:api/errors]]).

## Used in {#used-in}

- [[page:how-to/query/run-a-bql-query]] — reading the records in each SDK.
- [[page:tutorials/openapi/getting-started]] — a query over HTTP and its JSON.
