Event Stream
The event stream is the primary way for bots to receive notifications about challenges, games starting, and game endings.
GET /api/stream/event
Stream incoming events in real-time. This is a long-lived HTTP connection that sends newline-delimited JSON (ndjson).Authentication
Requires OAuth token withbot:play, board:play, or challenge:read scope.
Request
Event Types
object
A game has started. Connect to the game stream immediately.
object
A game has finished.
object
Someone challenged you.
object
A challenge was declined.
object
A challenge was canceled.
Game Stream
GET /api/bot/game/stream/
Stream the state of a game being played with the Bot API. Provides real-time updates for moves, draw offers, takeback requests, and opponent presence.Connect to this stream as soon as you receive a
gameStart event.Authentication
Requires OAuth token withbot:play scope.
Parameters
string
required
The game ID to stream
Request
Event Types
object
Full game data. This is always the first message sent. Contains both game metadata and current state.
object
Current state of the game. Sent after each move.
object
A chat message.
object
The opponent left the game.
Make a Move
POST /api/bot/game//move/
Make a move in a game being played with the Bot API.Authentication
Requires OAuth token withbot:play scope.
Parameters
string
required
The game ID
string
required
The move in UCI format (e.g.,
e2e4, e7e5, e1g1 for castling)boolean
Whether to offer a draw with this move
Request
Response
boolean
Whether the move was successful
UCI Move Format
Moves must be in Universal Chess Interface (UCI) format:- Normal moves:
e2e4,g8f6 - Castling:
e1g1(kingside),e1c1(queenside) - Promotion:
e7e8q(promote to queen),a7a8n(promote to knight) - En passant: Use the destination square (e.g.,
e5d6)
Additional Game Actions
Abort Game
POST /api/bot/game//abort Abort a game. Only possible in the first few moves.Resign Game
POST /api/bot/game//resign Resign a game.Write in Chat
POST /api/bot/game//chat Post a message in the game chat.string
required
Chat room:
player (private) or spectator (public)string
required
Message text
Complete Bot Example
Best Practices
Connection Management
- Keep Streams Alive: The event and game streams are long-lived connections
- Handle Disconnections: Implement reconnection logic with exponential backoff
- Process Events Quickly: Don’t block the stream processing thread
- Use Threads: Handle each game in a separate thread
Performance
- Think Time: Respect time controls and don’t take too long to move
- Memory: Clean up finished games to avoid memory leaks
- Rate Limits: Avoid making too many API calls
Fair Play
- Engine Strength: Don’t make your bot play at unrealistic strength
- No Unfair Advantage: Follow Lichess Terms of Service
- Handle Draws: Respond appropriately to draw offers
See Also
- Bot Account - Account setup and management
- Challenges - Handle challenges
- Board API - Alternative API for human players

