Simple REST Chess API

Simple REST API to get legal moves, make a move and get recommended moves on a chess board. The API uses python-chess to evaluate the board and Stockfish to analyze the next best moves, as well as score the board.

The API uses the Forsyth–Edwards Notation to pass and return the board state. Move list are returned in UCI format.

API Endpoint: http://www.dplouffe.ca/api/chess/[endpoint]

 

Endpoints

score

Score a board position.

METHOD: GET

QUERY PARAMETERS
fen: The FEN representation of your board state.

RESULTS
turn
The color of the next player to move
stalemate
True if the board state is in stalemate
checkmate
True if the board state is in checkmate
score
The score stockfish gives the current board state. Positive = White is better, Negative = Black is better
depth
The number of moves ahead stockfish analyzes
moves
A list of the moves that stockfish is predicting in UCI format. The first move is the next move stockfish thinks you should do; the second moves is the move stockfish thinks your opponent should do and so on.

EXAMPLE
Click Me


legal_moves

Get a list of legal moves back from the API.

METHOD: GET

QUERY PARAMETERS
fen: The FEN representation of your board state.

RESULTS
turn
The color of the next player to move
stalemate
True if the board state is in stalemate
checkmate
True if the board state is in checkmate
legal_moves
A list of the legal moves, in UCI format, that a player can execute during the next turn.

EXAMPLE
Click Me