Bluesky.Net 0.3.0-alpha

This is a prerelease version of Bluesky.Net.
There is a newer prerelease version of this package available.
See the version list below for details.
dotnet add package Bluesky.Net --version 0.3.0-alpha                
NuGet\Install-Package Bluesky.Net -Version 0.3.0-alpha                
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="Bluesky.Net" Version="0.3.0-alpha" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Bluesky.Net --version 0.3.0-alpha                
#r "nuget: Bluesky.Net, 0.3.0-alpha"                
#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.
// Install Bluesky.Net as a Cake Addin
#addin nuget:?package=Bluesky.Net&version=0.3.0-alpha&prerelease

// Install Bluesky.Net as a Cake Tool
#tool nuget:?package=Bluesky.Net&version=0.3.0-alpha&prerelease                

NuGet GitHub license

N|Solid

Bluesky.Net

Unofficial .NET implementation of atproto.com

About the target framework

To simplify the development, first versions will target only NET7.0+

Eventually the library will support NET standard 2.0

About the results

The api implements a basic discriminated union pattern for all the results.

The first option of the result is what you expect, the second an error if the HTTP status code is > 2xx

How to use it

1- Install the nuget package

Install-Package Bluesky.Net

2- Add the SDK to your services collection

services.AddBluesky();

3- The SDK can be configured

services
    .AddBluesky(options => {
        options.TrackSession = false;
    });

4- Inject the IBlueskyApi in your code

public class MyClass
{
    private readonly IBlueskyApi _bluesky;
    public MyClass(IBlueskyApi bluesky)
    {
        _bluesky = bluesky;
    } 
}

5 - Call the api

Login command = new("YOUR_HANDLE", "YOUR_PASSWORD");
Multiple<Session, Error> result = await _bluesky.Login(command, CancellationToken.None);

result
    .Switch(
        session => Console.WriteLine(session.Email),
        error => Console.WriteLine(JsonSerializer.Serialize(error)
    );    

6 - Create a post


Multiple<Did, Error> resolvedHandle = await api.ResolveHandle(session.Handle, CancellationToken.None);
        
string text =
        @"Link to Google This post is created with Bluesky.Net. A library to interact with Bluesky. A mention to myself and an emoji '🌅'";
    int mentionStart = text.IndexOf("myself", StringComparison.InvariantCulture);
    int mentionEnd = mentionStart + Encoding.Default.GetBytes("myself").Length;
    CreatePost post = new(
        text,
        new Link("www.google.com", 0, "Link to Google".Length),
        new Mention(resolvedHandle.AsT0, mentionStart, mentionEnd));

    //Create a post
    Multiple<CreatePostResponse, Error> created = await api.CreatePost(post, CancellationToken.None);    

Retries

You can easily plug retries with Polly when registering the api. Install the nuget package

Install-Package Microsoft.Extensions.Http.Polly

Configure your retries:

services
  .AddBluesky()
  .AddPolicyHandler(
      HttpPolicyExtensions
        .HandleTransientHttpError()
        .OrResult(msg => msg.StatusCode == System.Net.HttpStatusCode.ServiceUnavailable)
        .WaitAndRetryAsync(6, retryAttempt => TimeSpan.FromSeconds(Math.Pow(2,retryAttempt))));
Product Compatible and additional computed target framework versions.
.NET net7.0 is compatible.  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 was computed.  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. 
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.4.0-alpha 358 4/30/2023
0.3.0-alpha 90 4/28/2023
0.2.0-alpha 90 4/28/2023
0.1.0-alpha 90 4/26/2023
0.0.2-alpha 80 4/24/2023
0.0.1-alpha 80 4/24/2023