player_id on player endpoint versus uuid on game archive endpoint

Sort:
neilgd72

Hi,

On the player API endpoint (https://api.chess.com/pub/player/{username}) the player_id seems to be a number, but on the game archive API endpoint (https://api.chess.com/pub/player/{username}/games/{YYYY}/{MM}) there is a uuid field, but it is a uid and doesn't correspond to the player_id.

Is there any way of reconciling these, or do I just need to use the username (which presumably can change)?

Thanks!

Neil

Martin_Stahl

There is an @username field that includes the player username

@id
Martin_Stahl

But I believe the ID and UUID are created differently so there's no conversion.

neilgd72

Thanks Martin. But I'm guessing people can change their usernames, so I was hoping to use a field that stayed consistent over time.

stephen_33
neilgd72 wrote:

Thanks Martin. But I'm guessing people can change their usernames, so I was hoping to use a field that stayed consistent over time.

Although there are fixed references for both clubs and members ("club_id" & "player_id"), all API access requires the use of club or member names, either of which can change at any time.

This has been a headache for me and other API users ever since the API was introduced and continues to be so! That's how they designed it so we're stuck with it.

neilgd72

Thanks Stephen! There seems to be 2 different player_ids too, with one a number and one a uuid, used in different places!

stephen_33

Yep, I'm afraid that's the kind of design feature you have to get used to on this site.

This subject caught my eye because by coincidence I'm in the process of adapting the way I organise my data for league activities from club name and player name to club_id and player_id. Then I plan to convert from those two ids to current names by means of look-up tables.

Even then I'm puzzled because if you look at a member's name such as Martin_Stahl, the endpoint is this....

https://api.chess.com/pub/player/martin_stahl

  "player_id": 2168834,
  "@id": "https://api.chess.com/pub/player/martin_stahl",
  "url": "https://www.chess.com/member/Martin_Stahl",
  "name": "Martin Stahl",
  "username": "martin_stahl"

If the member name is "Martin_Stahl", then shouldn't that be the "username"? But the "username" is always given in lower-case. When you open Martin's webpage the URL is...

https://www.chess.com/member/martin_stahl

..again, lower-case so that seems to be consistent, yes? But hold on a moment, the webpage address above, the "url", is given with this spelling of the username: Martin_Stahl. So which is it, cased or lower-case?

Does that make any sense to you because it makes very little sense to me.

neilgd72

That is very odd!

Like you, I’m going to store the player uuid and then match it to the current username by looking at the most recent game they’ve played.

stephen_33

If I want to obtain the name of a member as it's displayed on webpages, you'd think that would involve no more than looking up the "username" but that's always lower-cased, so doesn't quite work.

Instead I have to parse-off the name element of the "url" which gives the name as displayed but what a strange way to have to go about it.

Using a player's uuid is an option I suppose but by itself how do you obtain the new name when it's changed? You plan to cache the uuid with the game id?

A system I use that works well for both clubs and players is to find a team match in which the club or player was involved. In future I plan to cache the club_id with its match-id/team number so when I download the match endpoint I have the new club name.

Much the same with players except I have to cache the player_id with its match_id/team number and board number. That works well.

neilgd72

Yep, I’ll cache a game and then I can pick up the new username, but use the uuid internally.