11

Is there an online chess evaluation engine with a REST API? I'd like to be able to send a game or position (with castling ability presumably) to a simple REST API and get back the positional evaluation from a reasonably strong engine.

2
  • 1
    Nobody expects the inquisition. analysis.cpuchess.com is pretty close, but no API Mar 21, 2016 at 0:29
  • @Peter You can program the JavaScript to give positions to analysis.cpuchess.com and read results back.
    – SmallChess
    Mar 21, 2016 at 8:26

2 Answers 2

4
+100

The project https://github.com/noobpwnftw/chessdb provides an API for getting engine evaluations including also the PV, with the FEN of a position as input.

E.g., try an example from the readme:

https://www.chessdb.cn/cdb.php?action=querypv&board=rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNR%20w%20KQkq%20-%200%201&json=1

The response I got is:

{
  "status": "ok",
  "score": 8,
  "depth": 39,
  "pv": [
    "e2e4", "c7c5", "d2d4", "c5d4", "g1f3", "e7e5", "c2c3", "b8c6", "f1c4", "g8f6", "f3g5", "d7d5", "e4d5", "c6a5", "c4b5", "c8d7", "d1e2", "f8d6", "b2b4", "h7h6", "g5f3", "e8g8", "b4a5", "d4d3", "e2b2", "f6d5", "b1d2", "d7b5", "b2b5", "d5c3", "b5d3", "d6b4", "d3d8", "f8d8", "a5a6", "b7a6", "a2a3", "b4a5", "e1f1"
  ],
  "pvSAN": [
    "e4", "c5", "d4", "cxd4", "Nf3", "e5", "c3", "Nc6", "Bc4", "Nf6", "Ng5", "d5", "exd5", "Na5", "Bb5+", "Bd7", "Qe2", "Bd6", "b4", "h6", "Nf3", "O-O", "bxa5", "d3", "Qb2", "Nxd5", "Nbd2", "Bxb5", "Qxb5", "Nxc3", "Qxd3", "Bb4", "Qxd8", "Rfxd8", "a6", "bxa6", "a3", "Ba5", "Kf1"
  ]
}
5
  • 1
    It is essentially functioning as an opening book api and not able to evaluate unknown positions on-the-fly. e.g. chessdb.cn/cdb.php?action=querypv&board=8/7K/P2P4/1b1k3p/…
    – prusswan
    Jul 6, 2019 at 17:44
  • That's what I infer too. Funny comment at bottom "Expect no further documentation except this one but the code should be self-explanatory", even though there isn't a single line explaining what it is :) Oct 22, 2021 at 2:32
  • Interesting find. I awarded the bounty although this question remains open. I'm rather surprised that in 2021 the world doesn't have a chess position evaluation API ! Oct 25, 2021 at 13:06
  • It appears to be giving perfectly legitimate results. I ran queries from this FEN: r1bqkb1r/ppp2ppp/5n2/n2Pp1N1/2B5/8/PPPP1PPP/RNBQK2R w KQkq - 1 6 and it gave the expected results. Aug 27, 2022 at 5:38
  • @PeterCotton is the "Request for Analysis" here what you are looking for? chessdb.cn/cloudbookc_api_en.html Depending on the current load it can take a bit for the analysis to happen, but then you can probe it.
    – koedem
    Oct 11 at 9:32
3

I'm a bit late, but https://stockfish.online is a REST GET API for Stockfish. Make requests with a FEN string, depth, and mode. For example, making a GET request to https://stockfish.online/api/stockfish.php?fen=r2q1rk1/ppp2ppp/3bbn2/3p4/8/1B1P4/PPP2PPP/RNB1QRK1 w - - 5 11&depth=13&mode=bestmove would get the best move for the given FEN string at depth 13. Hope this helps!

Not the answer you're looking for? Browse other questions tagged or ask your own question.