mcutils-js-api 2.0.28 → 2.0.29

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.ts CHANGED
@@ -7,6 +7,7 @@ import type { Cape } from "./types/player/cape/cape";
7
7
  import { ServerRegistryEntry } from "./types/server-registry/server-registry-entry";
8
8
  import { Player } from "./types/player/player";
9
9
  import { CachedPlayerName } from "./types/cache/cached-player-name";
10
+ import { StatisticsResponse } from "./types/response/statistics-response";
10
11
  export declare class McUtilsAPI {
11
12
  private readonly endpoint;
12
13
  constructor(endpoint?: string);
@@ -174,5 +175,14 @@ export declare class McUtilsAPI {
174
175
  entries?: ServerRegistryEntry[];
175
176
  error?: ErrorResponse;
176
177
  }>;
178
+ /**
179
+ * Fetch the statistics of the API.
180
+ *
181
+ * @returns the statistics or the error (if one occurred)
182
+ */
183
+ fetchStatistics(): Promise<{
184
+ statistics?: StatisticsResponse;
185
+ error?: ErrorResponse;
186
+ }>;
177
187
  }
178
188
  export default McUtilsAPI;
package/dist/index.js CHANGED
@@ -255,5 +255,19 @@ export class McUtilsAPI {
255
255
  error: (await response.json()),
256
256
  };
257
257
  }
258
+ /**
259
+ * Fetch the statistics of the API.
260
+ *
261
+ * @returns the statistics or the error (if one occurred)
262
+ */
263
+ async fetchStatistics() {
264
+ const response = await fetch(`${this.endpoint}/statistics`);
265
+ if (response.ok) {
266
+ return { statistics: (await response.json()) };
267
+ }
268
+ return {
269
+ error: (await response.json()),
270
+ };
271
+ }
258
272
  }
259
273
  export default McUtilsAPI;
@@ -0,0 +1,5 @@
1
+ export type StatisticsResponse = {
2
+ seenPlayers: number;
3
+ seenSkins: number;
4
+ seenCapes: number;
5
+ };
@@ -0,0 +1 @@
1
+ export {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mcutils-js-api",
3
- "version": "2.0.28",
3
+ "version": "2.0.29",
4
4
  "module": "dist/index.js",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",