chesscom 0.1.1

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
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.
      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.
      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. 
      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. 
      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: Array of Daily Chess games that a player is currently playing.
      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 usernames for players with this title
                    items:
                      $ref: '#/components/schemas/DailyGame'
                required:
                  - games                
        '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: the Glicko "RD" value used to calculate ratings changes
          required:
            - rating
            - date
            - rd
        best:
          type: object
          description: the 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: integer 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
        - best
        - 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
    
    # Schema for error response body
    Error:
      type: object
      properties:
        code:
          type: integer
        message:
          type: string
      required:
        - code
        - message