Expand description
§litchee
An asynchronous, builder-pattern Rust client for the Lichess API.
litchee targets feature parity with the official API. It is async-first
(built on tokio + reqwest), because many Lichess endpoints stream
newline-delimited JSON (application/x-ndjson) — event streams, board and
bot game state, game exports, and more.
§Authentication
Two flows are supported:
- Personal access token — pass a token to the client builder.
OAuth2Authorization Code flow with PKCE — so applications can “Log in with Lichess”. See theoauthmodule.
§Naming
Every data-transfer object decoded from the API is prefixed with Lichess
(for example LichessUser, LichessGame, LichessToken).
§Quick start
Build a client and call an endpoint group accessor:
use litchee::LichessClient;
let client = LichessClient::builder().token("lip_your_token").build()?;
// A simple JSON request.
let me = client.account().profile().await?;
println!("Logged in as {}", me.user.username);
// A streaming (NDJSON) request.
use futures_util::StreamExt;
let mut games = client.games().export_user("bobby").max(5).stream().await?;
while let Some(game) = games.next().await {
println!("game {}", game?.id);
}See the examples/ directory for runnable programs, and the oauth module
for the “Log in with Lichess” PKCE flow.
Re-exports§
pub use error::LichessError;pub use error::Result;
Modules§
- api
- The Lichess API, organized by business concern.
- error
- Error types for the litchee client.
- model
- Shared, cross-cutting data types (
Lichess*DTOs) used by many concerns.
Structs§
- Lichess
Client - An asynchronous handle to the Lichess API.
- Lichess
Client Builder - A builder for
LichessClient. - Retry
Policy - Controls automatic retries of rate-limited (
429) requests. - Secret
- A value that must not appear in logs.