HTTP API¶
Everything the interface does, it does through this API. It is served on
http://localhost:8000/api/… by server.py, binds to loopback only, and has no
authentication because it has no remote surface to authenticate.
Requests and responses are JSON, except the handful of endpoints that return a file.
Errors come back as {"error": "…"} with a 4xx or 5xx status and a message written to be
shown to a person.
Computer opponent¶
POST /api/engine/play accepts {"fen":"…","level":5}. Level must be 1–11.
The response uses the analysis payload (fen, bestmove, lines, engine).
This bounded search uses a separate one-thread, 32 MB Stockfish process, with
Skill Level (level - 1) * 2 and 100 + level * 75 milliseconds. It does not
alter the live-analysis or annotation engines. Invalid levels return 400; an
unavailable engine returns 503.
GET /api/collections includes indexed_games for each collection, counting
both owned and linked games that have a completed position index.
Library¶
Method |
Path |
What it does |
|---|---|---|
|
|
liveness, paths, and whether the engine is available |
|
|
game, collection and index counts |
|
|
every collection with its |
|
|
create one — |
|
|
the whole collection as one PGN download |
|
|
remove it; |
Games¶
GET /api/games takes the filters below as query parameters and returns
{total, games: [...]}. limit defaults to 100 and caps at 500; offset pages. Every
game carries collections: [{id, name, kind, owner}], the shelves holding it, owner
first.
A collection filter matches the games a collection owns and the games linked onto it.
Import responses report linked alongside added, duplicates and skipped.
- Selecting what is listed
kind—games(the database’s default),studies,openings, or empty for everything.collection— id or name.- Who played
qfree text,player,white,black,min_elo,max_elo,white_min_elo,white_max_elo,black_min_elo,black_max_elo,outcome(win/loss/draw, read from the player you named),result.- What was played
eco,eco_to,opening,variation,min_length,max_length,position(a FEN, matched through the position index).- Where and when
event,site,round,year,date_from,date_to,event_type,event_date_from,event_date_to.- ChessBase tags
team,title,fide_id,source_title— each matching either player where the tag is per-side.- Provenance and your own labels
annotator,termination,annotated(0/1),source,tag,category,added_from,added_to.- Order
sort—added,date,date_asc,event_date,event,round,elo,white,black,eco,opening,result,annotator,length.
Method |
Path |
What it does |
|---|---|---|
|
|
one game, with its PGN text |
|
|
import — |
|
|
replace a game’s PGN, keeping its id |
|
|
remove one game from the index |
|
|
the collections holding this game, owner first |
|
|
|
|
|
remove a link; a game’s own collection cannot be unlinked |
|
|
|
|
|
|
Importing¶
Method |
Path |
What it does |
|---|---|---|
|
|
progress of the import currently running |
|
|
recent batches, with counts and undone state |
|
|
|
|
|
|
|
|
|
|
|
|
The engine¶
Method |
Path |
What it does |
|---|---|---|
|
|
engine name, path, threads, hash, and core counts |
|
|
|
|
|
current lines, search statistics and machine telemetry |
|
|
stop it |
|
|
|
|
|
|
|
|
progress and results |
|
|
stop the annotation run |
A GET /api/engine/live response carries lines, plus depth, seldepth, nodes,
nps, hashfull, tbhits, time, the engine’s own cpu_percent and memory_mb, and
a machine object with cores, cpu_percent, cpu_mhz, memory, temperature_c and
power_w. Any reading the machine does not publish is null rather than estimated.
Study and positions¶
Method |
Path |
What it does |
|---|---|---|
|
|
games, continuations, decades and pins for a position |
|
|
|
|
|
indexing progress |
|
|
your notes and links on a position |
|
|
study folders on disk, and their category |
|
|
|
|
|
a game’s library labels |
Repertoires¶
Method |
Path |
What it does |
|---|---|---|
|
|
every repertoire, newest first |
|
|
one, with its lines as JSON |
|
|
create or replace |
|
|
remove one |
|
|
|
lichess account¶
Method |
Path |
What it does |
|---|---|---|
|
|
who the stored token belongs to, its scopes, and where to make one |
|
|
|
|
|
forget the token |
|
|
studies visible to the token (or to |
|
|
|
|
|
the game watcher’s settings and what it last did |
|
|
|
|
|
check lichess now, whether or not the watcher is running |
The token is never returned by any endpoint. GET /api/settings/lichess_token is
refused with 403.
Your own openings¶
The explorer’s report. Every route takes the same filters: collection, player,
color (w/b), speed (one or several of bullet, blitz, rapid, classical,
correspondence, comma-separated), rated (0/1), since, until (a year, month or
day), min_opponent_elo, max_opponent_elo, kind. With no player the report reads
from White’s side.
Method |
Path |
What it does |
|---|---|---|
|
|
totals, per-move statistics and a per-year trend, from the player’s side |
|
|
the lines that cost the most points — |
|
|
the names that actually appear in a collection, for the player box |
Scores are percentages from the report’s side of the board: score_pct, with wins,
draws, losses and avg_opponent_elo beside them. weakest entries carry line (the
numbered moves) and moves (the SAN list, so the line can be replayed), plus
points_dropped.
Reference material¶
Method |
Path |
What it does |
|---|---|---|
|
|
opening book: bundled, your indexed games, or lichess online |
|
|
the lichess explorer, cached in your library |
|
|
seven-piece endgame result, cached |
|
|
free study references for a line |
|
|
Wikipedia background for a game |
|
|
opening names present in your library, with their ECO span |
|
|
name the openings of games that carry none |
|
|
master-game search and the crawler |
|
|
whether online services are reachable |
Books, sounds and settings¶
Method |
Path |
What it does |
|---|---|---|
|
|
list PDFs, or add one as base64 |
|
|
the PDF itself, with range requests |
|
|
remember the page you are on |
|
|
which sample sets are installed, and the events each covers |
|
|
preferences; secret keys are refused |