Skip to content

Account

dblike edited this page Jan 20, 2026 · 1 revision

Account API

Read and write account information for the authenticated user.

Namespace: LichessSharp.Api.Contracts, LichessSharp.Models.Account Access: client.Account Required Scope: Varies by method


Methods

GetProfileAsync

Get the profile of the authenticated user.

Task<UserExtended> GetProfileAsync(CancellationToken cancellationToken = default)

Returns: UserExtended with full profile information.

Example:

using var client = new LichessClient(token);

var profile = await client.Account.GetProfileAsync();

Console.WriteLine($"Username: {profile.Username}");
Console.WriteLine($"ID: {profile.Id}");
Console.WriteLine($"Title: {profile.Title ?? "None"}");
Console.WriteLine($"Online: {profile.Online}");
Console.WriteLine($"Playing: {profile.Playing}");
Console.WriteLine($"Created: {profile.CreatedAt}");
Console.WriteLine($"Seen: {profile.SeenAt}");
Console.WriteLine($"Play time: {profile.PlayTime?.Total / 3600} hours");

// Rating information
if (profile.Perfs?.Blitz != null)
    Console.WriteLine($"Blitz: {profile.Perfs.Blitz.Rating} ({profile.Perfs.Blitz.Games} games)");
if (profile.Perfs?.Rapid != null)
    Console.WriteLine($"Rapid: {profile.Perfs.Rapid.Rating} ({profile.Perfs.Rapid.Games} games)");
if (profile.Perfs?.Bullet != null)
    Console.WriteLine($"Bullet: {profile.Perfs.Bullet.Rating} ({profile.Perfs.Bullet.Games} games)");

GetEmailAsync

Get the email address of the authenticated user.

Required Scope: email:read

Task<string> GetEmailAsync(CancellationToken cancellationToken = default)

Returns: The email address as a string.

Example:

using var client = new LichessClient(token);

var email = await client.Account.GetEmailAsync();
Console.WriteLine($"Email: {email}");

GetPreferencesAsync

Get the preferences of the authenticated user.

Required Scope: preference:read

Task<AccountPreferences> GetPreferencesAsync(CancellationToken cancellationToken = default)

Returns: AccountPreferences with all user preferences.

Example:

using var client = new LichessClient(token);

var prefs = await client.Account.GetPreferencesAsync();

Console.WriteLine($"Dark mode: {prefs.Dark}");
Console.WriteLine($"Sound: {prefs.Sound}");
Console.WriteLine($"Animation: {prefs.Animation}");
Console.WriteLine($"Premove: {prefs.Premove}");
Console.WriteLine($"Takeback: {prefs.Takeback}");
Console.WriteLine($"Auto Queen: {prefs.AutoQueen}");
Console.WriteLine($"Clock Bar: {prefs.ClockBar}");
Console.WriteLine($"Clock Sound: {prefs.ClockSound}");
Console.WriteLine($"Coordinate: {prefs.Coords}");
Console.WriteLine($"Confirm Resign: {prefs.ConfirmResign}");

GetKidModeAsync / SetKidModeAsync

Get or set kid mode status (disables chat and hides potentially inappropriate content).

Required Scope: preference:read (get), preference:write (set)

Task<bool> GetKidModeAsync(CancellationToken cancellationToken = default)

Task<bool> SetKidModeAsync(bool enabled, CancellationToken cancellationToken = default)

Example:

using var client = new LichessClient(token);

// Check current status
var kidMode = await client.Account.GetKidModeAsync();
Console.WriteLine($"Kid mode: {kidMode}");

// Enable kid mode
await client.Account.SetKidModeAsync(true);
Console.WriteLine("Kid mode enabled");

// Disable kid mode
await client.Account.SetKidModeAsync(false);
Console.WriteLine("Kid mode disabled");

GetTimelineAsync

Get the activity timeline of the authenticated user.

Required Scope: OAuth authentication required

Task<Timeline> GetTimelineAsync(
    int? nb = null,
    DateTimeOffset? since = null,
    CancellationToken cancellationToken = default)

Parameters:

Name Type Description
nb int? Maximum entries to return (default 15, max 30)
since DateTimeOffset? Only return entries after this timestamp

Example:

using var client = new LichessClient(token);

// Get recent timeline
var timeline = await client.Account.GetTimelineAsync(nb: 20);

foreach (var entry in timeline.Entries)
{
    Console.WriteLine($"[{entry.Date}] {entry.Type}: {entry.Data}");
}

// Get entries since yesterday
var yesterday = DateTimeOffset.UtcNow.AddDays(-1);
var recentTimeline = await client.Account.GetTimelineAsync(since: yesterday);

See Also

  • Users API - Get public profiles of other users
  • OAuth API - Authentication and token management

Clone this wiki locally