Working Code

Sort:
HectorCarrasco

 Hello all, I'm developing a mac osx app which works as menu bar app, it's give you some notifications of pending daily games, it's a beta version happy.png feel free to use and improve it https://github.com/hcarrasc/Hgemoves

skelos

Thanks. Interesting. I won't look now (I always have games to move in currently so it would not be useful) but if I get my number of games down some more, it might be.

I suppose it's in Objective C, if it's Mac native?

andreamorandini

@HectorCarrasco cool work, thank you for sharing!

YacinTmimi

Hi Everyone! I recently began a project using chess.com's API to gather data on all my archived games. The code is written in Python, and heres a link to the GitHub page so you can check it out. The project is set up so everyone can gather data on their own games. I did my best to document where the projects at, and where I'd like to take it. The project is still very much in its infancy, and if anyone has suggestions, or would like to help me work on it that would be great!

skelos

Interesting; I wrote code (in perl) to download a player's games. I've not yet put it into any database; that's later.

As it takes no more than few minutes to download games for quite old and active accounts I've not restricted it in any way.

For future flexibility I store the JSON data as-received and break out the PGN data, which I already had scripts to process when I was downloading via the web archive.

Do know that there have been fixes and changes to the archive downloads. The last was sometime mid-late July, if I recall correctly. That doubtless means some of my saved JSON is non-optimal. sad.png

When I have used Python with api.chess.com I have used the non-core "requests" module. I don't know what benefits or limitations it has over "request-html" but it will not work for those still using Python 2.7. (Of whom there are some, although new projects are definitely better off working with Python 3.x if at all possible.)

YacinTmimi

@skelos I also noticed that it could take several minutes to download game data. I have roughly 2200 games, and it takes about 7minutes when running for the first time. I imagine that there are many players on the site that have way more games than that. I'll look to incorporate a database at some point, but for now I'm just storing data in csv files. By storing the data, the speed of the program is greatly increased on future runs.

As for the difference between requests-html and requests, I'm not entirely sure. I believe both libraries were written by the same author. After checking the documentation, requests-html seems to be more geared towards web scrapping. However, both are capable of making GET requests. I may consider switching from requests-html to requests in the future as both are compatible with Python 3.6

Thanks for taking the time to respond.

skelos

$ /usr/bin/time ../../games -v YacinTmimi

...

       12.72 real         0.79 user         0.10 sys

 

Wall-clock time: 12.72 seconds. Less than 1s of CPU time (on an old 2Ghz MacBook Air) and 1/10th of a second of kernel time.

 

That's over a VPN running over Wi-Fi, originating in Australia and (eventually) accessing api.chess.com.

Make sure you've enabled compression and HTTP 1.1 connection caching, I suggest.

 

Checking that I got all the games:

$ grep Link *.pgn | wc -l

    2289

That includes in-progress games.

 

Cheers,

Giles

skelos

Also, the compressed JSON data and uncompressed PGN files don't take up a lot of space, although for enough players it will add up:

 

$ du -sh YacinTmimi/

5.7M YacinTmimi/

 

Under 6MB.

skelos

Players who have several years of games and who often play bllitz and bullet create many more games and of course slower downloads.

A player with 53 months of data (including any incomplete daily games) and a total of  27841 games took longer:

 

$ /usr/bin/time ../../games player

      498.90 real         5.88 user         0.58 sys

 

i.e. ~8.5 minutes elapsed, but still less than 7s CPU time. I'm pretty convinced at the moment that response time from api.chess.com is the limiting factor here. That's 74MB total (compressed JSON plus uncompressed PGN files extracted from the JSON).

If I calculate correctly, that's (less than, because the PGN  files I'm counting twice are within the JSON) 150KB/s. Not exactly fast, but definitely fast enough to use.

skelos

Yup, following up my own post again, bad form: to really know where the bottleneck is (there is always one, whether it matters or not) I'd have to take network traces, and:

  • My network is not well set up for that
  • I haven't taken a network trace since I left my last job, and don't miss them.
skelos

Now writing a per-team game selection script to choose games played by a player for a particular team.

Multiple endpoints: player's list of archives, per-month archives, and the team match endpoint. That I've figured I need so far. happy.png

Magnus335

I played around with the API by making a baseball card for chess.  Not really a UI improvement over the tooltip in live play in my opinion.  I put together a demo that shows a way to show club players on the home screen next to the title players by placing players into categories. Gives some recognition to improving players of lower strength.  As far as I can tell, only titled players get space on the home page right now.  

Great API, very simple to use!

 

 

  

netdsg

The public chess.com API awesome!  Here's a grafana integration:

https://github.com/netdsg/chessfana

Denpotap

Do you know any software which can determine your elo just after one 10 minutes blitz game? I have one. It can be usefull for new players’ calibration or just for interest. I think when new user chooses his skill by himself it could probably spoil next few games for both players (cause skill difference could be very big).  So, my solution: https://github.com/dendiod/elometer

KarlGregorP

I work whith a web page www.sikassaareaiand.ee

 

Sorry this its estonia

PLaba

I've worked on the PyPI project to provide a light wrapper around the API. It's located at https://pypi.org/project/chess.com/ and is maintained by @JimmyChangChang.

GregorFil

https://www.chess.com/clubs/forum/view/working-code#comment-34647094

Wuje

I made a site to see how many titled players you've beaten, https://howmanymasters.com

steezymalteezy

Hey everyone, I built an unofficial Ruby client for the Published Data REST API and published it as a gem: https://rubygems.org/gems/chess-pub-api-client

All endpoints are included in the client, and the data is returned as hashes of the parsed JSON for now.
The client also needs to eventually implement caching and proper PGN handling, as it currently does not support them.

Would love any feedback!

crosszay
Dale00007 wrote:

As you are aware I am working on club manager. Till now I was using screenscraping only for myself. With API I will try to maybe give it to friends and maybe later public. But as I am not professional developer, I am a bit worried to put it fully public ... but I will see once more critical APIs are ready and I have more time to build some viable product. 

You can see beta version at http://cm.tode.cz ... if there is some big interest I can create account to somebody who is interested (but as said - at this moment I will really li