How to use Lichess API in 2 Minutes
Lichess is a popular alternative to Chess.com. Many like to joke if your ELO is 1000 on Chess.com, it’s probably 1500 on Lichess. I’m not here to make such judgements, however.
My goal is to explain how to quickly use Lichess API to get basic account information, including a user’s ELO. Later posts may go into automating game play.
First things first, as with all APIs, we need to get a key. Go to preferences, API Access Tokens, and create a key.
Next, we are going to use this sample app provided by the Lichess developer team. All you have to do is clone this repository (git clone repo) and open in your preferred IDE. I personally really like using Visual Studio Code.
Once the project is cloned, all you have to do is the following:
- Copy your personal token into the .env.default, create a .env file and copy and past the .env.default into your .env file.
- Open terminal, go to the repository directory, and run:
And voila! You should receive your own Lichess account information. Here’s mine, and yes my username is HikarusBaby and my ELO is 1308 in blitz.