embed id of the game?

Sort:
ElectricFalcon

Is there an API endpoint for the embed id of the match? I see this differs from the id used at the end of the game url?

Or alternatively is there a link to the id at the end of the game url and the embed id? 

stephen_33

I can't make sense of what you mean?

ElectricFalcon

In the API endpoint for the game url it follows the format:

https://www.chess.com/daily/game/29076797

For the embed html for the same game, the 'gid'is

<iframe id="6622788" allowtransparency="true" frameborder="0" style="width:100%;border:none;" src="//www.chess.com/emboard?id=6622788"></iframe>

or referenced as "[g_id=6622788]" for forum posts (minus the underscore to avoid it calling the board).

Is there a way to return this gid number in the api so I can embed the iframe board in an api call?


stephen_33

That's slightly clearer but I still don't know what you mean by 'so I can embed the iframe board in an api call'?

The 'gid' you quote is an HTML ('frame' tag) element so doesn't have a number as such. And it doesn't make any sense (to me) to talk of embedding HTML into an HTTP endpoint request.

What precisely are you trying to achieve?

ElectricFalcon

I have a list of chess users that I want to pull games and stats for using the API. Then I want to display the game on a website.

Rather than pull the pgn from the games archives for each, and put together the chessboard myself in html and call the pgn into it using chessboard.js, I figured it'd be way easier to call the iframe embed html from chess.com and input the game id into it. 

In the API you can return the game URL and i figured I;d just trim the number from the end of the game url and put it in the iframe gid, but these numbers are not the same. Hence me looking for a way to return the embed iframe GID from the API? Hopefully this makes more sense happy.png

stephen_33

This is outside of my scope because I've never tried using chessboard.js or the associated chess.js

But having read the description on GitHub, it's clear that chessboard.js itself displays only chess positions, not games as such.

I have a gut feeling that you'll need to download each game PGN if you want to display users games on another site?

ElectricFalcon

Parking chessboard.js for the moment it's more that I want to be able to pull the embed html or more specifically the [gid =""] from the chess.com website and use that rather than going through chessboard.js as it's just neater and easier?  The chess.com API currently returns a game url, it would just be great if it returned a game ID . 

stephen_33

I'm assuming this ....

For the embed html for the same game, the 'gid'is

<iframe id="6622788" allowtransparency="true" frameborder="0" style="width:100%;border:none;" src="//www.chess.com/emboard?id=6622788"></iframe>

.
.... is what you feed into chessboard.js? At least I can't find any iframe tags in pages for single games, live or daily ones.

stephen_33
ElectricFalcon wrote:

Parking chessboard.js for the moment it's more that I want to be able to pull the embed html or more specifically the [gid =""] from the chess.com website and use that rather than going through chessboard.js as it's just neater and easier?  The chess.com API currently returns a game url, it would just be great if it returned a game ID . 

But this is baffling me. I can't find any such HTML in the pages of any games I've looked at.

Take this example: https://www.chess.com/daily/game/258147384

There's no 'gid' anywhere on the source page. The game id of 258147384 is given seven times.

The game id uniquely identifies the game on this site but it's of limited use on other sites, I'd have thought.

But you do realise that you can't access individual games via the chess.com api because they don't have their own endpoints?

ElectricFalcon

Go to the share icon in the bottom right. Click it and it'll open a popup with the pgn, image, animated gif, and embed. 

Also you can access each game information by downloading the monthly archive for a player and iterating through the JSON. 

stephen_33

The fog clears! I've never used that feature which explains why I couldn't understand what you meant by the 'embed id'.

No, the gid is not available in any endpoint. I think you'll need to work out a different method for creating diagrams en-masse?