---
title: .NET quick start
summary: Add the BIM.works_SDK package, log in with an API token, list your tree, upload a model and query it, in one program.
order: 50
languages: [csharp]
terms: [api-token, node, version, qid, bql]
see-also: [how-to/install/dotnet, how-to/auth/log-in-with-an-api-token, how-to/models/upload-a-model, how-to/query/run-a-bql-query, reference/dotnet]
featured: true
---

# .NET quick start

```note title="Classic SDK"
This tutorial uses the classic, hand-written .NET [[term:sdk|SDK]]. For a new integration, the [[page:reference/sdk/dotnet|.NET SDK]] generated from the OpenAPI document is the choice; its reference has a complete example for every operation ([[page:reference/sdk]] compares the two).
```

The .NET client is a .NET Standard 2.0 library, so it works from .NET Framework 4.6.1 up to current .NET. Its calls are synchronous and cover the tree, uploads, queries, tokens and geo referencing. This page takes you from an empty project to a program that uploads a model and queries it.

## Install

The package is `BIM.works_SDK` on nuget.org. Use the version of your server (the version pill at the top of this page is the server's):

```shell {#install}
dotnet add package BIM.works_SDK --version 3.0.0-beta.192
```

or `<PackageReference Include="BIM.works_SDK" Version="3.0.0-beta.192" />` in the project file. Everything lives in the `BIM.works_SDK` namespace. [[page:how-to/install/dotnet]] covers pre-release versions.

## Log in

```example
name: dotnet-quick-start
code: dotnet/quick-start.cs
notes: |
  One `BimWorksClientFactory` per instance and one `BimWorksClient` per login; both are `IDisposable`, so the `using` blocks close the connection. `CreateClientWithApiToken` is synchronous and throws `BimWorksException` when the token is rejected.
highlight: 12-13,17-19,24-27,31-34
```

The factory takes a `Uri`; the sub-APIs are properties of the client: `Auth`, `Fs`, `Upload`, `Bim`, `Tokens`, `Gis`, `Actions`, `Info` and `Admin`. `client.Info.GetApplicationVersion()` returns the server version as a `JsonElement` and is a good first call to confirm the address.

## List the tree

`client.Fs.GetRootNodeUuid()` is the node your token was created on; every path is relative to it, so `client.Fs.GetNodeByPath("/")` is the same node as a `TreeNode`. `client.Fs.ListNodes(uuid)` returns the children as `List<TreeNode>`, each with `Name`, `IsFolder`, `Path` and `Versions`; `GetLastVersion()` gives the version to query and view. `CreateNode(parentUuid, name, isFolder, InputFileType.FOLDER)` adds a folder, `CreateNodeIfNotExists` the same without failing when the name is taken, and `CreateNode(parentUuid, "model.ifc", false, InputFileType.IFC)` an empty model node to upload into.

## Upload

An `UploadBuilder` names the target node and the source: `new UploadBuilder(nodeUuid).SetPath(path)` for a local file, `PassThrough(uri, filesize)` for a URL the server downloads itself, or a `stream` with `filename` and `filesize`. `client.Upload.UploadModel(builder)` returns an `AsyncUploadTask`; `GetUploadResponse()` waits for the server to process the file and returns the model node with its new version. Upload into an empty model node you created, as the example does, or into a folder, in which case a model node named after the file is created.

## Query

`client.Bim.Query(versionUuid, bql)` runs a [[term:bql|BQL]] statement on one model, `client.Bim.Query2(versionUuids, bql)` on several; both return a `JsonElement` array with one object per row, every feature under its path and every value wrapped in an object with a `value` property (plus a `unit` when it has one). `System.Text.Json` reads it: `row.GetProperty("attribute").GetProperty("Name").GetProperty("value").GetString()`. The [BQL course](../bql/index.md) teaches the language.

## Where to go from here

`client.Tokens.CreateVersionsToken` mints a token that only sees the versions you name, the pattern for handing a model to a browser ([[page:explanation/tokens-and-delegation]]): with the `query:run` scope the browser runs its own queries. `client.QueryDelegated`, the older way of letting a browser query, is retired ([[term:delegated-query]]). The [[page:reference/dotnet|.NET reference]] lists every type; the how-to guides show one task at a time, starting with [[page:how-to/models/upload-a-model]] and [[page:how-to/query/run-a-bql-query]]; [[page:how-to/models/upload-models-concurrently]] uploads a whole batch at once.
