Overview
Chess tactics detection API — 10 patterns, confirmed material gain, ~200ms per position.
ChessGrammar is a REST API that detects tactical patterns in chess positions. Send a FEN string or a PGN game, get back every tactic with its trigger move, material gain, and forcing sequence.
Quick Start
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"}'
Response:
{
"tactics": [
{
"pattern": "fork",
"color": "black",
"trigger_move": "d4e2",
"key_squares": ["e2"],
"target_squares": ["g1", "c3"],
"gain": 700,
"is_mate": false,
"sequence": ["d4e2", "g1g2", "e2c3"]
},
{
"pattern": "discovered_attack",
"color": "black",
"trigger_move": "d4e2",
"key_squares": ["e5", "d4"],
"target_squares": ["c3"],
"gain": 700,
"is_mate": false,
"sequence": ["d4e2", "g1g2", "e2c3", "b2c3"]
}
],
"count": 2,
"performance_ms": 177.7,
"fen": "6k1/5p1p/..."
}
How It Works
Send a position (FEN) or a game (PGN). The engine scans for tactical patterns and confirms each one by calculating the actual material gain through best play. You receive the pattern type, trigger move, target squares, material gain, and the winning sequence of moves.
Endpoints
| Endpoint | Method | Input | Description |
|---|---|---|---|
/api/v1/extract | POST | "fen": "..." | Analyze a single position |
/api/v1/extract | POST | "pgn": "...", "mode": "played" | Analyze a full game |
/api/v1/health | GET | — | Service status |
Rate Limits
The public API is rate-limited to 30 requests per minute per IP. No API key required.