Kibitz API
Send a chess game. Get back its turning points explained in plain language, plus an annotated PGN you can show on any board.
The API is asynchronous: you start a job with POST /v1/annotate, then ask for its result with GET /v1/jobs/{id} until it is done. A game usually takes 30 to 60 seconds once a worker is warm, and up to about two minutes after a quiet period.
Authentication
Every request needs your API key in the Authorization header. Keep the key on your server; do not put it in an app or web page that users can inspect.
Authorization: Bearer YOUR_API_KEY
Keys are issued to early-access partners. Request one here, or write to omer@kibitzchess.info.
Quickstart
# 1. Start a job
curl -s -X POST https://api.kibitzchess.info/v1/annotate \
-H "Authorization: Bearer $KIBITZ_KEY" \
-H "Content-Type: application/json" \
-d '{"lichess": "https://lichess.org/AbCdEfGh", "notes": 3}'
# → {"id": "2616cfae-...", "status": "queued", "result": "/v1/jobs/2616cfae-..."}
# 2. Ask for the result every 5-10 seconds until "status" is "done"
curl -s https://api.kibitzchess.info/v1/jobs/2616cfae-... \
-H "Authorization: Bearer $KIBITZ_KEY"
import os, time, requests
API = "https://api.kibitzchess.info/v1"
HEADERS = {"Authorization": f"Bearer {os.environ['KIBITZ_KEY']}"}
job = requests.post(f"{API}/annotate", headers=HEADERS,
json={"pgn": open("game.pgn").read(), "notes": 3}).json()
while True:
time.sleep(8)
result = requests.get(f"{API}/jobs/{job['id']}", headers=HEADERS).json()
if result["status"] in ("done", "failed"):
break
for note in result.get("notes", []):
print(note["move"], note["grade"], "→", note["best"])
print(note["text"])
const API = "https://api.kibitzchess.info/v1";
const headers = { Authorization: `Bearer ${process.env.KIBITZ_KEY}`, "Content-Type": "application/json" };
const job = await (await fetch(`${API}/annotate`, {
method: "POST", headers, body: JSON.stringify({ pgn, notes: 3 }),
})).json();
let result;
do {
await new Promise(r => setTimeout(r, 8000));
result = await (await fetch(`${API}/jobs/${job.id}`, { headers })).json();
} while (!["done", "failed"].includes(result.status));
console.log(result.notes);
Start a job
The body is JSON. Send either pgn or lichess.
| Field | Type | Description |
|---|---|---|
pgn | string | The game in PGN. If the text holds several games, the first is used. Up to 100,000 characters. |
lichess | string | A Lichess game link or its 8-character id, instead of pgn. |
notes | integer | How many turning points to explain, 1 to 5. Default 3. Fewer come back if the game has fewer real mistakes. |
side | string | "both" (default), "white" or "black": whose mistakes to explain, for example only your user's. |
rating | integer | The reader's rating. Notes are simpler for lower ratings. Default: the player's rating from the PGN headers, else 1200. |
html | boolean | true also returns a self-contained board page (step through the moves, evaluation graph, notes with diagrams). Default false. |
Answer: 202 Accepted
{
"id": "2616cfae-b8b8-448d-973a-e019c7fd6c9b-u1",
"status": "queued",
"result": "/v1/jobs/2616cfae-b8b8-448d-973a-e019c7fd6c9b-u1"
}
Get the result
status is one of queued, running, done or failed. Ask again every 5 to 10 seconds until it is done or failed. Results are kept for about 30 minutes after the job ends.
The result
{
"id": "2616cfae-...",
"status": "done",
"notes": [
{
"move": "6... Nf6",
"grade": "mistake",
"best": "Qf6",
"text": "**Nf6** was a mistake. ... **Qf6** was best. ... The lesson: ...",
"written": true
}
],
"pgn": "[White \"Paul Morphy\"] ... 6... Nf6 $2 { Nf6 was a mistake. ... } ( 6... Qf6 7. Qb3 ... ) ...",
"seconds": 52.3
}
| Field | Description |
|---|---|
notes[].move | The move that was played, with its move number. |
notes[].grade | inaccuracy, mistake or blunder, measured in lost winning chances. |
notes[].best | The best move in that position. |
notes[].text | The explanation, written to the player ("you"). Moves are in **bold** (Markdown). |
notes[].written | true: an explanation by the coach model. false: a short engine note (grade, the opponent's best answer, the better line), used when the explanation did not pass our checks. See How notes are made. |
pgn | The game with ?!/?/?? marks, the notes as comments, the better line as a variation, and an evaluation on every move. Lichess draws its evaluation graph from it after an import. |
html | Only if you asked for it: the board page as one HTML document. |
seconds | Time spent on the analysis. |
Errors
Errors come back as JSON: {"error": "what went wrong"}.
| Code | Meaning |
|---|---|
400 | The body is not JSON, has neither pgn nor lichess, or the job id is malformed. |
401 | The API key is missing or not valid. |
404 | No job with that id, or its result has expired. |
413 | The PGN is longer than 100,000 characters. |
422 | The game could not be read (for example a broken PGN or a game with no moves). The job's status is failed. |
502 | The analysis service is briefly unavailable. Try again in a minute. |
Timing and limits
- A game takes about 30 to 60 seconds on a warm worker. After a quiet period the first game waits up to about a minute longer while a worker starts.
- Several games can run at the same time; each is analysed independently.
- Results stay available for about 30 minutes. Store what you need.
- During early access, usage and pricing are agreed with each partner.
How notes are made
Stockfish 19 checks every position of the game and finds the moves that gave away the most. For each one, code builds a fact sheet from the engine's lines: what the move allowed, the better move and why it works, and the threats involved. Our coach model then writes the explanation from that sheet, for the reader's rating.
Before a note is returned, a checker compares it with the sheet. It catches invented moves, pieces on the wrong square, wrong mates and wrong move order. A note that fails is replaced by a short engine note, marked "written": false.