lichess.org
Donate

Web sockets and the Lichess API (on Android)

As a learning project, I tried to develop an Android app (in Java) that can play games on Lichess.org using the Lichess API (lichess.org/api). Using OkHttp3, I managed to extract data from from the API (see the commented section in the code below). However, when actually playing games, you have to get Lichess to send you updates when a move has been made, and I got the impression that web sockets were the right technology for this. However, I keep getting the response

> Response{protocol=http/1.1, code=200, message=OK, url=lichess.org/api/board/game/stream/<ID of my game>}

and the exception

> java.net.ProtocolException: Expected HTTP 101 response but was '200 OK'

To use the Board API, you need an access token for Lichess with a specific mandate to use the Board API.

My code can be seen in this topic on Stackoverflow where I also posted this previously, but didn’t get a reply yet:

stackoverflow.com/questions/77819221/web-sockets-and-the-lichess-api-on-android

This topic has been archived and can no longer be replied to.