API My games

Sort:
NordInferno

Hi, I was trying Chess.com API, I just want to fetch some data,
I managed to get my rating from it,
I want to get "my today's matches", like total matches played today, number of wins, lose, draws...

I don't want PGNs and all that, I just want number of matches (rated)..

 

 

UPDATE::

I GOT IT BY DOING THIS.. (I'LL CHANGE SOME STATIC DATES AND MONTHS LATER ON..)

BUT THIS IS THE RESULT..

 

games = get_player_games_by_month(name,"2021","06").json['games'] (gets games of the month)

games = [d for d in games if d['end_time'] >= datetime.strptime("June 7, 2021", "%B %d, %Y").timestamp() and d['rated'] == True and d['time_class'] == "rapid"] (Filters out "rapid", and "Rated" games from given date to current date)
games = [{"str": d["pgn"]} for d in games] (filters out only pgns to find out results)

 

for eg. in loop (for game in games)

something like this "game['str'].count('Result "1/2-1/2"')" would return true if game is drawn...

 

Thank you @stephen_33, @Hyper-Dragon for helping..

if anyone interested in complete code, ping me..

Alexander30

well this is something that you will have to code imho. 

NordInferno
Alexander30 wrote:

well this is something that you will have to code imho. 

I know, I am asking, how to get matches by day... It has options for all matches, and matches in a month...

like, we can get rating using "https://api.chess.com/pub/player/<player_name>/stats"

stephen_33
NordInferno wrote:

I want to get "my today's matches", like total matches played today, number of wins, lose, draws...

Well you could do this manually and it's all available in the one endpoint but it would involve looking through a lot of games' data. If you start here...

https://api.chess.com/pub/player/nordinferno/games/archives

That gives these sets/monthly archives of your games...

https://api.chess.com/pub/player/nordinferno/games/2020/10

https://api.chess.com/pub/player/nordinferno/games/2021/01
https://api.chess.com/pub/player/nordinferno/games/2021/02

etc..

https://api.chess.com/pub/player/nordinferno/games/2021/06

Since you want only the games you've finished today, the current month is the one of most interest (i.e. /2021/06). When I open that archive of your games in my browser and search for "rated", I see 12 results but those are for the entire month of June of course.

If you want to search for just those games with an end date/time of today, enter this as the search string: EndDate \"2021.06.09\"]\n[EndTime
That gives no results but that might only mean you haven't finished any games today? I think it might also mean that the endpoint hasn't been updated yet - some endpoints are brought up to date only every 24 hours! That means we're often looking at data that's a little old.

So you could do that manually but I'm guessing you'll get very bored very quickly.

How are your coding skills?

stephen_33
NordInferno wrote:

... I am asking, how to get matches by day... It has options for all matches, and matches in a month...

Not available - the smallest set of games is that for a specified month. That's why the endpoint contains all the data on each game, the site's parameters as well as the pgn.

Using the site's API means that we have to do a lot of the unpacking. I'm mostly interested in the match archives of clubs that take part in leagues I help to run. Most of the time I need only the archive of open matches, or at most open and in-progress matches but I still have to download vast archives (in some cases) of all open, current and finished matches because the data is packaged that way.

NordInferno
stephen_33 wrote:
NordInferno wrote:

I want to get "my today's matches", like total matches played today, number of wins, lose, draws...

Well you could do this manually and it's all available in the one endpoint but it would involve looking through a lot of games' data. If you start here...

https://api.chess.com/pub/player/nordinferno/games/archives

That gives these sets/monthly archives of your games...

https://api.chess.com/pub/player/nordinferno/games/2020/10

https://api.chess.com/pub/player/nordinferno/games/2021/01 https://api.chess.com/pub/player/nordinferno/games/2021/02

etc..

https://api.chess.com/pub/player/nordinferno/games/2021/06

Since you want only the games you've finished today, the current month is the one of most interest (i.e. /2021/06). When I open that archive of your games in my browser and search for "rated", I see 12 results but those are for the entire month of June of course.

If you want to search for just those games with an end date/time of today, enter this as the search string: EndDate \"2021.06.09\"]\n[EndTime
That gives no results but that might only mean you haven't finished any games today? I think it might also mean that the endpoint hasn't been updated yet - some endpoints are brought up to date only every 24 hours! That means we're often looking at data that's a little old.

So you could do that manually but I'm guessing you'll get very bored very quickly.

How are your coding skills?

I actually want to track my chess progress, Currently I  manually maintain a excel sheet, with today's start rating, day end rating, number of matches played, no of wins/loss/draws..

 

I also found that we can fetch all games of a particular month, and I was able to get matches played in day, like you mentioned, but, further ahead, how to find results(from my pov, i.e. I wom/lose, not playerX won, or playerY won)..

as of my coding skills, they are quite good, I am an IT Student...

stephen_33

"as of my coding skills, they are quite good, I am an IT Student..."

It helps to know a person's abilities and as a Python user I'd request the month's endpoint and then iterate over all the games in the set, filtering for the parameters I'm interested in.

There's no other way because the site provides no means of filtering results, we have to do that ourselves.

* But about my point on the frequency with which the site updates endpoints, you may not see some of the games that you've finished very recently - something to bear in mind.

Hyper-Dragon

stephen_33 The monthly games endpoint seems to update as soon as a match finishes.  I usually recalculate new stats after my last game and the data always seems to be there. 

@NordInferno To track progress you probably want to split out non-rated games and calculate each rating by time control.  Also,  instead of just start/end rating, what about peak rating for the day?  That's something missing from the ChessDotCom site graphs.

stephen_33
Hyper-Dragon wrote:

stephen_33 The monthly games endpoint seems to update as soon as a match finishes.  I usually recalculate new stats after my last game and the data always seems to be there.

That's good to hear but it's an endpoint I don't normally use and the site is often coy about guaranteeing its endpoint refresh rates. That's to say, just because updates are rapid today it doesn't mean they'll still be next week?

Hyper-Dragon
stephen_33 wrote:
Hyper-Dragon wrote:

stephen_33 The monthly games endpoint seems to update as soon as a match finishes.  I usually recalculate new stats after my last game and the data always seems to be there.

That's good to hear but it's an endpoint I don't normally use and the site is often coy about guaranteeing its endpoint refresh rates. That's to say, just because updates are rapid today it doesn't mean they'll still be next week?

 

True enough.  All I can say, anecdotally, is that it has always been up to date for over 18 months.  

NordInferno
Hyper-Dragon wrote:

stephen_33 The monthly games endpoint seems to update as soon as a match finishes.  I usually recalculate new stats after my last game and the data always seems to be there. 

@NordInferno To track progress you probably want to split out non-rated games and calculate each rating by time control.  Also,  instead of just start/end rating, what about peak rating for the day?  That's something missing from the ChessDotCom site graphs.

Yes, I agree about daily peak rating... they should add that..

alphatttt

Hi I want to get Live match data from my profile. Are we able to get that data (moves) of the game I am playing through this API?

stephen_33
alphatttt wrote:

Hi I want to get Live match data from my profile. Are we able to get that data (moves) of the game I am playing through this API?

Yes but only for finished games, not current ones.