Dmart.Client 0.9.37

dotnet add package Dmart.Client --version 0.9.37
                    
NuGet\Install-Package Dmart.Client -Version 0.9.37
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Dmart.Client" Version="0.9.37" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Dmart.Client" Version="0.9.37" />
                    
Directory.Packages.props
<PackageReference Include="Dmart.Client" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add Dmart.Client --version 0.9.37
                    
#r "nuget: Dmart.Client, 0.9.37"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package Dmart.Client@0.9.37
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=Dmart.Client&version=0.9.37
                    
Install as a Cake Addin
#tool nuget:?package=Dmart.Client&version=0.9.37
                    
Install as a Cake Tool

Dmart.Client

Async C# client for the dmart structured CMS/IMS HTTP API. Mirrors pydmart — same method surface, same wire shapes, idiomatic async/await in C#.

Install

dotnet add package Dmart.Client

Dmart.Models (the shared wire types) comes along as a dependency.

Method surface

Dmart.Client mirrors the same dmart HTTP surface that pydmart and tsdmart wrap — feature parity by method name and response shape across all the dmart language SDKs. Dmart.SqlAdapter exposes the same method names for everything that's DB-feasible, so a consumer can swap backends by changing the constructor.

Feature Client SqlAdapter (DB)
Auth (Client-only)
LoginAsync / LoginByAsync yes n/a
LogoutAsync yes n/a
CreateUserAsync (register) yes n/a
UpdateUserAsync yes n/a
CheckExistingAsync yes n/a
GetProfileAsync yes yes (actor is "self")
OtpRequestAsync / OtpRequestLoginAsync yes n/a
PasswordResetRequestAsync / ConfirmOtpAsync yes n/a
ValidatePasswordAsync yes n/a
DeleteAccountAsync yes n/a
GoogleMobileLoginAsync / FacebookMobileLoginAsync / AppleMobileLoginAsync yes n/a
Entry CRUD (both)
LoadAsync / LoadOrNoneAsync / IsEntryExistAsync yes yes
GetByUuidAsync / GetBySlugAsync yes yes
GetEntryByCriteriaAsync yes (best-effort) yes
GetSchemaAsync yes yes
CreateAsync / UpdateAsync / SaveAsync yes yes
DeleteAsync / MoveAsync yes yes
RequestAsync yes (raw envelope) n/a — use typed CRUD
RetrieveEntryAsync yes (raw envelope) LoadAsync does the typed version
Query (both)
QueryAsync / QueryEntriesAsync yes QueryAsync returns (Total, Records)
GetSpacesAsync / LoadSpacesAsync yes GetSpacesAsync (typed dict)
FetchSpaceAsync yes yes
GetChildrenAsync yes yes
LoadUserMetaAsync yes yes
GetUserPermissionsAsync n/a — read roles on the profile yes (DB cache)
QueryHistoryAsync yes (uses QueryType.History) yes (histories table)
Locks (both)
LockEntryAsync / UnlockEntryAsync yes n/a — use TryLockAsync
TryLockAsync / UnlockAsync yes (parity-shape over endpoints) yes
GetLockerAsync n/a — no HTTP endpoint yes
Multipart / bulk (Client)
UploadWithPayloadAsync yes n/a — files served by server
PublicAttachAsync yes n/a
CsvAsync / ResourcesFromCsvAsync yes n/a — server-orchestrated
ImportAsync / ExportAsync yes n/a
Workflow / submit (Client)
ProgressTicketAsync yes n/a — workflow plugin dispatch
SubmitAsync yes n/a
Public reads (Client)
PublicQueryGetAsync / PublicExecuteAsync yes n/a — call DB directly
Payload (Client)
GetPayloadAsync / GetAttachmentUrl yes n/a — DB doesn't serve URLs
FetchDataAssetAsync yes n/a — server query engine
Info (Client)
GetInfoMeAsync / GetManifestAsync / GetSettingsAsync yes n/a
GetSpaceHealthAsync yes n/a — server orchestration
Admin (Client)
ReindexEmbeddingsAsync / ApplyAlterationAsync yes n/a
ReloadSecurityDataAsync / SemanticSearchAsync yes n/a
GetShortLinkAsync / GetShorteningAsync yes n/a
SendMessageAsync / BroadcastToChannelsAsync / GetWsInfoAsync yes n/a

Auth methods live exclusively on Dmart.Client — authentication is a server concern, and a direct-DB caller is already inside the trust boundary. Server-orchestrated features (workflow, plugin dispatch, file payloads, manifest, etc.) similarly stay HTTP-only.

Usage

using Dmart.Client;
using Dmart.Models.Api;
using Dmart.Models.Enums;

using var client = new DmartClient("http://localhost:8282");

// Authenticate — token is cached on the instance and attached to
// every subsequent request.
await client.LoginAsync("dmart", "change-me");

// Query users.
var resp = await client.QueryAsync(new Query
{
    Type = QueryType.Subpath,
    SpaceName = "management",
    Subpath = "/users",
    Limit = 10,
});

foreach (var record in resp.Records ?? [])
    Console.WriteLine(record.Shortname);

await client.LogoutAsync();

Error handling

Any non-success envelope (status=failed), non-2xx HTTP response with a parsable error payload, or transport-level failure throws DmartException:

try
{
    await client.LoginAsync("nope", "wrong");
}
catch (DmartException ex)
{
    // ex.StatusCode — HTTP status (or 0 on transport errors)
    // ex.Error.Type / Code / Message — server's api.Error envelope
}

Configuration

The constructor accepts three styles, mirroring Dmart.SqlAdapter's options pattern so the two SDKs configure the same way.

Style 1 — Raw URL (simplest)

using var client = new DmartClient("http://localhost:8282");

Style 2 — Strongly-typed DmartClientOptions

Use when binding from IConfiguration / appsettings.json or when you need to set a default bearer token, request timeout, or default headers at construction time.

using var client = new DmartClient(new DmartClientOptions
{
    BaseUrl        = "http://localhost:8282",
    AuthToken      = "preset-bearer-or-null",   // optional
    Timeout        = TimeSpan.FromSeconds(30),   // optional
    DefaultHeaders =                             // optional
    {
        ["X-Tenant-Id"] = "tenant-42",
    },
});
Property Type Default Notes
BaseUrl string? null Required. Falls back to DMART_BASE_URL env var when unset. Trailing slashes are stripped.
AuthToken string? null Pre-set bearer for service-to-service calls. LoginAsync overwrites it.
Timeout TimeSpan? null Applied only when DmartClient owns its HttpClient (i.e., NOT when you pass your own via the typed-client pattern).
DefaultHeaders Dictionary<string, string> empty Added to every outgoing request via TryAddWithoutValidation so non-standard names like X-… are accepted.

Style 3 — Environment variable only

The simplest "containerized service" case: export the URL, construct with default options, no config-binding needed.

export DMART_BASE_URL=https://dmart.example.com
using var client = new DmartClient(new DmartClientOptions());

If neither BaseUrl nor DMART_BASE_URL is set, the constructor throws InvalidOperationException so the misconfiguration surfaces at startup rather than as a mysterious 404 on the first request.

appsettings.json example

{
  "Dmart": {
    "BaseUrl": "https://dmart.example.com",
    "Timeout": "00:00:30"
  }
}

ASP.NET's standard IConfiguration binding picks env vars up out of the box. Use : (POSIX) or __ (Docker) as the path separator:

export Dmart__BaseUrl=https://dmart.example.com
export Dmart__AuthToken=$(cat /run/secrets/dmart_service_token)

Dependency injection

Minimal-API host (Program.cs)

using Dmart.Client;

var builder = WebApplication.CreateBuilder(args);

builder.Services.Configure<DmartClientOptions>(
    builder.Configuration.GetSection("Dmart"));
builder.Services.AddSingleton<DmartClient>(sp =>
    new DmartClient(sp.GetRequiredService<IOptions<DmartClientOptions>>().Value));

Typed-client (IHttpClientFactory) pattern

Lets ASP.NET manage the underlying HttpClient lifetime (handler rotation, DNS refresh, Polly policies). DmartClient does not apply Timeout in this mode — configure that on the HttpClient itself.

services.Configure<DmartClientOptions>(config.GetSection("Dmart"));
services.AddHttpClient("dmart", (sp, c) =>
{
    var opts = sp.GetRequiredService<IOptions<DmartClientOptions>>().Value;
    c.BaseAddress = new Uri(opts.ResolveBaseUrl());
});
services.AddSingleton<DmartClient>(sp =>
{
    var opts = sp.GetRequiredService<IOptions<DmartClientOptions>>().Value;
    var http = sp.GetRequiredService<IHttpClientFactory>().CreateClient("dmart");
    return new DmartClient(opts, http);
});

HttpClient disposal stays with the caller in that mode; the default constructor (new DmartClient("url")) owns its HttpClient and disposes it when the client is disposed.

Supported frameworks

  • netstandard2.1 — .NET Framework 4.8+ / Mono / Xamarin via the standard bridge.
  • net8.0 — LTS .NET 8.
  • net10.0 — current .NET.

License

MIT.

Product Compatible and additional computed target framework versions.
.NET net5.0 was computed.  net5.0-windows was computed.  net6.0 was computed.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 is compatible.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed.  net9.0 was computed.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 is compatible.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
.NET Core netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
.NET Standard netstandard2.1 is compatible. 
MonoAndroid monoandroid was computed. 
MonoMac monomac was computed. 
MonoTouch monotouch was computed. 
Tizen tizen60 was computed. 
Xamarin.iOS xamarinios was computed. 
Xamarin.Mac xamarinmac was computed. 
Xamarin.TVOS xamarintvos was computed. 
Xamarin.WatchOS xamarinwatchos was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
0.9.37 39 6/3/2026
0.9.36 48 6/3/2026
0.9.35 95 6/1/2026
0.9.34 87 6/1/2026
0.9.33 91 5/30/2026
0.9.32 93 5/29/2026
0.9.31 100 5/29/2026
0.9.30 87 5/29/2026
0.9.29 92 5/29/2026
0.9.28 88 5/29/2026
0.9.27 93 5/28/2026
0.9.26 92 5/27/2026
0.9.25 88 5/25/2026
0.9.24 89 5/24/2026
0.9.23 90 5/24/2026
0.9.22 88 5/24/2026
0.9.21 92 5/24/2026
0.9.20.2 101 5/24/2026
0.9.20.1 91 5/24/2026
0.9.20 89 5/24/2026
Loading failed