Skip to content

Simple Stockfish integration, allowing users to access powerful chess engine functionality, retrieve moves and evaluations from FEN

Notifications You must be signed in to change notification settings

vigneshsaravanakumar404/Stockfish_API_Wrapper

Repository files navigation

Stockfish API Wrapper

Simple Stockfish API wrapper. Allows users to access powerful chess engine functionality, retrieve moves and evaluations from FEN and complete use of all Stockfish methods from native c++ code. Provides a convenient way to access Stockfish from anywhere. The API Wrapper is used in my Mobile Application Development Course final, Chess.

Installation

Clone the project and Stockfish 15.1

  git clone https://github.com/vigneshsaravanakumar404/Stockfish_API_Wrapper.git
  git clone https://github.com/official-stockfish/Stockfish.git

Install dependencies

  pip install
  pip stockfish
  pip Flask
  pip pyuac

Change stockfish path from

    STOCKFISH_PATH = "C:/Users/vigne/PycharmProjects/Stockfish_API_Wrapper/Stockfish/src/stockfish.exe"

to your stockfish path in app.py

Run the program and start Ngrok tunnel

  python app.py
  ngrok http 5000

API Reference

Get best move based on elo

  GET /api/bestmove/
Parameter Type Description
elo int Required Elo Stockfish will play at
contempt int Aggression of Stockfish
min-split-depth int Minimum depth Stockfish will search to
ponder boolean Allow the engine to think during opponent's turn
threads int Number of threads Stockfish will use
multipv int Number of best moves to return
fen string Required FEN of board position
minimum-thinking-time int Minimum thinking time
uci-chess960 boolean Set Chess960
uci-limit-strength boolean Limit max Stockfish level

Get best move based on level

    GET /api/bestmove/
Parameter Type Description
skill-level int Required Elo Stockfish will play at
contempt int Aggression of Stockfish
min-split-depth int Minimum depth Stockfish will search to
ponder boolean Allow the engine to think during opponent's turn
threads int Number of threads Stockfish will use
multipv int Number of best moves to return
fen string Required FEN of board position
minimum-thinking-time int Minimum thinking time
uci-chess960 boolean Set Chess960
uci-limit-strength boolean Limit max Stockfish level

Check if FEN is valid

    GET /is-fen-valid/
Parameter Type Description
fen string Required FEN of board position

Check if move is valid

    GET /is-move-correct/
Parameter Type Description
fen string Required FEN of board position
move string Required Move to check

Get evaluation of position

    GET /get-evaluation/
Parameter Type Description
fen string Required FEN of board position

Get top moves

    GET /get-top-moves/
Parameter Type Description
fen string Required FEN of board position
number int Required Number of moves

Screenshots

Flask server running on localhost

img_3.png

Flask server tunnelled on Ngrok

img_1.png

Sample output for request of top 5 best moves in standard chess position

img.png

Tech Stack

Python Stockfish Flask IntelliJ IDEA

References

About

Simple Stockfish integration, allowing users to access powerful chess engine functionality, retrieve moves and evaluations from FEN

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published