Getting Started

Make your first API call in 30 seconds.

Base URL

https://chessgrammar.com/api/v1

No API key or authentication required during the Developer Preview.

Your first call

Analyze a position for tactical patterns:

curl -X POST https://chessgrammar.com/api/v1/extract \
  -H "Content-Type: application/json" \
  -d '{"fen": "6k1/5p1p/4p3/4q3/3n4/2Q3P1/PP1N1P1P/6K1 b - - 3 37"}'

This position contains a knight fork and a discovered attack. The response:

{
  "tactics": [
    {
      "pattern": "fork",
      "color": "black",
      "trigger_move": "d4e2",
      "key_squares": ["e2"],
      "target_squares": ["g1", "c3"],
      "targets": [
        {"square": "g1", "piece": "K", "piece_name": "king", "color": "white"},
        {"square": "c3", "piece": "Q", "piece_name": "queen", "color": "white"}
      ],
      "gain": 700,
      "gain_confirmed": true,
      "is_mate": false,
      "sequence": null,
      "fen": "6k1/5p1p/..."
    },
    {
      "pattern": "discovered_attack",
      "color": "black",
      "trigger_move": "d4e2",
      "key_squares": ["e5", "d4"],
      "target_squares": ["c3"],
      "gain": 700,
      "gain_confirmed": true,
      "is_mate": false,
      "sequence": null,
      "fen": "6k1/5p1p/..."
    }
  ],
  "count": 2,
  "depth": "l2",
  "performance_ms": 48.2,
  "fen": "6k1/5p1p/..."
}

Reading the response

Each tactic in the tactics array contains:

FieldDescription
patternTactic type: fork, pin, skewer, discovered_attack, double_check, back_rank_mate, smothered_mate, deflection, interference, trapped_piece
colorWhich side has the tactic (white or black)
trigger_moveThe move that initiates the tactic (UCI format)
key_squaresThe critical square(s) involved
target_squaresThe squares of the attacked/affected pieces
targetsDetailed info on each target (square, piece type, color)
gainMaterial gain in centipawns (100 = pawn, 300 = knight/bishop, 500 = rook, 900 = queen)
gain_confirmedtrue if confirmed through forcing tree (L2), false for L1 candidates
is_matetrue if the tactic leads to checkmate
sequenceForcing move sequence (only when with_sequence: true)

Try it interactively

The Playground lets you paste a FEN or PGN and see results instantly, with a visual board.

Next steps