Engines & analysis · Developers

Stockfish API: How to Get Stockfish Moves From Code

Stockfish has no official web API: it is a program that talks the UCI protocol, so you either run it yourself or call a service that runs it for you. The quickest free option is our endpoint, https://chessmovefinder.com/api/mcp: one POST returns Stockfish 17.1’s best moves, evaluation and continuation, with no key. Lichess’s cloud-eval endpoint covers positions already in its database, and for unlimited or deep analysis you run Stockfish yourself with a library such as python-chess.

Official API?
NoStockfish speaks UCI
Free hosted option
Our MCP endpointStockfish 17.1, no key
Request
One POSTJSON-RPC tools/call
Search time
0.3–3 sdefault 1.5 s, depth ~15–20
Lines
1–3best moves returned
Self-host
python-chessor any UCI wrapper

Is there an official Stockfish API?

No. Stockfish is a command-line engine. Programs talk to it with the Universal Chess Interface (UCI): you send text commands such as position fen … and go depth 20, and it prints info lines and a bestmove. The Stockfish wiki puts it plainly: developers should communicate with Stockfish via the UCI protocol (Stockfish wiki).

So a “Stockfish API” is always one of two things: a library that wraps UCI on your own machine, or a web service that runs Stockfish on its servers and returns the result over HTTP. Need the engine first? See how to download Stockfish.

Stockfish API options compared

Ways to get Stockfish analysis from code
OptionRun byInterfaceEngineLimitsAccessGood for
Chess Move Finder MCPOur free endpointPOST (JSON-RPC, MCP)Stockfish 17.10.3–3 s search, 1–3 linesNo key; fair-use limitAI assistants, bots, small apps
Lichess cloud evaluationLichessGET /api/cloud-evalStockfish (stored evals)Only positions already in the cloud databaseNo key; rate limitedCommon positions, openings
Lichess External EngineLichessHTTP APIYour own engineWhatever you runLichess accountUsing your engine inside Lichess
chess-api.comThird partyPOST /v1, WebSocketStockfish 17 NNUE (per its site)Depth limitedSee its docsFront-end projects
stockfish.onlineThird partyGET /api/s/v2.phpStockfishdepth parameterSee its docsQuick experiments, microcontrollers
Run it yourselfYouUCI over stdin/stdoutAny version (Stockfish 19)Unlimited: your hardwareFree (GPLv3)Production, deep analysis

Third-party services change; check each provider’s documentation before relying on it. Sources: Lichess API, chess-api.com, stockfish.online example (chess.com), Chess Stack Exchange.

Our free Stockfish endpoint

Chess Move Finder runs a public, read-only endpoint at https://chessmovefinder.com/api/mcp. It uses the Model Context Protocol (MCP), so AI assistants such as Claude can connect to it directly, but it is also a plain HTTP API: send one JSON-RPC tools/call request and you get the answer back as JSON. Full details are in the developer documentation.

  • Engine: Stockfish 17.1. Each search runs 0.3–3 seconds (default 1.5 s), which usually reaches depth 15–20.
  • Tools: find_best_move (1–3 best moves with evaluation and continuation), describe_position (checks a FEN), legal_moves and apply_moves (turns a move list into a FEN).
  • Access: no key and no sign-in. Engine calls have an abuse limit, and the server may ask you to retry when it is busy.

Example request

curl -s https://chessmovefinder.com/api/mcp \
  -H 'Content-Type: application/json' \
  -H 'Accept: application/json, text/event-stream' \
  -d '{"jsonrpc":"2.0","id":1,"method":"tools/call","params":{"name":"find_best_move","arguments":{"fen":"r1bqkbnr/pppp1ppp/2n5/4p3/3PP3/5N2/PPP2PPP/RNBQKB1R b KQkq - 0 3","lines":2,"think_time_ms":1500}}}'

Real response

This is the JSON part of a real response to that request (we shortened only the link):

{
  "fen": "r1bqkbnr/pppp1ppp/2n5/4p3/3PP3/5N2/PPP2PPP/RNBQKB1R b KQkq - 0 3",
  "sideToMove": "Black",
  "engine": "Stockfish 17.1 (lite, single thread)",
  "thinkTimeMs": 1500,
  "scorePerspective": "White: positive favours White, negative favours Black",
  "lines": [
    {
      "rank": 1,
      "move": "exd4",
      "uci": "e5d4",
      "evaluation": "+0.38",
      "meaning": "White is slightly better.",
      "depth": 20,
      "continuation": "exd4 Nxd4 Nf6 Nxc6 bxc6 Bd3 Be7 O-O O-O Nd2 Re8 Qe2"
    },
    {
      "rank": 2,
      "move": "Nxd4",
      "uci": "c6d4",
      "evaluation": "+0.64",
      "meaning": "White is slightly better.",
      "depth": 20,
      "continuation": "Nxd4 Nxd4 exd4 Qxd4 Qf6 Qe3 Bb4+ c3 Be7 Bd3 Qe6 O-O"
    }
  ],
  "analysisUrl": "https://chessmovefinder.com/tools/analysis#fen=…"
}

Scores are from White’s point of view: +0.38 means White is slightly better, even with Black to move. Every response also links to the position on our analysis board.

JavaScript

const res = await fetch("https://chessmovefinder.com/api/mcp", {
  method: "POST",
  headers: {
    "Content-Type": "application/json",
    "Accept": "application/json, text/event-stream",
  },
  body: JSON.stringify({
    jsonrpc: "2.0", id: 1, method: "tools/call",
    params: { name: "find_best_move", arguments: { fen, lines: 2 } },
  }),
});
const { result } = await res.json();
console.log(result.content[0].text);

Build a request

Paste a FEN and choose the options; copy the command into a terminal.

curl -s https://chessmovefinder.com/api/mcp \
  -H 'Content-Type: application/json' \
  -H 'Accept: application/json, text/event-stream' \
  -d '{"jsonrpc":"2.0","id":1,"method":"tools/call","params":{"name":"find_best_move","arguments":{"fen":"r1bqkbnr/pppp1ppp/2n5/4p3/3PP3/5N2/PPP2PPP/RNBQKB1R b KQkq - 0 3","lines":2,"think_time_ms":1500}}}'

Not sure how to write a FEN? Set up the position in the board editor and copy it, or read FEN vs PGN.

Lichess cloud evaluation

Lichess exposes stored Stockfish evaluations through GET /api/cloud-eval (Lichess API reference). It is free and fast, but it only knows positions that are already in its cloud database, typically positions that Lichess users have analysed, so new middlegame positions often return “not found”.

curl -s 'https://lichess.org/api/cloud-eval?fen=r1bqkbnr%2Fpppp1ppp%2F2n5%2F4p3%2F3PP3%2F5N2%2FPPP2PPP%2FRNBQKB1R%20b%20KQkq%20-%200%203&multiPv=2'

Lichess also has an External Engine API for the opposite direction: running your own engine and using it inside Lichess’s analysis board.

Run Stockfish yourself (Python)

For unlimited, deep or production use, run Stockfish on your own machine or server. In Python, the python-chess engine module handles UCI for you:

import chess
import chess.engine

board = chess.Board("r1bqkbnr/pppp1ppp/2n5/4p3/3PP3/5N2/PPP2PPP/RNBQKB1R b KQkq - 0 3")
with chess.engine.SimpleEngine.popen_uci("/path/to/stockfish") as engine:
    info = engine.analyse(board, chess.engine.Limit(depth=20), multipv=2)
    for line in info:
        print(board.san(line["pv"][0]), line["score"].white())

Install it with pip install chess and point popen_uci at the Stockfish file you downloaded. To expose it as your own API, wrap this in a small web service (FastAPI, Express or similar) and put a queue in front of it: each search uses a full CPU core for its duration.

Licence: Stockfish is GPLv3 (GNU). Shipping it inside an app you distribute means providing its source under the GPL; running it on your own server is generally not distribution. This is not legal advice.

Which Stockfish API should you use?

  • Chatbot, AI assistant or hobby project: our endpoint. One request, no key, Stockfish 17.1, clear text and JSON.
  • Opening positions only: Lichess cloud eval, which is instant for positions it already knows.
  • Heavy traffic, deep searches or the newest engine: run Stockfish 19 yourself.
  • Analysis in the browser with no server: a WebAssembly build of Stockfish, which is what our analysis board uses.

FAQ

Does Stockfish have an official API?

No. Stockfish is a program that speaks the UCI protocol over standard input and output; the Stockfish team does not run a public web API. Developers either run Stockfish themselves or use a service that runs it for them.

Is there a free Stockfish API?

Yes, several. Our endpoint at https://chessmovefinder.com/api/mcp is free with no key and runs Stockfish 17.1; Lichess’s cloud-eval endpoint is free for positions already in its database; chess-api.com and stockfish.online offer free HTTP access with their own limits.

How do I get the best move from Stockfish in Python?

Install python-chess (pip install chess), download Stockfish, then open it with chess.engine.SimpleEngine.popen_uci and call engine.play or engine.analyse with a depth or time limit, as in the example on this page.

Can I use the Chess Move Finder endpoint in my app?

Yes, for reasonable use. It is a public, read-only MCP endpoint: each search runs 0.3–3 seconds and there is an abuse limit on engine calls. For heavy or deep analysis, run Stockfish on your own server.

What is the difference between depth and time limits?

A depth limit stops the search after a set number of plies; a time limit stops it after a set number of milliseconds. Time limits keep response times predictable on servers; depth limits make results more reproducible.

Can I use Stockfish in a commercial product?

Stockfish is licensed under GPLv3. You can use it commercially, but if you distribute it (for example inside an app), you must also provide the source code under the GPL. Running it on your own server is generally not distribution. Check the licence for your case; this is not legal advice.

Sources and how we checked

No code needed

Find the best move in any position.

Set up a position and let Stockfish show you the best move, free in your browser.

Find the best move →

Keep reading