forked from lichess-org/api
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
219 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
node_modules |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
# Lichess Nodejs Axios Http Client Example | ||
|
||
This directory contains code snippets to make API calls in popular nodejs http client axios, | ||
to run the example follow the steps below. Please note this examples only contain non-OAuth endpoints, | ||
for OAuth endpoints view ```oauth-app``` | ||
|
||
``` | ||
npm install | ||
node server.js | ||
``` |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
{ | ||
"dependencies": { | ||
"axios": "^1.6.8" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
const axios = require('axios'); | ||
|
||
|
||
//This file contains Lichess API Axios examples, only non OAuth api endpoints are covered | ||
|
||
|
||
// USER: Real time user status: <https://lichess.org/api#tag/Users/operation/apiUsersStatus> | ||
|
||
// Define the query parameters | ||
const queryParams = { | ||
ids: 'aliquantus,chess-network,lovlas', // Example IDs | ||
withGameIds: true // Include game IDs | ||
}; | ||
|
||
// Make the Axios call | ||
axios.get('https://lichess.org/api/users/status', { params: queryParams }) | ||
.then(response => { | ||
console.log(response.data); | ||
// Handle the response data here | ||
}) | ||
.catch(error => { | ||
console.error('Error:', error); | ||
// Handle errors here | ||
}); | ||
|
||
|
||
// USER: Get top10 Leaderboard <https://lichess.org/api#tag/Users/operation/player> | ||
|
||
axios.get('https://lichess.org/api/player') | ||
.then(response => { | ||
console.log(response.data) | ||
}) | ||
.catch(error => { | ||
console.error('Error:', error); | ||
// Handle errors here | ||
}); |