Skip to main content

Goal

Get a working SpeckleSharp script with the shortest path to load and analyse model data — without learning dependency injection.

What you will build

A script that authenticates, loads the latest version of an existing model, counts elements by category, and prints a summary to the console.

When to use this

Use this page when you write:
  • A one-off C# script or console app
  • A Grasshopper C# Script or custom component
  • A C# cell in a polyglot notebook (Jupyter, Visual Studio, Rider)
  • A small automation that is not a desktop connector
You do not need to understand dependency injection, service lifetimes, or ASP.NET Core. Paste the bootstrap once, then write normal C# against client, operations, and the Model you receive.
If you are building a production desktop connector (Revit, Rhino, AutoCAD, and similar), start with Dependency injection (connectors) and Publish large models (connectors) instead.
Load model data with Receive3. Paste the bootstrap below, authenticate with a PAT from SPECKLE_TOKEN, and call IOperations.Receive3. It returns a Model: a flat list of objects with path-keyed properties and relation accessors such as Level and Host. Install a 2026.9 build of the SDK. 2026.9.0-beta.7 is the current one; a later stable 2026.9.0 replaces the pin without changing the code:
Updating a script that uses Receive2 and Flatten()? See Migrate to 2026.9 for each change side by side.
For Grasshopper object construction without server calls, see Use SpeckleSharp in a Grasshopper C# node. For connector Publish/Load on the canvas, use the Grasshopper connector — the SDK complements those components; it does not replace them.

One-time bootstrap (copy this)

Paste this at the top of your script, notebook cell, or Grasshopper C# component. Run it once per process. This is the canonical bootstrap — other pages link here instead of repeating the full block.
Example
You can rename SpeckleBootstrap to anything. The point is a single static holder so notebook cells and script functions do not repeat new ServiceCollection() on every run.
There is no new Operations() or import-and-go equivalent. Every public entry point (IOperations, IClientFactory, IAccountFactory) is resolved from the bootstrap container. That is a one-time setup cost, not an ongoing architectural commitment.

Complete example

Load an existing model and count elements by category:
Complete example
You should see the version message, the object count, and up to 15 categories with their counts.
options and cancellationToken are for long-running host applications (connectors with progress UI and cancel buttons). For scripts, null and default are correct — not placeholders to replace.
Receive3 also takes the model URL you copy from the web app: Receive3(account, new Uri(modelUrl), options: null, cancellationToken: default). Without @versionId in the URL it loads the latest version.

How it works

Receive3 returns a Model. Query it with model.Objects, model.ObjectsWith("path"), and model.ObjectByApplicationId(id). Read properties with dotted paths (obj.GetDouble("Constraints.Base Offset")) and follow relations with accessors (obj.Level, obj.Host, obj.Material). See Object model for how the data is shaped, and Load and publish model data for the other paths.

Common mistakes

What to skip (unless you are building a connector)

Grasshopper and hosted scripts

Speckle connector components (Publish, Load): use the components for transport. Custom analysis in Grasshopper C#: see Use SpeckleSharp in a Grasshopper C# node for object construction; return here for Receive3.

Polyglot notebooks

  1. Paste the bootstrap in the first cell and run it once per kernel session.
  2. In later cells, call SpeckleBootstrap.Operations, SpeckleBootstrap.ClientFactory, and so on directly.
  3. Store account, client, or model in notebook variables if you reuse them — IClient and Model are IDisposable.

Next Steps

Build your first model analysis tool

Full CSV report walkthrough

Authentication

PAT and environment variables

Migrate to 2026.9

Move a Receive2 script to Receive3

FAQ

No. Treat AddSpeckleSdk + BuildServiceProvider() as a required preamble — like adding using statements.
Build your first model analysis tool for a complete automation. This page for the bootstrap snippet. Publish and load a model from C# if you want to publish your own data from scratch.
Receive3 loads it when the server holds that version in the 2026.9 format. If it throws because the version has no bundle, load it with Receive2. See Read versions published before 2026.9.
Last modified on October 19, 2026