0

I'm on the hunt for an online Stockfish API where I can send either a FEN/PGN position or a list of moves and get back some info like evaluations / variants / best moves.

I've been scouring StackExchange posts, but most of the services I've found seem to have gone AWOL. I stumbled upon the stockifish.online website, but it's a bit sluggish and doesn't offer much data.

Got any other leads?

2 Answers 2

3

I found https://chess-api.com/. Quite easy but has limited depth (18). Runs SF 16.1 NNUE.

Example POST request:

async function postChessApi(data = {}) {
    const response = await fetch("https://chess-api.com/v1", {
        method: "POST",
        headers: {
            "Content-Type": "application/json"
        },
        body: JSON.stringify(data),
    });
    return response.json();
}
postChessApi({ fen: "7Q/8/8/6k1/2K5/8/8/8 w - -", depth: 30, variants: 1 }).then((data) => {
    console.log(data);
});

Response:

{
    "text": "Move h8 → e5 (Qe5+): [100]. White is winning. Depth 18.",
    "captured": false,
    "promotion": false,
    "isCapture": false,
    "isPromotion": false,
    "isCastling": false,
    "fen": "7Q/8/8/6k1/2K5/8/8/8 w - - 0 1",
    "type": "bestmove",
    "depth": 18,
    "move": "h8e5",
    "eval": 100,
    "centipawns": 10000,
    "mate": "13",
    "continuationArr": [
        "g5g6",
        "e5e6",
        "g6g5",
        "c4d4",
        "g5f4",
        "e6f6",
        "f4g3",
        "f6f5",
        "g3g2",
        "d4d3",
        "g2g3",
        "d3e2",
        "g3h4",
        "e2e3",
        "h4g3",
        "f5g5",
        "g3h2"
    ],
    "debug": "info depth 18 seldepth 21 multipv 1 score mate 13 nodes 98918 nps 32972666 hashfull 15 tbhits 0 time 3 pv h8e5 g5g6 e5e6 g6g5 c4d4 g5f4 e6f6 f4g3 f6f5 g3g2 d4d3 g2g3 d3e2 g3h4 e2e3 h4g3 f5g5 g3h2",
    "winChance": 100,
    "taskId": "8w3cp3pf1",
    "turn": "w",
    "color": "w",
    "piece": "q",
    "from": "h8",
    "to": "e5",
    "san": "Qe5+",
    "flags": "n",
    "lan": "h8e5",
    "fromNumeric": "88",
    "toNumeric": "55",
    "continuation": [
        {
            "from": "g5",
            "to": "g6",
            "fromNumeric": "75",
            "toNumeric": "76"
        },
        {
            "from": "e5",
            "to": "e6",
            "fromNumeric": "55",
            "toNumeric": "56"
        }
    ]
}
2

I think it's unlikely that you will find publically accessible API like this, since engines aren't cheap to run on scale.

However you can get pretty close. First option is Lichess cloud evaluations database that exposes engine evaluations for 15 million positions via API. Data available is analysis depth, kilonodes and best variations.

If you are prepared to host engine yourself and just need to make it accessible via API it's possible with Lichess external engine API.

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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