All Classes and Interfaces

Class
Description
Read and write account information and preferences.
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
Play on Lichess with physical boards and third-party clients.
 
 
 
 
 
Play on Lichess as a bot.
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
Send and receive challenges and manage bulk challenges.
 
 
 
 
 
 
 
 
 
 
 
Provides access to the Lichess API.
 
 
 
 
 
OAuth scopes representing different permissions
ClientAuth provides authenticated access to the Lichess API.
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
The TV Channels
 
Specifies who will be able to chat
 
 
 
 
 
The reasons for declining a challenge
 
 
 
 
 
 
 
The possible performance types
 
The possible performance types, excluding correspondence
 
 
 
Specifies a rating group, which includes ratings up to next rating group.
_1600 indicates ratings between 1600-1800 and _2500 indicates ratings from 2500 and up.
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
FIDE players and federations from their public download
https://lichess.org/fide
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
Access games played on Lichess.
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
A container for responses with multiple entries.
The response can be either Entries for successful requests or Fail for failed requests.
Client client = Client.basic();

Many<Pgn> good = client.studies().exportChaptersByStudyId("YtBYXc3m"); // "Beautiful Checkmates" by NoseKnowsAll
Many<Pgn> bad  = client.studies().exportChaptersByStudyId("non-existing-study-id");

System.out.println(good);  // Entries[stream=java.util.stream.ReferencePipeline$Head@3d121db3]
System.out.println(bad);   // Fail[status=404, info=Info[message=404 - Resource not found]]
A "lazy" way to access the values is to use the method Many.Many.stream() which is shared by all Many
List<Pgn> goodList = good.stream().toList();
List<Pgn> badList  = bad.stream().toList();

System.out.println(goodList.size()); // 64
System.out.println(badList.size());  // 0
The problem is that we don't know if the "badList" was empty because the Study was empty or because we failed to find the Study.
 
 
 
 
 
 
 
 
 
 
 
 
A container for responses with a single entry.
The response can be either Entry for responses with a value or None or Fail for responses without a value.
Client client = Client.basic();

One<User> good = client.users().byId("lichess");
One<User> bad  = client.users().byId("non-existing-user-id");

System.out.println(good);  // Entry[entry=User[id=lichess, username= ...
System.out.println(bad);   // Fail[status=404, info=Empty[]]
One way to access the value is via an Optional which can be gotten via One.maybe()
Optional<User> goodUser = good.maybe();
Optional<User> badUser  = bad.maybe();

goodUser.ifPresent(user -> System.out.println(user.username())); // Lichess
badUser.ifPresent(user  -> System.out.println(user.username())); //
Many of the Optional methods are also available directly via One for convenience
String goodName = good.map(user -> user.username()).orElse("No user!");
String badName  =  bad.map(user -> user.username()).orElse("No user!");

System.out.println(goodName); // Lichess
System.out.println(badName);  // No user!
Another way is to check the type
if (good instanceof Entry<User> u) {
    User user = u.entry();
    System.out.println(user.url()); // https://lichess.org/@/Lichess
}

if (bad instanceof Entry<User> u) {
    // not reached
}

// If we are interested in any failures, we can check for the Fail type
if (bad instanceof Fail<User> fail) {
    System.out.println(fail.status()); // 404
}
Note, "inverted" match in if-statements can also be used to get an entry into scope
if (! (good instanceof Entry<User> u)) {
    return;
}

User user = u.entry();  // The u-variable is reachable here!

var teams = client.teams().byUserId(user.id());
...
When Pattern Matching in switch arrives, we can leave out the if-statements
String message = switch(bad) {
     case Entry<User> user -> "Found user!";
     case NoEntry<User> nouser -> "Couldn't find user!"; // NoEntry "catches" both None and Fail
};

System.out.println(message); // Couldn't find user!
 
Lookup positions from the Lichess opening explorer.
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
Lookup positions from the Lichess tablebase server.
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
Access Arena and Swiss tournaments played on Lichess.
Official Arena tournaments are maintained by Lichess, but you can create your own Arena tournaments as well.
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
Access registered users on Lichess.