Powered by Stockfish 17 lite NNUE. Free API access is available; paid subscriptions are not enabled.
Documentation / Guides
Stockfish from JavaScript and TypeScript
fetch in Node, Deno, Bun and the browser
Node 18+ and the browser use the same code
const API = "https://stockfishapi.com/v1";
export async function evaluate(fen: string, depth = 14, multipv = 1) {
const res = await fetch(`${API}/eval`, {
method: "POST",
headers: { Authorization: `Bearer ${process.env.STOCKFISH_API_KEY}`, "Content-Type": "application/json" },
body: JSON.stringify({ fen, depth, multipv }),
});
if (!res.ok) throw Object.assign(new Error("stockfishapi"), { problem: await res.json(), status: res.status });
return res.json() as Promise<{ bestmove: string; eval: { type: "cp" | "mate"; value: number }; cost_units: number }>;
}
In the browser
Keyless calls work from any origin at depth ≤ 10, which is enough for a demo. For anything more, call from your server so the key stays secret, or mint a scoped key with a small budget (POST /v1/keys {"scopes":["eval"],"budget_units":500}) and accept that it is public.
With chess.js
import { Chess } from "chess.js";
const game = new Chess();
game.move("e4");
const { bestmove } = await evaluate(game.fen(), 12);
game.move({ from: bestmove.slice(0, 2), to: bestmove.slice(2, 4), promotion: bestmove[4] }); Get a key with one call: POST /v1/signup {"email":"you@example.com"}. Free plan, depth 14, 2,000 units a day.