Uniform.Matrix.Protocol.Client 0.1.2

dotnet add package Uniform.Matrix.Protocol.Client --version 0.1.2
                    
NuGet\Install-Package Uniform.Matrix.Protocol.Client -Version 0.1.2
                    
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="Uniform.Matrix.Protocol.Client" Version="0.1.2" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Uniform.Matrix.Protocol.Client" Version="0.1.2" />
                    
Directory.Packages.props
<PackageReference Include="Uniform.Matrix.Protocol.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 Uniform.Matrix.Protocol.Client --version 0.1.2
                    
#r "nuget: Uniform.Matrix.Protocol.Client, 0.1.2"
                    
#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 Uniform.Matrix.Protocol.Client@0.1.2
                    
#: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=Uniform.Matrix.Protocol.Client&version=0.1.2
                    
Install as a Cake Addin
#tool nuget:?package=Uniform.Matrix.Protocol.Client&version=0.1.2
                    
Install as a Cake Tool

Uniform.Matrix.Protocol.Client

An HTTP client of the Matrix Client-Server API: discovery, login and registration, sync, rooms and messages, media, devices, end-to-end encryption keys and key backup.

dotnet add package Uniform.Matrix.Protocol.Client

Log in

using Uniform.Matrix.Protocol.Client;
using Uniform.Matrix.Protocol.Core;

using HttpClient http = new();

// Find the homeserver for the server part of the user ID
UserId userId = UserId.Parse("@alice:matrix.org");
Uri homeserver = await HomeserverDiscovery.DiscoverAsync(http, userId.ServerName);
MatrixClient client = new(http, homeserver);
await client.LoginWithPasswordAsync(userId.ToString(), password, deviceDisplayName: "My app");

Store client.Session to resume later without the password: new MatrixClient(http, session).

Receive and send messages

await foreach (SyncResponse sync in client.SyncLoopAsync(cancellationToken: cancellationToken))
{
    foreach ((string roomId, JoinedRoom room) in sync.Rooms.Join)
    {
        foreach (ClientEvent clientEvent in room.Timeline.Events)
        {
            if (clientEvent.Type != EventTypes.RoomMessage || !clientEvent.TryGetContent(out MessageContent? message)) continue;
            Console.WriteLine($"[{roomId}] {clientEvent.Sender}: {message.Body}");
        }
    }
}

string roomId = await client.JoinRoomAsync("#lobby:matrix.org");
await client.SendEventAsync(roomId, EventTypes.RoomMessage, new MessageContent { MessageType = MessageTypes.Text, Body = "Hello" });

SyncLoopAsync long-polls and retries network errors with backoff; store NextBatch with the session and pass it as since to continue where you left off.

Notes

  • One MatrixClient serves one homeserver and one session. The caller owns the HttpClient, so it works with IHttpClientFactory; keep its timeout longer than the sync long-poll.
  • Rate-limited requests are retried after the server's retry_after_ms; other errors throw MatrixException.
  • Endpoints that need user-interactive auth, such as deleting devices, take the password and answer the server's challenge.
  • For end-to-end encryption, see Uniform.Matrix.Protocol.Crypto; for a client with local storage and room state, Uniform.Matrix.Client.

More in Using the protocol client.

About

Part of Uniform.Matrix, a pure .NET implementation of the Matrix specification. Version 0.1 is an early pre-release: APIs may still change.

Product Compatible and additional computed target framework versions.
.NET 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. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages (1)

Showing the top 1 NuGet packages that depend on Uniform.Matrix.Protocol.Client:

Package Downloads
Uniform.Matrix.Client

Matrix client engine with local SQLite storage: session, sync, outbox, media cache, encryption and room state.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
0.1.2 0 10/27/2026
0.1.0 28 10/26/2026
0.1.0-alpha.1 31 10/26/2026