Welcome to the Lichess API
Free/libre, open-source chess server API
Introduction
Welcome to the reference for the Lichess API! Lichess is free/libre, open-source chess server powered by volunteers and donations.
- Get help in the Lichess Discord channel
- API demo app with OAuth2 login and gameplay: source / demo
- API UI app with OAuth2 login and endpoint forms: source / website
- Contribute to this documentation on Github
- Check out Lichess widgets to embed in your website
- Download all Lichess rated games
- Download all Lichess puzzles with themes, ratings and votes
- Download all evaluated positions
Endpoint
All requests go to https://lichess.org (unless otherwise specified).
Clients
- Python general API
- MicroPython general API
- Python general API - async
- Python Lichess Bot
- Python Board API for Certabo
- Java general API
- JavaScript & TypeScript general API
- LichessNET - C# API Wrapper
Rate limiting
All requests are rate limited using various strategies, to ensure the API remains responsive for everyone. Only make one request at a time. If you receive an HTTP response with a 429 status, please wait a full minute before resuming API usage.
Streaming with ND-JSON
Some API endpoints stream their responses as Newline Delimited JSON a.k.a. nd-json, with one JSON object per line.
Here’s a JavaScript utility function to help reading NDJSON streamed responses.
Authentication
Which authentication method is right for me?
Read about the Lichess API authentication methods and code examples
Personal Access Token
Personal API access tokens allow you to quickly interact with Lichess API without going through an OAuth flow.
- Generate a personal access token
curl https://lichess.org/api/account -H "Authorization: Bearer {token}"- NodeJS example
Token Security
- Keep your tokens secret. Do not share them in public repositories or public forums.
- Your tokens can be used to make your account perform arbitrary actions (within the limits of the tokens’ scope). You remain responsible for all activities on your account.
- Do not hardcode tokens in your application’s code. Use environment variables or a secure storage and ensure they are not shipped/exposed to users. Be especially careful that they are not included in frontend bundles or apps that are shipped to users.
- If you suspect a token has been compromised, revoke it immediately.
To see your active tokens or revoke them, see your Personal API access tokens.
Authorization Code Flow with PKCE
The authorization code flow with PKCE allows your users to login with Lichess. Lichess supports unregistered and public clients (no client authentication, choose any unique client id). The only accepted code challenge method is S256. Access tokens are long-lived (expect one year), unless they are revoked. Refresh tokens are not supported.
See the documentation for the OAuth endpoints or the PKCE RFC for a precise protocol description.
- Demo app
- Minimal client-side example
- Flask/Python example
- Java example
- NodeJS Passport strategy to login with Lichess OAuth2
Real life examples
Token format
Access tokens and authorization codes match ^[A-Za-z0-9_]+$. The length of tokens can be increased without notice. Make sure your application can handle at least 512 characters. By convention tokens have a recognizable prefix, but do not rely on this.