CarpaNet 0.1.0-alpha.35

This is a prerelease version of CarpaNet.
There is a newer version of this package available.
See the version list below for details.
dotnet add package CarpaNet --version 0.1.0-alpha.35
                    
NuGet\Install-Package CarpaNet -Version 0.1.0-alpha.35
                    
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="CarpaNet" Version="0.1.0-alpha.35" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="CarpaNet" Version="0.1.0-alpha.35" />
                    
Directory.Packages.props
<PackageReference Include="CarpaNet" />
                    
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 CarpaNet --version 0.1.0-alpha.35
                    
#r "nuget: CarpaNet, 0.1.0-alpha.35"
                    
#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 CarpaNet@0.1.0-alpha.35
                    
#: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=CarpaNet&version=0.1.0-alpha.35&prerelease
                    
Install as a Cake Addin
#tool nuget:?package=CarpaNet&version=0.1.0-alpha.35&prerelease
                    
Install as a Cake Tool

CarpaNet

NuGet Version License

CarpaNet Logo

CarpaNet is the core .NET runtime library for interacting with ATProtocol. It provides ATProtocol primitives, HTTP clients, OAuth support (Via CarpaNet.OAuth), identity resolution, CBOR serialization, event streams, Jetstream support (Via CarpaNet.Jetstream) and repo reading.

CarpaNet is intended as a "thin" implementation of accessing ATProtocol XRPC endpoints and services. Instead of binding itself to Bluesky services directly, you can use CarpaNet.SourceGen to create source generated bindings based on whatever version of the lexicons you wish to use. This should give much more flexability and maintainability for keeping up to date with ATProtocol changes, since now you don't need to depend on the library itself to stay updated.

1444070256569233

This library is experimental and not stable. Expect issues and bugs! Docs are not complete yet as the API is evolving and not stable.

Installation

dotnet add package CarpaNet

By itself, CarpaNet does not provide bindings to any ATProtocol lexicons. You can either write them yourself or use CarpaNet.SourceGen to create bound objects.

IATProtoClient

All clients implement IATProtoClient, which provides GetAsync, PostAsync, and SubscribeAsync methods for XRPC calls. The source generator produces typed extension methods on IATProtoClient (e.g., client.AppBskyFeedGetTimelineAsync()), so any client works with the generated API surface. You can either write your own implementation, or use the ones provided by CarpaNet or CarpaNet.OAuth.

ATProtoClient

The provided implementation client for CarpaNet. Supports public (unauthenticated) access, session-based authentication (App Passwords), and custom token providers. Includes auto-retry on auth failure and rate limiting.

// Public (unauthenticated) access
var client = ATProtoClient.Create(new ATProtoClientOptions
{
    JsonOptions = myJsonOptions,
    CborContext = myCborContext
});

var session = await client.LoginAsync("myhandle.bsky.social", "my-app-password");

// Or authenticate via password session directly using static factory.
var client = await ATProtoClient.CreateWithSessionAsync(
    "myhandle.bsky.social", "my-app-password",
    options: new ATProtoClientOptions
    {
        JsonOptions = myJsonOptions,
        CborContext = myCborContext
    });

Configuration

ATProtoClientOptions controls client behavior:

Property Description Default
BaseUrl Base URL for API requests
JsonOptions JsonSerializerOptions with source-gen resolver (required for AOT)
CborContext CborSerializerContext for event stream deserialization (required for AOT)
TokenProvider ITokenProvider for auth; null = public mode null
IdentityResolver Handle/DID resolver Auto-created
AutoRetryOnAuthFailure Retry on 401 with token refresh true
EnableRateLimitHandler Rate limit handling true
AutoRetryOnRateLimit Auto-retry on rate limit true
RateLimitMaxRetries Max rate limit retries 3
UserAgent User-Agent header null
Timeout Request timeout 100s
LabelerDids Labeler DIDs for atproto-accept-labelers header null

ATProtocol Types

  • ATDid — Strongly-typed DID (e.g., did:plc:...)
  • ATHandle — Strongly-typed handle (e.g., myname.bsky.social)
  • ATUri — AT URI with authority, collection, and record key parsing
  • ATCid — Content identifier (CID)
  • ATIdentifier — Accepts either a DID or handle
  • BlobRef — Blob reference with CID link

Identity Resolution

IdentityResolver resolves handles to DIDs and DIDs to DID documents. Supports both did:plc (via PLC directory) and did:web. Handle resolution uses DNS TXT records with HTTPS fallback.

var resolver = IdentityResolver.CreateWithCache();
var didDoc = await resolver.ResolveAsync("myhandle.bsky.social");
var pdsEndpoint = didDoc.PdsEndpoint;

CBOR Serialization

The CarpaNet.Cbor namespace provides DAG-CBOR serialization using System.Formats.Cbor. The CborSerializerContext pattern mirrors System.Text.Json's JsonSerializerContext for AOT compatibility. Used for event stream message deserialization and repository operations.

Event Streams

EventStreamClient provides WebSocket-based subscription to ATProtocol event streams, with CBOR frame parsing. This is used internally by the clients' SubscribeAsync method.

Repository

The Repo namespace includes CarReader for reading CAR (Content Addressable aRchive) files, Repository for working with ATProtocol repositories, and MstNode/RepoCommit for Merkle Search Tree operations.

Authentication

ITokenProvider abstracts token management. Two implementations are provided:

  • SessionTokenProvider — For app password sessions (JWT access/refresh tokens)
  • DPoPTokenProvider — For OAuth sessions with DPoP proof-of-possession, you can find this in CarpaNet.OAuth.

Both support automatic token refresh and raise TokenRefreshed events for session persistence.

Storage Interfaces

OAuth flows require persistent storage. CarpaNet provides interfaces and in-memory defaults:

  • IOAuthSessionStore — Store/retrieve/delete OAuth session data by DID
  • IOAuthStateStore — Store/consume OAuth authorization state (replay-safe)
  • MemoryOAuthSessionStore / MemoryOAuthStateStore — In-memory implementations
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 is compatible.  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 netcoreapp2.0 was computed.  netcoreapp2.1 was computed.  netcoreapp2.2 was computed.  netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
.NET Standard netstandard2.0 is compatible.  netstandard2.1 was computed. 
.NET Framework net461 was computed.  net462 was computed.  net463 was computed.  net47 was computed.  net471 was computed.  net472 was computed.  net48 was computed.  net481 was computed. 
MonoAndroid monoandroid was computed. 
MonoMac monomac was computed. 
MonoTouch monotouch was computed. 
Tizen tizen40 was computed.  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 (3)

Showing the top 3 NuGet packages that depend on CarpaNet:

Package Downloads
CarpaNet.OAuth

.NET ATProtocol OAuth Implementation Library for CarpaNet.

CarpaNet.Jetstream

.NET ATProtocol Jetstream Library, built for bindings with source generators.

CarpaNet.AspNetCore

ASP.NET Core XRPC endpoint support for CarpaNet ATProtocol library.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
1.0.1 180 3/30/2026
0.1.0-alpha.76 41 3/30/2026
0.1.0-alpha.71 48 3/24/2026
0.1.0-alpha.68 64 3/15/2026
0.1.0-alpha.58 46 3/8/2026
0.1.0-alpha.54 50 2/18/2026
0.1.0-alpha.52 44 2/18/2026
0.1.0-alpha.50 47 2/18/2026
0.1.0-alpha.47 54 2/17/2026
0.1.0-alpha.38 56 2/16/2026
0.1.0-alpha.37 56 2/16/2026
0.1.0-alpha.35 52 2/16/2026
0.1.0-alpha.34 54 2/15/2026
0.1.0-alpha.33 50 2/15/2026