.NET SDK for BlueSky
This document provides an overview of how to use the BlueSky.NET
library for interacting with the BlueSky API. The examples provided demonstrate essential operations such as retrieving a DID, creating a session, and posting content.
You can follow this project on @blueskydotnet.bsky.social
IMPORTANT: I have not yet setup the Nuget Package yet!!!
Add the Qonq.BlueSky
library to your project:
dotnet add package Qonq.BlueSky
Ensure your project has access to .NET Standard or a compatible version.
BLUESKY_HANDLE
: Your BlueSky account handle.BLUESKY_PASSWORD
: Your BlueSky account password.Below are some examples to demonstrate the primary functionalities of the BlueSky.NET
library.
First, initialize the BlueSkyClient
to connect to the BlueSky service:
using Qonq.BlueSky;
const string PdsHost = "https://bsky.social";
var client = new BlueSkyClient(PdsHost);
The DID (Decentralized Identifier) is unique for your BlueSky account. Use the GetDidAsync
method to fetch it:
using Qonq.BlueSky.Model;
var didResponse = await client.GetDidAsync("your-handle");
Console.WriteLine($"Your DID: {didResponse.Did}");
Output:
Your DID: 1234567890abcdef1234567890abcdef
To authenticate and start a session, use the CreateSessionAsync
method with your handle and password:
var sessionRequest = new CreateSessionRequest
{
Identifier = "your-handle",
Password = "your-password"
};
var sessionResponse = await client.CreateSessionAsync(sessionRequest);
Console.WriteLine($"Access Token: {sessionResponse.AccessJwt}");
Validation:
AccessJwt
is not null or empty to confirm a successful session creation.Once authenticated, you can post text content using the CreatePostAsync
method:
var postContent = "Beep, Beep, Boop! I'm a BlueSky.NET Bot!";
var postResponse = await client.CreatePostAsync(postContent);
Console.WriteLine($"Post URI: {postResponse.Uri}");
Console.WriteLine($"Post CID: {postResponse.Cid}");
Validation:
Uri
and Cid
fields should be non-null and non-empty.Once authenticated, you can post text content using the CreatePostAsync
method:
var postContent = "Beep, Beep, Boop! I'm a BlueSky.NET Bot!";
var image = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVR42mP8/wcAAwAB/6l9lAAAAABJRU5ErkJggg==";
var altText = "Image Alt Text";
var postResponse = await client.CreatePostAsync(postContent,image,altText);
Console.WriteLine($"Post URI: {postResponse.Uri}");
Console.WriteLine($"Post CID: {postResponse.Cid}");
Validation:
Uri
and Cid
fields should be non-null and non-empty.Feel free to contribute to the BlueSky.NET
library by submitting pull requests or reporting issues.
Repository: BlueSky.NET GitHub
This library is licensed under the MIT License. See the LICENSE file for details.
Fishyflip - a .NET ATProtocol/Bluesky Library
Client for Bluesky
Bluesky cross-poster for inferior services (and a .NET library for ATProto and Bluesky)
A .NET class library for the Bluesky social network.
An atproto PDS implementation in .NET (C#)
A Bluesky appview focused on low resource consumption
Your Brand Here!
50K+ engaged viewers every month
Limited spots available!
📧 Contact us via email🦋 Contact us on Bluesky