File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 11{
22 "name" : " mcutils-js-api" ,
3- "version" : " 2.0.28 " ,
3+ "version" : " 2.0.29 " ,
44 "module" : " dist/index.js" ,
55 "main" : " dist/index.js" ,
66 "types" : " dist/index.d.ts" ,
Original file line number Diff line number Diff line change @@ -8,6 +8,7 @@ import type { Cape } from "./types/player/cape/cape";
88import { ServerRegistryEntry } from "./types/server-registry/server-registry-entry" ;
99import { Player } from "./types/player/player" ;
1010import { CachedPlayerName } from "./types/cache/cached-player-name" ;
11+ import { StatisticsResponse } from "./types/response/statistics-response" ;
1112
1213export class McUtilsAPI {
1314 private readonly endpoint : string ;
@@ -327,6 +328,21 @@ export class McUtilsAPI {
327328 error : ( await response . json ( ) ) as ErrorResponse ,
328329 } ;
329330 }
331+
332+ /**
333+ * Fetch the statistics of the API.
334+ *
335+ * @returns the statistics or the error (if one occurred)
336+ */
337+ async fetchStatistics ( ) : Promise < { statistics ?: StatisticsResponse ; error ?: ErrorResponse } > {
338+ const response = await fetch ( `${ this . endpoint } /statistics` ) ;
339+ if ( response . ok ) {
340+ return { statistics : ( await response . json ( ) ) as StatisticsResponse } ;
341+ }
342+ return {
343+ error : ( await response . json ( ) ) as ErrorResponse ,
344+ } ;
345+ }
330346}
331347
332348export default McUtilsAPI ;
Original file line number Diff line number Diff line change 1+ export type StatisticsResponse = {
2+ seenPlayers : number ;
3+ seenSkins : number ;
4+ seenCapes : number ;
5+ } ;
You can’t perform that action at this time.
0 commit comments