Documentation / Guides
A lichess bot backed by the API
Before your first request, sign in with Google, create a key for 100 free requests with a verified email, then add a card. Start with 100 free requests with a verified email, then add a card for 2,000 units/day and automatic overage billing. The trial is shared across your account, never resets, and is never charged. All prices are in USD.
play on lichess without hosting an engine
Shape
Use the official lichess-bot framework with a homemade engine class: on each turn, call POST /v1/bestmove with the board FEN and a movetime_ms matching your clock budget, then play the move. options.elo lets the bot play at a rating instead of full strength, which lichess bot etiquette appreciates.
class ApiEngine:
def __init__(self, key, elo=None):
self.h = {"Authorization": f"Bearer {key}"}
self.opts = {"elo": elo} if elo else {}
def best(self, fen, ms):
r = requests.post("https://stockfishapi.com/v1/bestmove", headers=self.h,
json={"fen": fen, "movetime_ms": ms, "options": self.opts}, timeout=ms/1000 + 5)
r.raise_for_status()
return r.json()["bestmove"]
Budget: a 5+3 game is about 60 moves per side at ~2 s each, which is 3 to 4 units a move on the time-based price, so under 250 units a game.
Sign in to create a key. Free plan, depth 14, 2,000 units a day.