Skip to content

Relations

dblike edited this page Jan 20, 2026 · 1 revision

Relations API

Follow, unfollow, block, and unblock users.

Namespace: LichessSharp.Api.Contracts Access: client.Relations Required Scope: follow:read, follow:write


Methods

StreamFollowingUsersAsync

Stream users who are being followed by the authenticated user.

Required Scope: follow:read

IAsyncEnumerable<UserExtended> StreamFollowingUsersAsync(
    CancellationToken cancellationToken = default)

Example:

using var client = new LichessClient(token);

Console.WriteLine("Users you follow:");
await foreach (var user in client.Relations.StreamFollowingUsersAsync())
{
    var status = user.Online ? "Online" : "Offline";
    Console.WriteLine($"  {user.Username} ({status})");

    if (user.Perfs?.Blitz != null)
    {
        Console.WriteLine($"    Blitz: {user.Perfs.Blitz.Rating}");
    }
}

FollowUserAsync

Follow a user.

Required Scope: follow:write

Task<bool> FollowUserAsync(string username, CancellationToken cancellationToken = default)

Example:

using var client = new LichessClient(token);

await client.Relations.FollowUserAsync("DrNykterstein");
Console.WriteLine("Now following DrNykterstein");

UnfollowUserAsync

Unfollow a user.

Required Scope: follow:write

Task<bool> UnfollowUserAsync(string username, CancellationToken cancellationToken = default)

Example:

using var client = new LichessClient(token);

await client.Relations.UnfollowUserAsync("username");
Console.WriteLine("Unfollowed user");

BlockUserAsync

Block a user.

Required Scope: follow:write

Task<bool> BlockUserAsync(string username, CancellationToken cancellationToken = default)

Example:

using var client = new LichessClient(token);

await client.Relations.BlockUserAsync("spammer123");
Console.WriteLine("Blocked user");

UnblockUserAsync

Unblock a user.

Required Scope: follow:write

Task<bool> UnblockUserAsync(string username, CancellationToken cancellationToken = default)

Example:

using var client = new LichessClient(token);

await client.Relations.UnblockUserAsync("username");
Console.WriteLine("Unblocked user");

See Also

Clone this wiki locally