Answers.Body: <p>Yes, it's possible to obtain the data you want. Chess.com has a REST API which is described in the following news post:</p>
  <p><a href="https://www.chess.com/news/view/published-data-api" rel="nofollow noreferrer">https://www.chess.com/news/view/published-data-api</a></p>
  <p>You can use the following URL to get a list of monthly archives of a players games:</p>
  <pre><code>https://api.chess.com/pub/player/{username}/games/archives
  </code></pre>
  <p>In this list you will find URLs which look like this:</p>
  <pre><code>https://api.chess.com/pub/player/{username}/games/{YYYY}/{MM}
  </code></pre>
  <p>If you append <code>/pgn</code> to this URL, you will get get all the games in PGN format, which is probably simpler to parse.</p>
  <p>Lets look at an example:</p>
  <p><a href="https://api.chess.com/pub/player/magnuscarlsen/games/2018/01/pgn" rel="nofollow noreferrer">https://api.chess.com/pub/player/magnuscarlsen/games/2018/01/pgn</a></p>
  <p>Here you will find games played by Magnus Carlsen in January 2018. This list contains a couple of Chess960 games, which are identified by the following tag:</p>
  <pre><code>[Variant &quot;Chess960&quot;]
  </code></pre>
  <p>The following tags will give you the UTC date and time of the game as well as the players ratings at the time:</p>
  <pre><code>[UTCDate &quot;2018.01.03&quot;]
  [UTCTime &quot;21:50:55&quot;]
  [WhiteElo &quot;2706&quot;]
  [BlackElo &quot;2940&quot;]
  </code></pre>
  <p>Lichess has also an API to download games, which I already described <a href="https://chess.stackexchange.com/questions/32761/downloading-games-from-lichess/32763#32763">here</a>.</p>
  <h2>Code</h2>
  <p>Here's some simple Kotlin code to extract the data (you will need to change the file and user name):</p>
  <pre><code>import java.io.File
  
  fun main() {
      val data = (File(&quot;ChessCom_magnuscarlsen_201801.pgn&quot;).readText().trim().split(&quot;\n\n\n&quot;).map {
          it.split('\n').filter { it.startsWith('[') }.map {
              val t = it.replace(Regex(&quot;[\\[\\]]&quot;), &quot;&quot;).split(' ', limit = 2)
              t[0] to t[1]
          }.toMap()
      })
      data.forEach {
          if (it[&quot;Variant&quot;] == &quot;\&quot;Chess960\&quot;&quot;) {
              println(&quot;${it[&quot;UTCDate&quot;]} ${it[&quot;UTCTime&quot;]} ${it[if (it[&quot;White&quot;] == &quot;\&quot;MagnusCarlsen\&quot;&quot;) &quot;WhiteElo&quot; else &quot;BlackElo&quot;]}&quot;)
          }
      }
  }
  </code></pre>
  <p>Result:</p>
  <pre><code>&quot;2018.01.03&quot; &quot;21:50:55&quot; &quot;2706&quot;
  &quot;2018.01.03&quot; &quot;21:09:41&quot; &quot;2727&quot;
  &quot;2018.01.03&quot; &quot;19:43:22&quot; &quot;2703&quot;
  </code></pre>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2021-05-01T10:04:38.260Z
Answers.LastActivityDate: 2021-05-01T13:44:30.563Z
Answers.LastEditDate: 2021-05-01T13:44:30.563Z
Answers.UserDisplayName: Sleafar
Body: <p>Cross-posted <a href="https://stackoverflow.com/questions/67159513/live-statistics-chess960-from-chess-com">stackoverflow</a>, but nothing.</p>
  <hr />
  <p>Both <a href="https://lichess.org/" rel="nofollow noreferrer">lichess</a> and chess.com have the feature to play the variant <a href="https://en.wikipedia.org/wiki/Fischer_random_chess" rel="nofollow noreferrer">chess960</a> live. However, only lichess has a graph showing how your live chess960 rating has changed over time. Lichess also shows other statistics like highest, lowest, best wins, worst losses, average opponent rating, etc. (chess.com does have this for correspondence chess960 though.)</p>
  <p>I could create my own graph and statistics in Excel/Google Sheets by manually recording each game's date and my rating afterwards indicated beside my username, but...</p>
  <p><strong>Question</strong>: Is there a way to obtain, or what in general is the way to go about obtaining, ratings after each chess960 game using some kind of script that sees a player's public profile and then extracts the data?</p>
  <p>I have a feeling this kind of script has been done before even if this was not specifically done for chess.com's live chess960. The script doesn't have to graph (pretty easy to do once you have to the data: just use excel/google sheets). I just need the script to collect all the dates and rating numbers for each line of the user's games.</p>
  <hr />
  <p>Update 2: Fixed now. see the 'json' vs the 'preformed'. WOW.</p>
  <p>Update 1: It appears Mike Steelson has an answer <a href="https://stackoverflow.com/questions/67345784/how-do-convert-parse-extract-data-from-a-pgn-into-a-spreadsheet-google-sheet-exc">here</a>, where the code is given as</p>
  <pre><code>=arrayformula( regexextract(split( substitute(substitute(substitute(getDataJSON(A1;&quot;/games&quot;;&quot;/pgn&quot;);&quot;[&quot;;&quot;&quot;);&quot;]&quot;;&quot;&quot;);&quot;&quot;&quot;&quot;;&quot;&quot;) ;char(10));&quot;\s.*&quot;) )
  </code></pre>
  <p>with an example given here</p>
  <p><a href="https://docs.google.com/spreadsheets/d/1MX1o5qdy0K3gTMzbimUV3SmFf-0XPCSJ8Vz4IjI-8Ak/copy" rel="nofollow noreferrer">https://docs.google.com/spreadsheets/d/1MX1o5qdy0K3gTMzbimUV3SmFf-0XPCSJ8Vz4IjI-8Ak/copy</a></p>
  <p>It appears there's a problem when it gets to the case of chess960 only. Consider for example <a href="https://www.chess.com/member/dukov5" rel="nofollow noreferrer">this player</a>: Replacing 'gmwso' with the player's username will yield a weird output. i imagine the output will be messier for mixed chess960 and chess.</p>
  
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2022-11-20T05:52:38.910Z
Comments.Text: Cross-posted: https://superuser.com/q/1645900/93541, https://boardgames.stackexchange.com/q/54692/8191, https://chess.stackexchange.com/q/34842/12996, https://stackoverflow.com/q/67159513/781723.  Please [do not post the same question on multiple sites](https://meta.stackexchange.com/q/64068).
Comments.UserDisplayName: D.W.
Tags: <chess-variants><programming><database><statistics><chess960>
Title: Live statistics chess960 from chess.com?
ThreadText: # Live statistics chess960 from chess.com?
  
  (Asked by: username_0 on 2021-04-19)
  
  Cross-posted stackoverflow, but nothing.
  
  Both lichess and chess.com have the feature to play the variant chess960 live. However, only lichess has a graph showing how your live chess960 rating has changed over time. Lichess also shows other statistics like highest, lowest, best wins, worst losses, average opponent rating, etc. (chess.com does have this for correspondence chess960 though.)
  I could create my own graph and statistics in Excel/Google Sheets by manually recording each game's date and my rating afterwards indicated beside my username, but...
  Question: Is there a way to obtain, or what in general is the way to go about obtaining, ratings after each chess960 game using some kind of script that sees a player's public profile and then extracts the data?
  I have a feeling this kind of script has been done before even if this was not specifically done for chess.com's live chess960. The script doesn't have to graph (pretty easy to do once you have to the data: just use excel/google sheets). I just need the script to collect all the dates and rating numbers for each line of the user's games.
  
  Update 2: Fixed now. see the 'json' vs the 'preformed'. WOW.
  Update 1: It appears Mike Steelson has an answer here, where the code is given as
  =arrayformula( regexextract(split( substitute(substitute(substitute(getDataJSON(A1;"/games";"/pgn");"[";"");"]";"");"""";"") ;char(10));"\s.*") )
  
  with an example given here
  https://docs.google.com/spreadsheets/d/1MX1o5qdy0K3gTMzbimUV3SmFf-0XPCSJ8Vz4IjI-8Ak/copy
  It appears there's a problem when it gets to the case of chess960 only. Consider for example this player: Replacing 'gmwso' with the player's username will yield a weird output. i imagine the output will be messier for mixed chess960 and chess.
  
  **Tags:** chess-variants, programming, database, statistics, chess960
  
  > **Comments:**
  > **username_1**: Cross-posted: https://superuser.com/q/1645900/93541, https://boardgames.stackexchange.com/q/54692/8191, https://chess.stackexchange.com/q/34842/12996, https://stackoverflow.com/q/67159513/781723.  Please [do not post the same question on multiple sites](https://meta.stackexchange.com/q/64068).  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_2 on 2021-05-01. Score: 3 | Accepted answer
  
  Yes, it's possible to obtain the data you want. Chess.com has a REST API which is described in the following news post:
  https://www.chess.com/news/view/published-data-api
  You can use the following URL to get a list of monthly archives of a players games:
  https://api.chess.com/pub/player/{username}/games/archives
  
  In this list you will find URLs which look like this:
  https://api.chess.com/pub/player/{username}/games/{YYYY}/{MM}
  
  If you append /pgn to this URL, you will get get all the games in PGN format, which is probably simpler to parse.
  Lets look at an example:
  https://api.chess.com/pub/player/magnuscarlsen/games/2018/01/pgn
  Here you will find games played by Magnus Carlsen in January 2018. This list contains a couple of Chess960 games, which are identified by the following tag:
  [Variant "Chess960"]
  
  The following tags will give you the UTC date and time of the game as well as the players ratings at the time:
  [UTCDate "2018.01.03"]
  [UTCTime "21:50:55"]
  [WhiteElo "2706"]
  [BlackElo "2940"]
  
  Lichess has also an API to download games, which I already described here.
  Code
  Here's some simple Kotlin code to extract the data (you will need to change the file and user name):
  import java.io.File
  
  fun main() {
      val data = (File("ChessCom_magnuscarlsen_201801.pgn").readText().trim().split("\n\n\n").map {
          it.split('\n').filter { it.startsWith('[') }.map {
              val t = it.replace(Regex("[\\[\\]]"), "").split(' ', limit = 2)
              t[0] to t[1]
          }.toMap()
      })
      data.forEach {
          if (it["Variant"] == "\"Chess960\"") {
              println("${it["UTCDate"]} ${it["UTCTime"]} ${it[if (it["White"] == "\"MagnusCarlsen\"") "WhiteElo" else "BlackElo"]}")
          }
      }
  }
  
  Result:
  "2018.01.03" "21:50:55" "2706"
  "2018.01.03" "21:09:41" "2727"
  "2018.01.03" "19:43:22" "2703"
  
  
  ---
  
  