Your network blocks the Lichess assets!

lichess.org
Donate
Screenshot of source code

Chariot - Java client for the Lichess API

Software Development
In addition to Lichess's visible features - there is also an API

Lichess has a lot of features and is constantly getting more!
In addition to the visible features, there also exists an API (Application Programming Interface) which can be used by developers to write applications which can interact with Lichess - such as Bots and OpeningTree.com.

The API is accessed by using a set of documented HTTP operations and this post is about a Java library, Chariot, which implements this Lichess API - making these operations easily available for Java applications.

Here's how the code could look for an application which fetches a Lichess Team and outputs how many members it has:

import chariot.Client;
import chariot.model.*;

void main() {

  // Create a client
  var client = Client.basic();

  // Lichess Swiss
  // https://lichess.org/team/lichess-swiss
  String teamId = "lichess-swiss";

  // Fetch info about the team from Lichess
  One<Team> teamResult =
    client.teams().byTeamId(teamId);

  // Check if the fetch succeeded or if there was some problem
  if (teamResult instanceof Some(var team)) {

    // We found the team, show number of members
    IO.println(team.nbMembers() + " members in " + team.name());
  } else {

    // There was some problem, show a message
    IO.println("Fetch failed: " + teamResult);
  }

  // Prepare a stream of the Lichess Swiss members from Lichess
  Many<TeamMember> memberResult =
    client.teams().usersByTeamId(teamId);

  // Only receive the first result (if any),
  // which is the newest member and show the member name
  memberResult.stream()
    .findFirst()
    .ifPresent(newest -> IO.println(
        "Newest member: " + newest.user().name()));
}

A listing of all methods in Chariot can be found here

Latest Java can be downloaded and upacked from here, and one can use a published version of Chariot from Maven Central (download jar into a directory) and then Copy/Paste the above code into a file named Main.java

And then running it:

$ java -cp chariot-0.2.10.jar Main.java
700436 members in Lichess Swiss
Newest member: Matias_irenio_atnez

or with paths to the files:

$ C:\path\to\downloaded\jdk-25\bin\java -cp C:\path\to\downloaded\chariot-0.2.10.jar C:\path\to\Main.java                                       
700436 members in Lichess Swiss
Newest member: Matias_irenio_atnez

There's also a Maven example project available, which can be handy since many IDEs such as IntelliJ IDEA and VS Code have support for opening Maven projects and getting the documentation, code completion and all the Good Stuff in place out-of-the-box.


This is an example application, Team Check, which can be used to visualize members of Lichess teams (in a somewhat silly way...)
members
It may be a silly application, but at least its code serves to demo the following features:

  • Searching for Lichess teams
  • List members of Lichess teams
  • Login/Logout, if one wants to access authorized parts of the API
  • Kick members from a Lichess team (if you are the team leader)

In case you don't like Java, people have also written API clients in other languages, such as Python for instance - like this one named Berserk.
And it is of course also possible to use the HTTP operations directly, without
using a library.

Should you choose to make a Lichess application, using any method,
consider blogging about it!

That's it for now,
thank you for your time! :)