The Chess Snapshot API provides an easy-to-use RESTful interface for detecting and analyzing chess positions from images. It utilizes the Chess Position Detector to convert a chessboard image into a FEN string and integrates the powerful Stockfish chess engine to determine the best move from any given position.
This API is intended for integration with a Flutter application, offering seamless support for the Chess Snapshot App.
- Python 3 (Python 3.10 is recommended)
- Ngrok
Ensure that Python is installed on your machine. You can install the necessary dependencies using pip
and the requirements.txt
file.
pip install -r requirements.txt
- OpenCV
- Numpy
- Flask
- Stockfish
- ...
These dependencies are necessary for image processing, detection algorithms, and chess analysis.
To use the Chess Snapshot API
, follow these steps:
-
Start the Flask Server:
python app.py
-
Expose the Server with Ngrok:
ngrok http --domain=knowing-fit-poodle.ngrok-free.app 8080
-
Get Chess Position (FEN String)
- URL:
/api/get_chess_position
- Method:
POST
- Description: This endpoint accepts an image file of a chessboard and returns the FEN string representing the position on the board.
- Response Example:
{ "fen": "rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNR" }
- URL:
-
Get Best Move
- URL:
/api/get_best_move
- Method:
POST
- Description: This endpoint accepts a FEN string and returns the best move as calculated by Stockfish.
- Response Example:
{ "best_move": "e2e4" }
- URL:
This project is based on advanced computer vision techniques and was supervised by Lect. Dr. Ioana Cristina Plajer.
Read More: Chess Snapshot Full Documentation in Romanian (PDF)