hello! here's a little about me:
inspired by natemoo-re
luckily being good at chess wasn't a pre-req to the job
Chess.com public data API wrapper with "isChanged" and priority queue functionality.
Home Page: https://www.npmjs.com/package/chess-web-api
License: MIT License
hello! here's a little about me:
inspired by natemoo-re
luckily being good at chess wasn't a pre-req to the job
Just call chessAPI.getGameByID(gameId).then((res) => console.log(res));
Get data
Error: TypeError: Chess is not a constructor
https://prnt.sc/112ie25
Hitting this exception in 1.0.9 version. 1.0.6 was working fine.
Uncaught (in promise) TypeError: request.callbackParameters is not iterable (cannot read property undefined)
at ChessWebAPI.startRequests (queue-methods.js:75)
Hi! π
Firstly, thanks for your work on this project I love it! π
Unfortunately I had to patch the module for the dispatch()
function, more concretely having callback function params would not work.
To replicate: Running the code in the example of dispatch doesn't work and gives off an unhandled promise rejection error. Which is tied to the way sortParameters
is called.
Here is the diff that solved my problem:
diff --git a/node_modules/chess-web-api/src/queue/index.js b/node_modules/chess-web-api/src/queue/index.js
index aaf838e..9217bb4 100644
--- a/node_modules/chess-web-api/src/queue/index.js
+++ b/node_modules/chess-web-api/src/queue/index.js
@@ -27,7 +27,7 @@ function dispatch(method, callback, parameters, options, callbackParameters, pri
}
const [_parameters, _options, _callbackParameters, _priority] = sortParameters(
- ['array', 'object', 'function', 'number'],
+ ['array', 'object', 'array', 'number'],
[parameters, options, callbackParameters, priority],
);
This issue body was partially generated by patch-package.
Do you mind having tyepscript support? I could submit a PR with the types definitions.
^1.1.2
This package must be used with require
instead of import
I'd like to be able to use this with import
since Vite is ESM only
latest
Call getGameByID and get the result
The getGameByID returns a live game
The getGameByID
should have returned a daily game instead.
Since the IDs for live-chess and daily-chess can overlap, I suggest dividing this method in getLiveGameByID
and getDailyGameByID
.
This is your code, I believe you can change /callback/live/game/${id}
to /callback/daily/game/${id}
to get the desired output.
// line 178, endpoint/games.js
const apiRequest = WebApiRequest.builder()
.withHost(UNDOCUMENTED_API_HOST)
.withPath(`/callback/live/game/${id}`)
.withQueryParameters(_options)
.withHeaders(_headers)
.build();
Spelling should have been "initialize" or "initialized".
Now it is "inicialized" and "inicialize".
This is really a small change , Posted in contribution to make the documentation error-free and awsomeπ―
I saw That this is how you get the games of a round from a tournament-
https://api.chess.com/pub/tournament/early-titled-tuesday-blitz-july-11-2023-4158385/11/1When I checked it on a couple of titled tuesdays games It founds just the last round (11) and not the rounds before.
Also in the tournament describer it shows that this is only round that exists-
url- https://api.chess.com/pub/tournament/early-titled-tuesday-blitz-july-11-2023-4158385
result- "rounds":["https://api.chess.com/pub/tournament/early-titled-tuesday-blitz-july-11-2023-4158385/11"]
I would be happy to get some help, thanks a lot.
Requirements:
https://www.chess.com/callback/live/game/6508402266
to fetch the initial details{
"white": "string", // URL of the white player's profile
"black": "string", // URL of the black player's profile
"url": "string", // URL of this game
"fen": "string", // current FEN
"pgn": "string", // current PGN
"turn": "black", // player to move
"move_by": 1501765498, // timestamp of when the next move must be made
// this is "0" if the player-to-move is on vacation
"draw_offer": "black", // (optional) player who has made a draw offer
"last_activity": 1509810789, // timestamp of the last activity on the game
"start_time": 1254438881, // timestamp of the game start (Daily Chess only)
"time_control": "string", // PGN-compliant time control
"time_class": "string", // time-per-move grouping, used for ratings
"rules": "string", // game variant information (e.g., "chess960")
"tournament": "string", //URL pointing to tournament (if available),
"match": "string" //URL pointing to team match (if available)
}
Howdy maintainers. Great library you've created here!
I'm wondering how I can add a getGameByID()
. For example take https://www.chess.com/live/game/6508402266
, get the id 6508402266
, and fetch the pgn.
After searching through the chess.com API docs, it doesn't seem there is an easy way to do this without parsing through the user's history, which is not ideal. Wondering if you have any tips on how to achieve this
I can help make a PR to implement if necessary.
The closest I've gotten is using the (undocumented) api https://www.chess.com/callback/live/game/6508402266
, but this doesn't return the pgn, and instead some encrypted string moveList: "mC0Kgv5QfHQBvBKBHt7MegZRdv6Evw90nDMNtAYQiq!TltXHAiRJCKEmfeTZbl0Fw2Fe2?Z9?..."
Thank you!
Chess.com announced an API break. How do I set my user-agent?
https://www.chess.com/news/view/breaking-change-user-agent-contact-info-required
latest
const api = new ChessWebAPI();
console.log(api.getPlayer('toadofsky'));
Get results
WebapiError: Forbidden
A declarative, efficient, and flexible JavaScript library for building user interfaces.
π Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. πππ
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google β€οΈ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.