Bsky.Net
1.0.0
dotnet add package Bsky.Net --version 1.0.0
NuGet\Install-Package Bsky.Net -Version 1.0.0
<PackageReference Include="Bsky.Net" Version="1.0.0" />
paket add Bsky.Net --version 1.0.0
#r "nuget: Bsky.Net, 1.0.0"
// Install Bsky.Net as a Cake Addin #addin nuget:?package=Bsky.Net&version=1.0.0 // Install Bsky.Net as a Cake Tool #tool nuget:?package=Bsky.Net&version=1.0.0
bsky.net
.Net library for interacting with the BlueSky API Inspired by from bluesky-net .
About the target framework
To simplify the development, first versions will target only NET8.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 Bsky.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 automatically resolving mentions and links
Multiple<Did, Error> resolvedHandle = await api.ResolveHandle(session.Handle, CancellationToken.None);
string text =
@"Link to Google https://google.com This post is created with Bsky.Net. A library to interact with Bluesky. A mention to @myself and an emoji '🌅'";
CreatePost post = new( text);
//Create a post
Multiple<CreatePostResponse, Error> created = await api.CreatePost(post, CancellationToken.None);
7 - Create a post with images automatically resolving mentions and links and uploading images and remove the metadata form the image(s) max 4 images
Multiple<Did, Error> resolvedHandle = await api.ResolveHandle(session.Handle, CancellationToken.None);
string text =
@"Link to Google https://google.com This post is created with Bsky.Net. A library to interact with Bluesky. A mention to @myself and an emoji '🌅'";
(string, string?)[] images = new (string, string?)[] {($"data:image/jpeg;base64,{base64String}", "Wijkertoren - Beverwijk") };
CreatePost post = new(message, images);
//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 | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | 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. |
-
net8.0
- Microsoft.Extensions.Http (>= 9.0.1)
- SixLabors.ImageSharp (>= 3.1.6)
- System.IdentityModel.Tokens.Jwt (>= 8.3.1)
- System.Net.Http.Json (>= 9.0.0)
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 |
---|---|---|
1.0.0 | 54 | 1/29/2025 |