jalpp / stockfish-rest-api

WIP Stockfish REST API

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Work in progress Stockfish REST API

making this for my own chess discord bots and other chess software that need stockfish best moves within 3 seconds. (I'm NOT trying to sell this or whatever in the name of Stockfish), mostly used for internal software, and of course it be free if I deploy it for other devs!!

Credits to:

Running it:

  • running on debug mode which runs the engine on server start by selecting engine mode (wasm or cc-nonnue) or run help to see server commands
  • node server.js debug wasm
    • node server.js debug cc-nonnue
  • node server.js debug cc-yesnnue
  • node server --help
  • running without debug mode and starting the server
  • node server.js

Endpoint parameters

  • mode = run webassembly Stockfish (wasm) or No NNUE ChessCom Stockfish 16 (cc-nonnue) or Yes NNUE ChessCom Stockfish 16 (cc-yesnnue)
  • depth = for wasm implementation [1 to 20] for Chesscom Stockfish 16 no NNUE version [1 to 16], for ChessCom Stockfish 16 yes NNUE version [1 to 22+] cap at depth 22, if one needs more they can request it
  • fen = chess FEN for given position

Working endpoints

  • Get best move for current FEN and MODE (pass in engine mode [wasm, cc-nonnue]) GET localhost:5000/stockfish/bestmove?fen=rnbqkbnr/pppp1ppp/4p3/8/4P3/8/PPPP1PPP/RNBQKBNR w KQkq - 0 2
  • Get eval for current FEN and MODE(pass in engine mode [wasm, cc-nonnue]) GET localhost:5000/stockfish/eval?fen=rnbqkbnr/pppp1ppp/4p3/8/4P3/8/PPPP1PPP/RNBQKBNR w KQkq - 0 2
  • Get top engine line and depth info for given engine MODE and DEPTH and FEN
  • GET localhost:5000/stockfish/toplines?fen=rnbqkbnr/pppp1ppp/4p3/8/4P3/8/PPPP1PPP/RNBQKBNR w KQkq - 0 2&depth=20&mode=wasm
  • GET localhost:5000/stockfish/toplines?fen=rnbqkbnr/pppp1ppp/4p3/8/4P3/8/PPPP1PPP/RNBQKBNR w KQkq - 0 2&depth=16&mode=16

TODOs

  • add NNUE engine type to bestmove (fixed needs review)
  • add NNUE engine type to eval (fixed needs review)
  • add NNUE engine type to lines (buggy code)
  • change lines to pv

License:

follows same as Stockfish GPL

About

WIP Stockfish REST API

License:GNU General Public License v3.0


Languages

Language:C++ 60.8%Language:JavaScript 24.5%Language:HTML 8.6%Language:C 3.6%Language:Makefile 1.5%Language:Python 0.7%Language:WebAssembly 0.2%