Free online Chess server. Play Chess now in a clean interface. No registration, no ads, no plugin required. Play Chess with the computer, friends or random opponents.
Play
Create a gameTournamentSimultaneous exhibitions
Learn
Chess basicsPuzzlesPracticeCoordinatesStudyCoaches
Watch
Lichess TVCurrent gamesStreamersBroadcasts (beta)Video library
Community
PlayersTeamsForumQuestions & Answers
Tools
Analysis boardOpening explorerBoard editorImport gameAdvanced search
Sign in
Reconnecting
  1. Forum
  2. General Chess Discussion
  3. For Newbie Javascript Lichess Bot Developers (i.e. just me?)

After some learning curve to get the Lichess API to work, I have distilled a small test program from what I learnt.

It will use my API token and retrieve my username from the Lichess accounts API.

There's no error checking etc as I wanted as small a demo program as reasonably possible.

const baseURL = "lichess.org/"
const APITOKEN = "YourAPItokenHere"

const axios = require('axios')

const headers = {Authorization: `Bearer ${APITOKEN}`}
const lichess = {baseURL, headers};

(async () => {console.log((await axios.get('/api/account', lichess)).data.username)})();