Built for agents, not just for people
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.
Agents can discover endpoints and evaluate positions over HTTP. Start a device login, ask your operator to approve once with Google, then collect a scoped key and make REST or MCP requests.
The loop
| Step | Call | What comes back |
|---|---|---|
| Discover | GET /llms.txt, GET /openapi.json | Auth, endpoints, cost annotations in under 800 tokens |
| Try | Static example response | An illustrative response; sign in with Google for 100 free requests, then add a card |
| Log in | POST /v1/auth/device/start | Pairing code for your operator; collect the key after approval |
| Budget | GET /v1/price, X-Quota-Remaining | Units for any request before you send it; what is left after |
| Hit a limit | any call → 402 | next_action, plan options, and a checkout URL for your human |
| Keep going | same key | Limits update within 60 s of payment; nothing to reconfigure |
Agent and CLI login
No browser cookies or Google credentials are needed in the agent. Its operator signs in and approves the exact scopes and budget on the connection screen. New operators can create their verified account there. Anonymous accounts and self-approved keys are not supported.
- Start with
POST /v1/auth/device/start. Keep the returneddevice_codeprivate. Show onlyverification_urianduser_codeto your operator. - The operator enters the code, signs in with Google, checks the requesting agent and account, and explicitly approves or denies access. The request expires after ten minutes.
- Poll
POST /v1/auth/device/tokenwith the private device code at most once every five seconds. After approval, saveaccess_tokensecurely. It is returned once and expires after 30 days. - Send
Authorization: Bearer YOUR_ACCESS_TOKENto engine endpoints or configure the same token in your MCP client. Never put either secret in URLs, logs, prompts, or committed files.
curl -sS https://stockfishapi.com/v1/auth/device/start -H 'Content-Type: application/json' -d '{"client_name":"My chess agent","scopes":["eval"],"budget_units":1000}' Keep the device code in your agent's private memory. A token poll sends this JSON body, without an Authorization header:
POST /v1/auth/device/token
Content-Type: application/json
{"device_code":"REPLACE_WITH_PRIVATE_DEVICE_CODE"} 400 authorization_pending: wait five seconds, then poll again.429 slow_downor a rate-limit problem: honorRetry-After, then wait at least five seconds between subsequent polls.400 access_denied,expired_token, orinvalid_grant: stop. Start a new request only when your operator wants to try again.409 account_key_limit: ask the operator to revoke an unused key in the dashboard. Retry before the ten-minute request expires, or start again.- On
200, store the key securely before continuing. If that response is lost, the token cannot be recovered. Revoke the unused key in the dashboard before starting again.
Device keys allow only eval, analyze, and/or batch. The default is eval with a 1,000-unit budget per calendar month; you may request 1–10,000 units. Budgets reset each UTC calendar month, so this is not a lifetime or dollar cap. Keys cannot manage billing, mint other keys, or raise their own budget. There is no refresh token. The operator can revoke access anytime in the dashboard.
Existing trial, plan, payment and rate limits still apply. Usage can incur your account's existing overage charges; connecting an agent does not create a paid subscription or add a card.
After collecting a token, make a position request:
// Node.js 18+. Supply STOCKFISH_API_KEY through your secret manager.
const response = await fetch("https://stockfishapi.com/v1/eval", {
method: "POST",
headers: { "Authorization": "Bearer " + process.env.STOCKFISH_API_KEY, "Content-Type": "application/json" },
body: JSON.stringify({ fen: "rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNR w KQkq - 0 1", depth: 1 })
});
const result = await response.json();
if (!response.ok) throw new Error(JSON.stringify(result));
console.log(result); Errors tell you what to do
Engine and account errors use RFC 9457 problem+json with a next_action you can branch on:
| next_action | Status | Do this |
|---|---|---|
fix_request | 400 | Read detail; the request will never succeed as sent |
retry_after | 429, 503 | Wait Retry-After seconds, then retry with the same Idempotency-Key |
sign_up | 401, 402, 429 (keyless) | Ask your operator to open the signup.url dashboard link |
upgrade | 402 | Show checkout.url to your operator, or pick a smaller depth |
raise_budget | 402 | PATCH /v1/keys/{id} if you hold the keys scope, otherwise ask |
verify_email | 403 | The owner must sign in with Google |
contact | 403, 501 | Surface the message; a person has to act |
HTTP/1.1 402 Payment Required
Content-Type: application/problem+json
{
"type": "https://stockfishapi.com/errors/quota_exceeded",
"title": "Daily quota exceeded",
"status": 402,
"next_action": "upgrade",
"retry_after": 31250,
"plans": [{ "plan": "hobby", "price_usd_month": 9, "included_units": 100000, "max_depth": 22 }],
"checkout": { "method": "POST", "url": "https://stockfishapi.com/v1/billing/checkout", "body": { "plan": "hobby" } }
}
Scoped keys for sub-tasks
Create a separate key for each integration in the signed-in dashboard. Key creation and rotation require a verified login; an API key alone cannot issue more credentials.
MCP
The MCP endpoint at https://stockfishapi.com/mcp supports Streamable HTTP with evaluate_position, best_move, legal_moves, and validate_position. Configure your API key as a Bearer token. Start with 100 free requests with a verified email, then add a card in the dashboard. Automatic MCP OAuth discovery is not supported. Use the device-login token as a Bearer header in a compatible client.
Retry and backoff
- Honour
Retry-After; it is exact, not a guess. - Send an
Idempotency-Key on POSTs you may retry. - Do not raise depth to "get a better answer" without checking
GET /v1/price; cost grows 1.6× per ply. - Prefer
bestmove when you only need a move; it is half the price of eval.