Home

Awesome

Lemmy.Net

Nuget

A .NET 7 library for interacting with the Lemmy API, based on lemmy-js-client and written in C#.

Prerequisites

Documentation

See the lemmy-js-client docs for documentation.

Installation

NuGet

Either find and install the Lemmy.Net package in your IDE's NuGet package manager, or run the following command in your project directory:

dotnet add package Lemmy.Net

Example usage

See Examples for fully-working example projects on how the API can be used.

To print post titles from the lemmy.ml instance, one by one until the user presses any key other thann:

using Lemmy.Net;

var client = new LemmyHttp("https://lemmy.ml");
await foreach (var postView in api.GetAllPosts())
{
    Console.WriteLine(postView.Post.Name);
    
    if (Console.ReadKey().KeyChar != 'n')
        return;
}

To list all communities on the ds9.lemmy.ml instance:

var api = new LemmyHttp(
    "https://ds9.lemmy.ml"
);

await foreach (var communityView in api.ListAllCommunities())
    Console.WriteLine(communityView.Community.Name + "@" + new Uri(communityView.Community.ActorId).Host);