chesscom 0.1.3

Chess.com API client
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
openapi: '3.0.2'
info:
  title: Chess
  version: '1.0'
servers:
  - url: https://api.chess.com/
paths:
  /pub/player/{username}:
    get:
      summary: Get additional details about a player in a game.
      description: Get additional details about a player in a game.
      operationId: getPlayerProfile
      parameters:
      - name: username
        in: path
        required: true
        schema:
          type: string
          example: rgnever
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Profile'
        '404':
          $ref: '#/components/responses/NotFound'
        '429':
          $ref: '#/components/responses/TooManyRequests'

  /pub/titled/{title}:
    get:
      summary: List of titled-player usernames.
      description: List of titled-player usernames.
      operationId: getTitledPlayers
      parameters:
      - name: title
        in: path
        required: true
        schema:
          $ref: '#/components/schemas/Title'
          example: GM
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                type: array
                description: array of usernames for players with this title
                items:
                  type: string
        '404':
          $ref: '#/components/responses/NotFound'
        '429':
          $ref: '#/components/responses/TooManyRequests'

  /pub/player/{username}/stats:
    get:
      summary: Get player stats.
      description: Get ratings, win/loss, and other stats about a player's game play, tactics, lessons and Puzzle Rush score.
      operationId: getPlayerStats
      parameters:
      - name: username
        in: path
        required: true
        schema:
          type: string
          example: rgnever
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/PlayerStats'
        '404':
          $ref: '#/components/responses/NotFound'
        '429':
          $ref: '#/components/responses/TooManyRequests'

  /pub/player/{username}/is-online:
    get:
      summary: Get player online status.
      description: Tells if a user has been online in the last five minutes.
      operationId: getPlayerOnlineStatus
      parameters:
      - name: username
        in: path
        required: true
        schema:
          type: string
          example: rgnever
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                type: object
                properties:
                  online:
                    type: boolean
                required:
                  - online
        '404':
          $ref: '#/components/responses/NotFound'
        '429':
          $ref: '#/components/responses/TooManyRequests'

  /pub/player/{username}/games:
    get:
      summary: Current Daily Chess
      description: Get list of Daily Chess games that a player is currently playing
      operationId: getDailyChessGames
      parameters:
      - name: username
        in: path
        required: true
        schema:
          type: string
          example: rgnever
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                type: object
                properties:
                  games:
                    type: array
                    description: Array of Daily Chess games that a player is currently playing
                    items:
                      $ref: '#/components/schemas/DailyGame'
                required:
                  - games
        '404':
          $ref: '#/components/responses/NotFound'
        '429':
          $ref: '#/components/responses/TooManyRequests'

  /pub/player/{username}/games/to-move:
    get:
      summary: To-Move Daily Chess
      description: Get list of Daily Chess games where it is the player's turn to move
      operationId: getDailyChessGamesToMove
      parameters:
      - name: username
        in: path
        required: true
        schema:
          type: string
          example: rgnever
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                type: object
                properties:
                  games:
                    type: array
                    description: Array of Daily Chess games where it is the player's turn to move
                    items:
                      $ref: '#/components/schemas/ToMoveGame'
                required:
                  - games
        '404':
          $ref: '#/components/responses/NotFound'
        '429':
          $ref: '#/components/responses/TooManyRequests'

  /pub/player/{username}/games/archives:
    get:
      summary: List of Monthly Archives
      description: Get list of monthly archives available for this player
      operationId: getChessGamesArchives
      parameters:
      - name: username
        in: path
        required: true
        schema:
          type: string
          example: rgnever
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                type: object
                properties:
                  archives:
                    type: array
                    description: List of URLs for monthly archives in ascending chronological order
                    items:
                      type: string
                      format: uri
                required:
                  - archives
        '404':
          $ref: '#/components/responses/NotFound'
        '429':
          $ref: '#/components/responses/TooManyRequests'

  /pub/player/{username}/games/{year}/{month}:
    get:
      summary: Complete Monthly Archives
      description: Get list of Live and Daily Chess games that a player has finished
      operationId: getChessGamesForMonth
      parameters:
      - name: username
        in: path
        required: true
        schema:
          type: string
          example: rgnever
      - name: year
        in: path
        description: Four digit year of the game-end
        required: true
        schema:
          type: string
          example: 2021
      - name: month
        in: path
        description: Two-digit month of the game-end
        required: true
        schema:
          type: string
          example: 03
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                type: object
                properties:
                  games:
                    type: array
                    description: List of Live and Daily Chess games that a player has finished
                    items:
                      $ref: '#/components/schemas/CompletedGame'
                required:
                  - games
        '404':
          $ref: '#/components/responses/NotFound'
        '429':
          $ref: '#/components/responses/TooManyRequests'

  /pub/player/{username}/games/{year}/{month}/pgn:
    get:
      summary: Multi-Game PGN Download
      description: Get standard multi-game format PGN containing all games for a month
      operationId: getChessGamesForMonthPGN
      parameters:
      - name: username
        in: path
        required: true
        schema:
          type: string
          example: rgnever
      - name: year
        in: path
        description: Four digit year of the game-end
        required: true
        schema:
          type: string
          example: 2021
      - name: month
        in: path
        description: Two-digit month of the game-end
        required: true
        schema:
          type: string
          example: 03
      responses:
        '200':
          description: OK
          content:
            application/x-chess-pgn:
              schema:
                type: string
                format: pgn
                description: This response follows the PGN standard, and is not JSON-encoded.
          headers:
            Content-Disposition:
              schema:
                type: string
                description: Indicates client should download, not display, the result
                example: attachment; filename="ChessCom_username_{{year}}{{month}}.pgn"
        '404':
          $ref: '#/components/responses/NotFound'
        '429':
          $ref: '#/components/responses/TooManyRequests'


# Descriptions of common components
components:
  responses:
    NotFound:
      description: The specified resource was not found
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
    TooManyRequests:
      description: Request exceeded rate limit
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
  schemas:
    Player:
      type: string
      enum: [white, black]
    Title:
      type: string
      enum: [GM, WGM, IM, WIM, FM, WFM, NM, WNM, CM, WCM]
    Profile:
      type: object
      properties:
        "@id":
          type: string
          format: uri
        url:
          type: string
          format: uri
        username:
          type: string
        player_id:
          type: integer
        title:
          $ref: '#/components/schemas/Title'
        status:
          type: string
          enum:
            - closed
            - closed:fair_play_violations
            - basic
            - premium
            - mod
            - staff
        name:
          type: string
        avatar:
          type: string
          format: uri
        location:
          type: string
        country:
          type: string
          format: uri
        joined:
          type: integer
          format: timestamp
        last_online:
          type: integer
          format: timestamp
        followers:
          type: integer
        is_streamer:
          type: boolean
        twitch_url:
          type: string
          format: uri
        fide:
          type: integer
      required:
        - "@id"
        - url
        - username
        - player_id
        - status
        - country
        - joined
        - last_online
        - followers
        - is_streamer
    PlayerStats:
      type: object
      properties:
        chess_daily:
          $ref: '#/components/schemas/ChessStats'
        chess_rapid:
          $ref: '#/components/schemas/ChessStats'
        chess_blitz:
          $ref: '#/components/schemas/ChessStats'
        chess_bullet:
          $ref: '#/components/schemas/ChessStats'
        chess960_daily:
          $ref: '#/components/schemas/ChessStats'
        chess960_rapid:
          $ref: '#/components/schemas/ChessStats'
        chess960_blitz:
          $ref: '#/components/schemas/ChessStats'
        chess960_bullet:
          $ref: '#/components/schemas/ChessStats'
        tactics:
          $ref: '#/components/schemas/TacticsStats'
        lessons:
          $ref: '#/components/schemas/LessonsStats'
        puzzle_rush:
          $ref: '#/components/schemas/PuzzleRushStats'
    ChessStats:
      type: object
      properties:
        last:
          type: object
          properties:
            rating:
              type: integer
              minimum: 0
              description: Most-recent rating
            date:
              type: integer
              format: timestamp
              description: Timestamp of the last rated game finished
            rd:
              type: integer
              minimum: 0
              description: Glicko "RD" value used to calculate ratings changes
          required:
            - rating
            - date
            - rd
        best:
          type: object
          description: Best rating achieved by a win
          properties:
            rating:
              type: integer
              minimum: 0
              description: Highest rating achieved
            date:
              type: integer
              format: timestamp
              description: Timestamp of the best-win game
            game:
              type: string
              format: uri
              description: URL of the best-win game
          required:
            - rating
            - date
            - game
        record:
          type: object
          description: Summary of all games played
          properties:
            win:
              type: integer
              minimum: 0
              description: Number of games won
            loss:
              type: integer
              minimum: 0
              description: Number of games lost
            draw:
              type: integer
              minimum: 0
              description: Number of games drawn
            time_per_move:
              type: integer
              minimum: 0
              description: Number of seconds per average move
            timeout_percent:
              type: number
              format: float
              minimum: 0
              description: Timeout percentage in the last 90 days
          required:
            - win
            - loss
            - draw
        tournament:
          type: object
          description: Summary of tournaments participated in
          properties:
            count:
              type: integer
              minimum: 0
              description: Number of tournaments joined
            withdraw:
              type: integer
              minimum: 0
              description: Number of tournaments withdrawn from
            points:
              type: integer
              minimum: 0
              description: Total number of points earned in tournaments
            highest_finish:
              type: integer
              minimum: 0
              description: Best tournament place
          required:
            - count
            - withdraw
            - points
            - highest_finish
      required:
        - last
        - record
    Rating:
      type: object
      properties:
        rating:
          type: integer
        date:
          type: integer
          format: timestamp
      required:
        - rating
        - date
    TacticsStats:
      type: object
      properties:
        higest:
          $ref: '#/components/schemas/Rating'
        lowest:
          $ref: '#/components/schemas/Rating'
    LessonsStats:
      type: object
      properties:
        higest:
          $ref: '#/components/schemas/Rating'
        lowest:
          $ref: '#/components/schemas/Rating'
    Score:
      type: object
      properties:
        score:
          type: integer
        date:
          type: integer
          format: timestamp
      required:
        - score
        - date
    PuzzleRushStats:
      type: object
      properties:
        higest:
          $ref: '#/components/schemas/Score'
        lowest:
          $ref: '#/components/schemas/Score'
    DailyGame:
      type: object
      properties:
        white:
          type: string
          format: uri
          description: URL of the white player's profile
        black:
          type: string
          format: uri
          description: URL of the black player's profile
        url:
          type: string
          format: uri
          description: URL of this game
        fen:
          type: string
          description: Current FEN
        pgn:
          type: string
          description: Current PGN
        turn:
          description: Player to move
          $ref: '#/components/schemas/Player'
        move_by:
          type: integer
          format: timestamp
          description: Timestamp of when the next move must be made
        draw_offer:
          description: Player who has made a draw offer (optional)
          $ref: '#/components/schemas/Player'
        last_activity:
          type: integer
          format: timestamp
          description: Timestamp of the last activity on the game
        start_time:
          type: integer
          format: timestamp
          description: Timestamp of the game start (Daily Chess only)
        time_control:
          type: string
          description: PGN-compliant time control
        time_class:
          type: string
          enum: [daily, rapid, blitz, bullet]
          description: Time-per-move grouping, used for ratings
        rules:
          type: string
          enum: [chess, chess960, bughouse, kingofthehill, threecheck, crazyhouse]
          description: Game variant information (e.g., "chess960")
        tournament:
          type: string
          format: uri
          description: URL pointing to tournament (if available)
        match:
          type: string
          format: uri
          description: URL pointing to team match (if available)
      required:
        - white
        - black
        - url
        - fen
        - pgn
        - turn
        - last_activity
        - time_control
        - time_class
        - rules
    ToMoveGame:
      type: object
      properties:
        url:
          type: string
          format: uri
          description: URL of this game
        move_by:
          type: integer
          format: timestamp
          description: Timestamp of when the next move must be made
        draw_offer:
          description: Player who has made a draw offer (optional)
          type: boolean
        last_activity:
          type: integer
          format: timestamp
          description: Timestamp of the last activity on the game
      required:
        - url
        - move_by
        - last_activity
    PlayerResult:
      type: object
      properties:
        username:
          type: string
        rating:
          type: integer
          description: The player's rating at the start of the game
          minimum: 0
        result:
          type: string
          enum: [win, checkmated, agreed, repetition, timeout, resigned, stalemate, lose, insufficient, 50move, abandoned, kingofthehill, threecheck, timevsinsufficient, bughousepartnerlose]
          description: |
            Player result:
             * `win` - Win
             * `checkmated` - Checkmated
             * `agreed` - Draw agreed
             * `repetition` - Draw by repetition
             * `timeout` - Timeout
             * `resigned` - Resigned
             * `stalemate` - Stalemate
             * `lose` - Lose
             * `insufficient` - Insufficient material
             * `50` - Draw by 50-move rule
             * `abandoned` - abandoned
             * `kingofthehill` - Opponent king reached the hill
             * `threecheck` - Checked for the 3rd time
             * `timevsinsufficient` - Draw by timeout vs insufficient material
             * `bughousepartnerlose` - Bughouse partner lost
        "@id":
          type: string
          description: URL of this player's profile
      required:
        - username
        - rating
        - result
        - "@id"
    CompletedGame:
      type: object
      properties:
        white:
          description: Details of the white-piece player
          $ref: '#/components/schemas/PlayerResult'
        black:
          description: Details of the white-piece player
          $ref: '#/components/schemas/PlayerResult'
        url:
          type: string
          format: uri
          description: URL of this game
        fen:
          type: string
          description: Current FEN
        pgn:
          type: string
          description: Current PGN
        start_time:
          type: integer
          format: timestamp
          description: Timestamp of the game start (Daily Chess only)
        end_time:
          type: integer
          format: timestamp
          description: Timestamp of the game end
        rated: # note, this field is missing from the documentation, but does appear in the API
          type: boolean
          description: Indicates if the game was rated
        time_control:
          type: string
          description: PGN-compliant time control
        time_class:  # note, this field is missing from the documentation, but does appear in the API
          type: string
          enum: [daily, rapid, blitz, bullet]
          description: Time-per-move grouping, used for ratings
        rules:
          type: string
          enum: [chess, chess960, bughouse, kingofthehill, threecheck, crazyhouse]
          description: Game variant information (e.g., "chess960")
        eco:
          type: string
          description: URL pointing to ECO opening (if available)
        tournament:
          type: string
          format: uri
          description: URL pointing to tournament (if available)
        match:
          type: string
          format: uri
          description: URL pointing to team match (if available)
      required:
        - white
        - black
        - url
        - fen
        - pgn
        - end_time
        - rated
        - time_control
        - time_class
        - rules

    # Schema for error response body
    Error:
      type: object
      properties:
        code:
          type: integer
        message:
          type: string
      required:
        - code
        - message