Query

Query one or more IFC models

POST
/openapi/ifc/Query

Queries one or more models with BQL (BIM.works Query Language): the query text, or a stored query action by action_uuid. Running a stored query needs read rights on it, not actions:read.

format chooses what comes back; it wins over the Accept header, which is only read when format is absent (application/ifc, application/xml, text/csv and the xlsx type then ask for those formats):

  • json (the default): one record per object (or group), with one field per GET column. A plain query answers an array of records. With compression: 1, or a slice (groupPath, groupKeys), it answers an object: the records under objects (or groups), the slice it addressed, and the compact tables.
  • count: {count}, the number of matching objects, without building records.
  • qids: {qids: {<version uuid>: [oid, …]}}, the matching objects as the selection the viewers take. Only for a query whose result is plain objects (no GROUP BY other than the leaf of a slice, no aggregate, no ORDER BY).
  • csv and xlsx: the records as a table, one column per GET feature.
  • ifc and ifcxml: the matching objects as an IFC STEP or an ifcXML model, with what they need to be valid (their geometry, placement and spatial structure).

An empty models array validates the query instead of running it: the answer is {messages: [{code, severity, line, column, message}]}, empty for a clean query, whatever the format.

Try it#

Edit the request and send it; it runs against this instance with your token, and the examples follow the form.

Authorization
Bearer <auth token>
Content-Type
application/json
Body
1 2 3 4 5 6 7 8 9 10
Authorization: Bearer <auth token>
Content-Type: application/json
Accept: application/json
curl -X POST "$BIMWORKS_URL/openapi/ifc/Query" \
  -H "Authorization: Bearer $BIMWORKS_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
  "models": [
    {
      "type": "VersionModelIdentifier",
      "name": "My model name",
      "uuid": "BIM_WORKS_FIRST_MODEL"
    }
  ],
  "query": "GET attribute.GlobalId, attribute.Name WHERE type = IFCWALL AND property.*.IsExternal = true"
}'
Send to see the response

Examples#

curlshell
curl -X POST "$BIMWORKS_URL/openapi/ifc/Query" \
  -H "Authorization: Bearer $BIMWORKS_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
  "models": [
    {
      "type": "VersionModelIdentifier",
      "name": "My model name",
      "uuid": "BIM_WORKS_FIRST_MODEL"
    }
  ],
  "query": "GET attribute.GlobalId, attribute.Name WHERE type = IFCWALL AND property.*.IsExternal = true"
}'

The examples are complete programs in the OpenAPI SDKs, all in the same four steps. The method in each SDK's reference: Java · .NET · TypeScript · PHP · Python.

Request body#

QueryRequest · application/json

FieldTypeDescription
modelsarray of ModelIdentifieroptionalModels to query, by Version or Node identifier (a Node stands for its latest Version). An empty model set validates the query instead
querystringoptionalThe query, in BQL. Pass either query or action_uuid
action_uuiduuidoptionalA stored query (BQL) action to run instead of query
action_versionintegeroptionalThe version of the stored action to run; its current version when absent
formatstringoptionalAbsent, the Accept header decides, and json when it names none of these. json: the records (application/json); count: {count} (application/json); qids: {qids: {version uuid: [oid]}} (application/json); csv: the records as a table (text/csv); xlsx: the same as a spreadsheet; ifc: the matching objects as IFC STEP (application/ifc); ifcxml: the same as ifcXML (application/xml). The IFC formats are a download of model content and also need the model:read scope One of json, count, qids, csv, xlsx, ifc, ifcxml.
parametersobjectoptionalValues for the $name parameters of the query, by name. Every parameter of the query then needs a value. Not for formats ifc and ifcxml
virtual_featuresobjectoptionalThe virtual features to apply (formats json, count, qids, csv and xlsx): "enabled" (the enabled definitions of the workspace the call works in: your default workspace, or the published workspace of a visitor), "none" (the default), an array of definition uuids, or an object {apply, include, exclude}
force_get_qidbooleanoptionalFormat json; add the qid of each object to its record, also when the query does not GET it Default false.
columnsbooleanoptionalFormat json; answer an object instead of the bare array of a plain query: the records under objects and the columns table under columns, one entry per GET item with its alias, its text and where its value is in a record (QueryColumn). A compact (compression: 1) or sliced answer is an object already and always carries columns Default false.
alias_keysbooleanoptionalFormat json; put values under their AS aliases, as before 3.0: an aliased attribute, property, quantity, calculated value, relation or model field is written at a root key named after its alias, and an aliased computed column (aggregate, arithmetic, shape, ...) under its alias. By default an alias only names its column (see columns) and every value stays where it is without one. For clients written against the old placement; read values through columns instead Default false.
filenamestringoptionalThe file name of the Content-Disposition, for the formats csv, xlsx, ifc and ifcxml
colorsQidColorsoptionalFormats ifc and ifcxml; the objects' colours, written as IfcStyledItems
bvlstringoptionalFormats ifc and ifcxml, instead of colors; a BVL text: the export keeps the selected objects it shows (begin it with SHOW; to keep them all) and writes the colours it gives them
compression0 | 1optionalOutput format of the JSON results. 0 (default): plain output, each object contains readable values such as qid and type. 1: compact output, version UUIDs and entity types are returned once in top-level vids/types arrays, and objects reference them by index (_v/_t) with _o as the object id. Only use 1 when you explicitly want the compact format, for example to reduce response size Default 0.
groupPathobjectoptionalSlice mode for queries with a (multi-key) GROUP BY. Each entry addresses one group per nesting level, as an index into that level's groups (sorted by group key value). An empty array returns the level-0 groups. When entries remain below the addressed path, the response contains the next level's groups in a top-level "groups" array (same record shape as regular grouped results, plus "groupKey" and "groupValue" columns carrying the group's own key and display value); when the path consumes all group keys, the member objects of the addressed group are returned in "objects". Objects without a value for a level's group feature are grouped under a synthetic "[none]" group at that level, so every level fully partitions its parent. Group indices are stable for an identical model set and query. Without groupPath, a multi-key GROUP BY returns flat records, one per non-empty key combination (including [none] combinations), ordered by key 1, then key 2, etc.
groupKeysobjectoptionalThe same slice as groupPath, addressed by value instead of by index - the groupKey of one group per level, as the slice records carry it. A key still names its group after the models change. Pass groupPath or groupKeys, not both
groupLevelintegeroptionalOptional validation aid for groupPath and groupKeys: must equal the number of their entries (the nesting level of the returned groups)

Responses#

StatusSchemaDescription
200object application/jsonQuery results in the requested format. Format json: the BIM.works query results JSON. A plain query answers an array of records with readable values; with columns: true it answers {objects, columns}, columns being an array of QueryColumn. With compression 1 the records reference top-level vids/types arrays by index, and columns is there too. With groupPath or groupKeys the response echoes the slice and groupLevel, and the records are under "groups" (the next level's groups) or "objects" (the member objects, when the slice consumed all group keys). Format count: {count}. Format qids: {qids}. An empty models array: {messages}
file text/csvFormat csv, the records as a table
file application/vnd.openxmlformats-officedocument.spreadsheetml.sheetFormat xlsx, the records as a spreadsheet
file application/ifcFormat ifc, the matching objects as an IFC STEP model
file application/xmlFormat ifcxml, the matching objects as an ifcXML model (dialect follows the models' schema)
400ErrorResponseInvalid input: a missing or invalid argument, an invalid query/identifier/path, a state conflict caused by the request (for example a Node name that already exists), or an uploaded file that was rejected because it cannot be read (type for example INVALID_INPUT_FILE, NO_CONVERTIBLE_CONTENT or one of the StepParserErrorCode codes; uploading the same file again fails the same way)
401ErrorResponseAuthentication failed: the bearer token is missing, malformed, expired or otherwise invalid, or the provided login credentials are incorrect
403ErrorResponseAuthenticated, but not allowed: no read/write rights on the target Node, the token's task or IP scope does not allow this call, or a required user feature is missing
404ErrorResponseThe referenced entity (Node, Version, model file, upload, ...) does not exist
429ErrorResponseToo many requests from this client in a short time, on an installation that limits the request rate. Wait the number of seconds in Retry-After before trying again
500ErrorResponseAn unexpected server-side error (database, routing, IO, unknown)
503ErrorResponseBIM.works is temporarily unavailable: it is restarting, stopped, or down for scheduled maintenance (type SERVICE_UNAVAILABLE or MAINTENANCE). Wait the number of seconds in Retry-After before trying again
504ErrorResponseBIM.works did not respond in time (type REQUEST_TIMED_OUT). The request may still be completed: check its result before trying again
Generated from api.yml·openapi.json