brawlstars-sdk 0.3.0

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.
@@ -0,0 +1,929 @@
1
+ /**
2
+ * Player or club tag used by the official API.
3
+ */
4
+ type EntityTag = `#${string}` | string;
5
+ /**
6
+ * Country code accepted by ranking endpoints.
7
+ */
8
+ type CountryCode = "global" | string;
9
+ /**
10
+ * Brawler identifier used by brawler endpoints.
11
+ */
12
+ type BrawlerId = string | number;
13
+ /**
14
+ * Cursor set used by paginated Brawl Stars list responses.
15
+ */
16
+ interface PagingCursors {
17
+ before?: string | undefined;
18
+ after?: string | undefined;
19
+ }
20
+ /**
21
+ * Pagination metadata wrapper.
22
+ */
23
+ interface Paging {
24
+ cursors?: PagingCursors | undefined;
25
+ }
26
+ /**
27
+ * Normalized list response shape returned by this client.
28
+ */
29
+ interface ApiListResponse<TItem> {
30
+ items: TItem[];
31
+ paging?: Paging | undefined;
32
+ }
33
+ /**
34
+ * Common query parameters for cursor-based endpoints.
35
+ */
36
+ interface CursorPaginationQuery {
37
+ before?: string | undefined;
38
+ after?: string | undefined;
39
+ limit?: number | undefined;
40
+ }
41
+ /**
42
+ * Localized name payload. The API export does not provide locale keys,
43
+ * so values are represented as a dictionary.
44
+ */
45
+ interface JsonLocalizedName {
46
+ [locale: string]: string;
47
+ }
48
+ /**
49
+ * Generic accessory model (gadgets and similar unlocks).
50
+ */
51
+ interface Accessory {
52
+ id: number;
53
+ name: JsonLocalizedName;
54
+ }
55
+ /**
56
+ * Star power model.
57
+ */
58
+ interface StarPower {
59
+ id: number;
60
+ name: JsonLocalizedName;
61
+ }
62
+ /**
63
+ * Hyper charge model.
64
+ */
65
+ interface HyperCharge {
66
+ id: number;
67
+ name: JsonLocalizedName;
68
+ }
69
+ /**
70
+ * Gear model with level information.
71
+ */
72
+ interface GearStat {
73
+ id: number;
74
+ name: JsonLocalizedName;
75
+ level: number;
76
+ }
77
+ /**
78
+ * Skin model for brawler stats.
79
+ */
80
+ interface Skin {
81
+ id: number;
82
+ name: JsonLocalizedName;
83
+ }
84
+ /**
85
+ * Brawler buff toggles available for a player.
86
+ */
87
+ interface BrawlerBuffies {
88
+ gadget: boolean;
89
+ starPower: boolean;
90
+ hyperCharge: boolean;
91
+ }
92
+ /**
93
+ * Detailed brawler stats for a specific player.
94
+ */
95
+ interface BrawlerStat {
96
+ id: number;
97
+ name: JsonLocalizedName;
98
+ rank: number;
99
+ trophies: number;
100
+ highestTrophies: number;
101
+ prestigeLevel: number;
102
+ power: number;
103
+ currentWinStreak: number;
104
+ maxWinStreak: number;
105
+ gadgets: Accessory[];
106
+ starPowers: StarPower[];
107
+ hyperCharges: HyperCharge[];
108
+ gears: GearStat[];
109
+ buffies: BrawlerBuffies;
110
+ skin: Skin;
111
+ }
112
+ /**
113
+ * Basic player icon descriptor.
114
+ */
115
+ interface PlayerIcon {
116
+ id: number;
117
+ }
118
+ /**
119
+ * Player club information embedded in player responses.
120
+ */
121
+ interface PlayerClub {
122
+ tag: string;
123
+ name: string;
124
+ }
125
+ /**
126
+ * Main player model.
127
+ */
128
+ interface Player {
129
+ tag: string;
130
+ name: string;
131
+ nameColor: string;
132
+ icon: PlayerIcon;
133
+ club?: PlayerClub | undefined;
134
+ trophies: number;
135
+ highestTrophies: number;
136
+ totalPrestigeLevel: number;
137
+ expLevel: number;
138
+ expPoints: number;
139
+ soloVictories: number;
140
+ duoVictories: number;
141
+ bestRoboRumbleTime: number;
142
+ bestTimeAsBigBrawler: number;
143
+ isQualifiedFromChampionshipChallenge: boolean;
144
+ brawlers: BrawlerStat[];
145
+ "3vs3Victories": number;
146
+ }
147
+ /**
148
+ * Club member model.
149
+ */
150
+ interface ClubMember {
151
+ tag: string;
152
+ name: string;
153
+ nameColor: string;
154
+ trophies: number;
155
+ role: string;
156
+ icon: PlayerIcon;
157
+ }
158
+ /**
159
+ * Club model.
160
+ */
161
+ interface Club {
162
+ tag: string;
163
+ name: string;
164
+ description: string;
165
+ trophies: number;
166
+ requiredTrophies: number;
167
+ members: ClubMember[];
168
+ type: string;
169
+ badgeId: number;
170
+ isFamilyFriendly: boolean;
171
+ }
172
+ /**
173
+ * Club ranking entry.
174
+ */
175
+ interface ClubRanking {
176
+ tag: string;
177
+ name: string;
178
+ trophies: number;
179
+ rank: number;
180
+ memberCount: number;
181
+ badgeId: number;
182
+ }
183
+ /**
184
+ * Player club info inside ranking entries.
185
+ */
186
+ interface PlayerRankingClub {
187
+ name: string;
188
+ }
189
+ /**
190
+ * Player ranking entry.
191
+ */
192
+ interface PlayerRanking {
193
+ tag: string;
194
+ name: string;
195
+ nameColor: string;
196
+ rank: number;
197
+ trophies: number;
198
+ icon: PlayerIcon;
199
+ club: PlayerRankingClub;
200
+ }
201
+ /**
202
+ * Static brawler metadata.
203
+ */
204
+ interface Brawler {
205
+ id: number;
206
+ name: JsonLocalizedName;
207
+ gadgets: Accessory[];
208
+ starPowers: StarPower[];
209
+ hyperCharges: HyperCharge[];
210
+ gears: GearStat[];
211
+ }
212
+ /**
213
+ * Game mode descriptor.
214
+ */
215
+ interface EventType {
216
+ id: number;
217
+ name: JsonLocalizedName;
218
+ }
219
+ /**
220
+ * Scheduled event location details.
221
+ */
222
+ interface ScheduledEventLocation {
223
+ id: number;
224
+ modeId: number;
225
+ mode: string;
226
+ map: JsonLocalizedName;
227
+ modifiers?: string[] | undefined;
228
+ }
229
+ /**
230
+ * Scheduled event entry in the event rotation response.
231
+ */
232
+ interface ScheduledEvent {
233
+ slotId: number;
234
+ startTime: string;
235
+ endTime: string;
236
+ event: ScheduledEventLocation;
237
+ }
238
+ /**
239
+ * Event payload in battle log entries.
240
+ */
241
+ interface Event {
242
+ id: number;
243
+ modeId: number;
244
+ mode: string;
245
+ map: JsonLocalizedName;
246
+ }
247
+ /**
248
+ * Battle result payload is not expanded in the source export.
249
+ */
250
+ interface BattleResult {
251
+ [key: string]: unknown;
252
+ }
253
+ /**
254
+ * Battle log entry.
255
+ */
256
+ interface Battle {
257
+ battleTime: string;
258
+ battle: BattleResult;
259
+ event: Event;
260
+ }
261
+ /**
262
+ * Standard client error body returned by non-2xx responses.
263
+ */
264
+ interface ClientErrorResponse {
265
+ reason: string;
266
+ message: string;
267
+ type: string;
268
+ detail?: Record<string, unknown> | undefined;
269
+ }
270
+ /**
271
+ * Battle log response.
272
+ */
273
+ type BattleLogResponse = ApiListResponse<Battle>;
274
+ /**
275
+ * Club members response.
276
+ */
277
+ type ClubMembersResponse = ApiListResponse<ClubMember>;
278
+ /**
279
+ * Club rankings response.
280
+ */
281
+ type ClubRankingsResponse = ApiListResponse<ClubRanking>;
282
+ /**
283
+ * Player rankings response.
284
+ */
285
+ type PlayerRankingsResponse = ApiListResponse<PlayerRanking>;
286
+ /**
287
+ * Brawler list response.
288
+ */
289
+ type BrawlersResponse = ApiListResponse<Brawler>;
290
+ /**
291
+ * Game modes response.
292
+ */
293
+ type GameModesResponse = ApiListResponse<EventType>;
294
+ /**
295
+ * Event rotation response.
296
+ */
297
+ type EventRotationResponse = ApiListResponse<ScheduledEvent>;
298
+
299
+ /**
300
+ * Request metadata attached to errors.
301
+ */
302
+ interface ApiErrorRequest {
303
+ method: HttpMethod;
304
+ url: string;
305
+ options?: {
306
+ timeoutMs?: number | undefined;
307
+ retries?: number | Partial<RetryOptions> | undefined;
308
+ cache?: boolean | RequestCacheOptions | undefined;
309
+ validation?: ValidationMode | undefined;
310
+ headers?: Readonly<Record<string, string>> | undefined;
311
+ } | undefined;
312
+ }
313
+ /**
314
+ * Structured metadata attached to all API errors.
315
+ */
316
+ interface ApiErrorMetadata {
317
+ endpoint: EndpointName;
318
+ method: HttpMethod;
319
+ request?: ApiErrorRequest | undefined;
320
+ statusCode?: number | undefined;
321
+ headers?: Readonly<Record<string, string>> | undefined;
322
+ body?: unknown;
323
+ responseBody?: unknown;
324
+ received?: unknown;
325
+ retryAfter?: number | null | undefined;
326
+ retryAfterMs?: number | undefined;
327
+ requestId?: string | undefined;
328
+ cause?: unknown;
329
+ }
330
+ /**
331
+ * Metadata for strict response validation failures.
332
+ */
333
+ interface ResponseValidationMetadata extends ApiErrorMetadata {
334
+ expectedSchema: string;
335
+ actualPayload: unknown;
336
+ }
337
+ /**
338
+ * Base error for all request failures.
339
+ */
340
+ declare class ApiError extends Error {
341
+ readonly endpoint: EndpointName;
342
+ readonly method: HttpMethod;
343
+ readonly request?: ApiErrorRequest | undefined;
344
+ readonly statusCode?: number | undefined;
345
+ readonly headers: Readonly<Record<string, string>>;
346
+ readonly body?: unknown;
347
+ readonly responseBody?: unknown;
348
+ readonly retryAfter: number | null;
349
+ readonly retryAfterMs?: number | undefined;
350
+ readonly requestId?: string | undefined;
351
+ constructor(message: string, metadata: ApiErrorMetadata);
352
+ }
353
+ /**
354
+ * Error raised for 4xx responses produced by the API.
355
+ */
356
+ declare class ClientError extends ApiError {
357
+ constructor(message: string, metadata: ApiErrorMetadata);
358
+ }
359
+ /**
360
+ * Error raised when the API returns a throttling response.
361
+ */
362
+ declare class RateLimitError extends ApiError {
363
+ constructor(message: string, metadata: ApiErrorMetadata);
364
+ }
365
+ /**
366
+ * Error raised when a request exceeds the configured timeout.
367
+ */
368
+ declare class TimeoutError extends ApiError {
369
+ constructor(message: string, metadata: ApiErrorMetadata);
370
+ }
371
+ /**
372
+ * Error raised when network transport fails.
373
+ */
374
+ declare class NetworkError extends ApiError {
375
+ constructor(message: string, metadata: ApiErrorMetadata);
376
+ }
377
+ /**
378
+ * Error raised when runtime response validation fails.
379
+ */
380
+ declare class ValidationError extends ApiError {
381
+ constructor(message: string, metadata: ApiErrorMetadata);
382
+ }
383
+ /**
384
+ * Error raised when strict response schema validation fails.
385
+ */
386
+ declare class ResponseValidationError extends ValidationError {
387
+ readonly expectedSchema: string;
388
+ readonly actualPayload: unknown;
389
+ constructor(message: string, metadata: ResponseValidationMetadata);
390
+ }
391
+
392
+ /**
393
+ * Event emitted before dispatching a request.
394
+ */
395
+ interface RequestStartEvent {
396
+ requestId: string;
397
+ endpoint: EndpointName;
398
+ method: HttpMethod;
399
+ url: string;
400
+ attempt: number;
401
+ }
402
+ /**
403
+ * Event emitted after receiving a successful or failed HTTP response.
404
+ */
405
+ interface RequestEndEvent {
406
+ requestId: string;
407
+ endpoint: EndpointName;
408
+ method: HttpMethod;
409
+ url: string;
410
+ attempt: number;
411
+ statusCode: number;
412
+ durationMs: number;
413
+ }
414
+ /**
415
+ * Event emitted when a request attempt fails.
416
+ */
417
+ interface RequestErrorEvent {
418
+ requestId: string;
419
+ endpoint: EndpointName;
420
+ method: HttpMethod;
421
+ url: string;
422
+ attempt: number;
423
+ willRetry: boolean;
424
+ durationMs: number;
425
+ error: Error;
426
+ }
427
+ /**
428
+ * Listener functions for request lifecycle events.
429
+ */
430
+ interface ObservabilityListeners {
431
+ requestStart?: ((event: RequestStartEvent) => void | Promise<void>) | ReadonlyArray<(event: RequestStartEvent) => void | Promise<void>> | undefined;
432
+ requestEnd?: ((event: RequestEndEvent) => void | Promise<void>) | ReadonlyArray<(event: RequestEndEvent) => void | Promise<void>> | undefined;
433
+ requestError?: ((event: RequestErrorEvent) => void | Promise<void>) | ReadonlyArray<(event: RequestErrorEvent) => void | Promise<void>> | undefined;
434
+ }
435
+ /**
436
+ * Adapter contract for optional metrics backends.
437
+ */
438
+ interface MetricsAdapter {
439
+ onRequestStart?(event: RequestStartEvent): void;
440
+ onRequestEnd?(event: RequestEndEvent): void;
441
+ onRequestError?(event: RequestErrorEvent): void;
442
+ }
443
+ /**
444
+ * Observability configuration passed to the client.
445
+ */
446
+ interface ObservabilityOptions {
447
+ listeners?: ObservabilityListeners | undefined;
448
+ metrics?: MetricsAdapter | ReadonlyArray<MetricsAdapter> | undefined;
449
+ }
450
+
451
+ /**
452
+ * HTTP method supported by the Brawl Stars API wrapper.
453
+ */
454
+ type HttpMethod = "GET";
455
+ /**
456
+ * Endpoint identifiers used internally and in hook contexts.
457
+ */
458
+ type EndpointName = "players.get" | "players.getBattleLog" | "clubs.get" | "clubs.getMembers" | "rankings.getClubs" | "rankings.getPlayers" | "rankings.getBrawlers" | "brawlers.list" | "brawlers.get" | "gamemodes.list" | "events.getRotation";
459
+ /**
460
+ * Strategy used for retry jitter.
461
+ */
462
+ type RetryJitter = "full" | "none";
463
+ /**
464
+ * Runtime response validation mode.
465
+ */
466
+ type ValidationMode = "off" | "warn" | "strict";
467
+ /**
468
+ * Logger used by the SDK for runtime warnings and diagnostics.
469
+ */
470
+ interface ClientLogger {
471
+ warn: (...messages: ReadonlyArray<unknown>) => void;
472
+ error?: (...messages: ReadonlyArray<unknown>) => void;
473
+ info?: (...messages: ReadonlyArray<unknown>) => void;
474
+ }
475
+ /**
476
+ * Retry strategy options.
477
+ */
478
+ interface RetryOptions {
479
+ maxAttempts: number;
480
+ baseDelayMs: number;
481
+ maxDelayMs: number;
482
+ backoffFactor: number;
483
+ jitter: RetryJitter;
484
+ retryableStatusCodes: ReadonlyArray<number>;
485
+ }
486
+ /**
487
+ * Per-endpoint cache policy overrides.
488
+ */
489
+ type EndpointCachePolicy = Partial<Record<EndpointName, number>>;
490
+ /**
491
+ * In-memory cache options.
492
+ */
493
+ interface CacheOptions {
494
+ maxSize?: number | undefined;
495
+ ttlMs?: number | undefined;
496
+ endpointTtlMs?: EndpointCachePolicy | undefined;
497
+ }
498
+ /**
499
+ * Request-level cache override.
500
+ */
501
+ interface RequestCacheOptions {
502
+ enabled?: boolean | undefined;
503
+ ttlMs?: number | undefined;
504
+ }
505
+ /**
506
+ * Context passed to `beforeRequest` hooks.
507
+ */
508
+ interface BeforeRequestContext {
509
+ endpoint: EndpointName;
510
+ method: HttpMethod;
511
+ url: string;
512
+ attempt: number;
513
+ requestId: string;
514
+ headers: Readonly<Record<string, string>>;
515
+ }
516
+ /**
517
+ * Context passed to `afterResponse` hooks.
518
+ */
519
+ interface AfterResponseContext {
520
+ endpoint: EndpointName;
521
+ method: HttpMethod;
522
+ url: string;
523
+ attempt: number;
524
+ requestId: string;
525
+ durationMs: number;
526
+ statusCode: number;
527
+ headers: Readonly<Record<string, string>>;
528
+ }
529
+ /**
530
+ * Context passed to `onError` hooks.
531
+ */
532
+ interface ErrorContext {
533
+ endpoint: EndpointName;
534
+ method: HttpMethod;
535
+ url: string;
536
+ attempt: number;
537
+ requestId: string;
538
+ durationMs: number;
539
+ willRetry: boolean;
540
+ error: ApiError;
541
+ }
542
+ /**
543
+ * Context passed to `onRateLimit` hooks.
544
+ */
545
+ interface RateLimitContext {
546
+ endpoint: EndpointName;
547
+ method: HttpMethod;
548
+ url: string;
549
+ attempt: number;
550
+ requestId: string;
551
+ statusCode: number;
552
+ retryAfter: number | null;
553
+ headers: Readonly<Record<string, string>>;
554
+ }
555
+ /**
556
+ * Async hook function.
557
+ */
558
+ type HookFn<TContext> = (context: TContext) => void | Promise<void>;
559
+ /**
560
+ * Hook definitions for request lifecycle events.
561
+ */
562
+ interface ClientHooks {
563
+ beforeRequest?: HookFn<BeforeRequestContext> | ReadonlyArray<HookFn<BeforeRequestContext>> | undefined;
564
+ afterResponse?: HookFn<AfterResponseContext> | ReadonlyArray<HookFn<AfterResponseContext>> | undefined;
565
+ onError?: HookFn<ErrorContext> | ReadonlyArray<HookFn<ErrorContext>> | undefined;
566
+ onRateLimit?: HookFn<RateLimitContext> | ReadonlyArray<HookFn<RateLimitContext>> | undefined;
567
+ }
568
+ /**
569
+ * Main client constructor options.
570
+ */
571
+ interface BrawlStarsClientOptions {
572
+ token: string;
573
+ baseUrl?: string | undefined;
574
+ timeoutMs?: number | undefined;
575
+ retries?: number | Partial<RetryOptions> | undefined;
576
+ concurrencyLimit?: number | undefined;
577
+ cache?: boolean | CacheOptions | undefined;
578
+ validation?: ValidationMode | undefined;
579
+ /**
580
+ * @deprecated Use `validation` instead.
581
+ */
582
+ validateResponses?: boolean | undefined;
583
+ hooks?: ClientHooks | undefined;
584
+ observability?: ObservabilityOptions | undefined;
585
+ fetch?: typeof fetch | undefined;
586
+ logger?: ClientLogger | undefined;
587
+ cacheKeyHeaders?: ReadonlyArray<string> | undefined;
588
+ }
589
+ /**
590
+ * Per-request override options.
591
+ */
592
+ interface RequestOptions {
593
+ timeoutMs?: number | undefined;
594
+ retries?: number | Partial<RetryOptions> | undefined;
595
+ signal?: AbortSignal | undefined;
596
+ headers?: HeadersInit | undefined;
597
+ cache?: boolean | RequestCacheOptions | undefined;
598
+ validation?: ValidationMode | undefined;
599
+ /**
600
+ * @deprecated Use `validation` instead.
601
+ */
602
+ validateResponse?: boolean | undefined;
603
+ hooks?: ClientHooks | undefined;
604
+ }
605
+
606
+ /**
607
+ * Shared options for paginated endpoints.
608
+ */
609
+ interface PaginatedEndpointOptions extends RequestOptions, CursorPaginationQuery {
610
+ }
611
+ /**
612
+ * Options for `players.get`.
613
+ */
614
+ type GetPlayerOptions = RequestOptions;
615
+ /**
616
+ * Options for `players.getBattleLog`.
617
+ */
618
+ type GetPlayerBattleLogOptions = RequestOptions;
619
+ /**
620
+ * Options for `clubs.get`.
621
+ */
622
+ type GetClubOptions = RequestOptions;
623
+ /**
624
+ * Options for `clubs.getMembers`.
625
+ */
626
+ type GetClubMembersOptions = PaginatedEndpointOptions;
627
+ /**
628
+ * Options for `rankings.getClubs`.
629
+ */
630
+ type GetClubRankingsOptions = PaginatedEndpointOptions;
631
+ /**
632
+ * Options for `rankings.getPlayers`.
633
+ */
634
+ type GetPlayerRankingsOptions = PaginatedEndpointOptions;
635
+ /**
636
+ * Options for `rankings.getBrawlers`.
637
+ */
638
+ type GetBrawlerRankingsOptions = PaginatedEndpointOptions;
639
+ /**
640
+ * Options for `brawlers.list`.
641
+ */
642
+ type ListBrawlersOptions = PaginatedEndpointOptions;
643
+ /**
644
+ * Options for `brawlers.get`.
645
+ */
646
+ type GetBrawlerOptions = RequestOptions;
647
+ /**
648
+ * Options for `gamemodes.list`.
649
+ */
650
+ type ListGameModesOptions = PaginatedEndpointOptions;
651
+ /**
652
+ * Options for `events.getRotation`.
653
+ */
654
+ type GetEventRotationOptions = RequestOptions;
655
+
656
+ /**
657
+ * Endpoint parser function with optional runtime validation.
658
+ */
659
+ type EndpointParser<TResponse> = (payload: unknown, validate: boolean) => TResponse;
660
+
661
+ interface InternalRequestConfig<TResponse> {
662
+ endpoint: EndpointName;
663
+ method: HttpMethod;
664
+ path: string;
665
+ query?: Readonly<Record<string, string | number | boolean | undefined>> | undefined;
666
+ options?: RequestOptions | undefined;
667
+ parser: EndpointParser<TResponse>;
668
+ }
669
+ /**
670
+ * Internal HTTP layer used by all endpoint resources.
671
+ */
672
+ declare class HttpClient {
673
+ private readonly fetchFn;
674
+ private readonly baseUrl;
675
+ private readonly timeoutMs;
676
+ private readonly retryOptions;
677
+ private readonly validationMode;
678
+ private readonly logger;
679
+ private readonly defaultHeaders;
680
+ private readonly hooks;
681
+ private readonly observability;
682
+ private readonly cacheSettings;
683
+ private readonly cacheKeyHeaders;
684
+ private readonly cache;
685
+ private readonly semaphore;
686
+ private globalRateLimitUntilMs;
687
+ private readonly routeRateLimitUntilMs;
688
+ private readonly endpointCacheIndex;
689
+ private requestCounter;
690
+ constructor(options: BrawlStarsClientOptions);
691
+ /**
692
+ * Execute a typed request against the API.
693
+ */
694
+ request<TResponse>(config: InternalRequestConfig<TResponse>): Promise<TResponse>;
695
+ /**
696
+ * Clear all in-memory cached responses.
697
+ */
698
+ clearCache(): void;
699
+ /**
700
+ * Invalidate cached responses for a given endpoint, or all endpoints when omitted.
701
+ */
702
+ invalidateCache(endpoint?: EndpointName): number;
703
+ private executeRequest;
704
+ private createRequestId;
705
+ private createApiError;
706
+ private emitError;
707
+ private resolveValidationMode;
708
+ private createRequestMetadata;
709
+ private resolveCacheSettings;
710
+ private resolveCachePolicy;
711
+ private isCacheableMethod;
712
+ private trackEndpointCacheKey;
713
+ private waitForRateLimitWindow;
714
+ private updateRateLimitState;
715
+ private parseResponseBody;
716
+ }
717
+
718
+ /**
719
+ * Brawler endpoint group.
720
+ */
721
+ declare class BrawlersResource {
722
+ private readonly http;
723
+ constructor(http: HttpClient);
724
+ /**
725
+ * List all brawlers.
726
+ */
727
+ list(opts?: ListBrawlersOptions): Promise<BrawlersResponse>;
728
+ /**
729
+ * @deprecated Use `list(opts?)`.
730
+ */
731
+ list(query?: CursorPaginationQuery, opts?: RequestOptions): Promise<BrawlersResponse>;
732
+ /**
733
+ * Get one brawler by identifier.
734
+ */
735
+ get(brawlerId: BrawlerId, opts?: GetBrawlerOptions): Promise<Brawler>;
736
+ }
737
+
738
+ /**
739
+ * Club endpoint group.
740
+ */
741
+ declare class ClubsResource {
742
+ private readonly http;
743
+ constructor(http: HttpClient);
744
+ /**
745
+ * Get full club details by tag.
746
+ */
747
+ get(clubTag: EntityTag, opts?: GetClubOptions): Promise<Club>;
748
+ /**
749
+ * List members for a club with optional cursor pagination.
750
+ */
751
+ getMembers(clubTag: EntityTag, opts?: GetClubMembersOptions): Promise<ClubMembersResponse>;
752
+ /**
753
+ * @deprecated Use `getMembers(clubTag, opts?)`.
754
+ */
755
+ getMembers(clubTag: EntityTag, query?: CursorPaginationQuery, opts?: RequestOptions): Promise<ClubMembersResponse>;
756
+ }
757
+
758
+ /**
759
+ * Events endpoint group.
760
+ */
761
+ declare class EventsResource {
762
+ private readonly http;
763
+ constructor(http: HttpClient);
764
+ /**
765
+ * Get currently active event rotation.
766
+ */
767
+ getRotation(opts?: GetEventRotationOptions): Promise<EventRotationResponse>;
768
+ }
769
+
770
+ /**
771
+ * Game modes endpoint group.
772
+ */
773
+ declare class GameModesResource {
774
+ private readonly http;
775
+ constructor(http: HttpClient);
776
+ /**
777
+ * List available game modes.
778
+ */
779
+ list(opts?: ListGameModesOptions): Promise<GameModesResponse>;
780
+ /**
781
+ * @deprecated Use `list(opts?)`.
782
+ */
783
+ list(query?: CursorPaginationQuery, opts?: RequestOptions): Promise<GameModesResponse>;
784
+ }
785
+
786
+ /**
787
+ * Player endpoint group.
788
+ */
789
+ declare class PlayersResource {
790
+ private readonly http;
791
+ constructor(http: HttpClient);
792
+ /**
793
+ * Get a player profile by tag.
794
+ *
795
+ * @example
796
+ * const player = await client.players.get("#2PP");
797
+ */
798
+ get(playerTag: EntityTag, opts?: GetPlayerOptions): Promise<Player>;
799
+ /**
800
+ * Get recent battle log entries for a player.
801
+ *
802
+ * @example
803
+ * const battles = await client.players.getBattleLog("#2PP");
804
+ */
805
+ getBattleLog(playerTag: EntityTag, opts?: GetPlayerBattleLogOptions): Promise<BattleLogResponse>;
806
+ }
807
+
808
+ /**
809
+ * Ranking endpoint group.
810
+ */
811
+ declare class RankingsResource {
812
+ private readonly http;
813
+ constructor(http: HttpClient);
814
+ /**
815
+ * Get club rankings for a country or globally.
816
+ */
817
+ getClubs(countryCode: CountryCode, opts?: GetClubRankingsOptions): Promise<ClubRankingsResponse>;
818
+ /**
819
+ * @deprecated Use `getClubs(countryCode, opts?)`.
820
+ */
821
+ getClubs(countryCode: CountryCode, query?: CursorPaginationQuery, opts?: RequestOptions): Promise<ClubRankingsResponse>;
822
+ /**
823
+ * Get player rankings for a country or globally.
824
+ */
825
+ getPlayers(countryCode: CountryCode, opts?: GetPlayerRankingsOptions): Promise<PlayerRankingsResponse>;
826
+ /**
827
+ * @deprecated Use `getPlayers(countryCode, opts?)`.
828
+ */
829
+ getPlayers(countryCode: CountryCode, query?: CursorPaginationQuery, opts?: RequestOptions): Promise<PlayerRankingsResponse>;
830
+ /**
831
+ * Get rankings for one brawler in a country or globally.
832
+ */
833
+ getBrawlers(countryCode: CountryCode, brawlerId: BrawlerId, opts?: GetBrawlerRankingsOptions): Promise<PlayerRankingsResponse>;
834
+ /**
835
+ * @deprecated Use `getBrawlers(countryCode, brawlerId, opts?)`.
836
+ */
837
+ getBrawlers(countryCode: CountryCode, brawlerId: BrawlerId, query?: CursorPaginationQuery, opts?: RequestOptions): Promise<PlayerRankingsResponse>;
838
+ }
839
+
840
+ /**
841
+ * Main Brawl Stars API client.
842
+ */
843
+ declare class BrawlStarsClient {
844
+ private readonly http;
845
+ /**
846
+ * Player operations.
847
+ */
848
+ readonly players: PlayersResource;
849
+ /**
850
+ * Club operations.
851
+ */
852
+ readonly clubs: ClubsResource;
853
+ /**
854
+ * Ranking operations.
855
+ */
856
+ readonly rankings: RankingsResource;
857
+ /**
858
+ * Brawler operations.
859
+ */
860
+ readonly brawlers: BrawlersResource;
861
+ /**
862
+ * Game mode operations.
863
+ */
864
+ readonly gamemodes: GameModesResource;
865
+ /**
866
+ * Event operations.
867
+ */
868
+ readonly events: EventsResource;
869
+ /**
870
+ * Create a new API client.
871
+ */
872
+ constructor(options: BrawlStarsClientOptions);
873
+ /**
874
+ * Clear all in-memory cached responses.
875
+ */
876
+ clearCache(): void;
877
+ /**
878
+ * Invalidate cache entries for one endpoint or all endpoints.
879
+ */
880
+ invalidateCache(endpoint?: EndpointName): number;
881
+ }
882
+
883
+ /**
884
+ * Convenience factory for creating a `BrawlStarsClient`.
885
+ */
886
+ declare function createBrawlStarsClient(options: BrawlStarsClientOptions): BrawlStarsClient;
887
+
888
+ interface CounterLike {
889
+ inc(labels?: Record<string, string | number>, value?: number): void;
890
+ }
891
+ interface HistogramLike {
892
+ observe(labels: Record<string, string | number>, value: number): void;
893
+ }
894
+ /**
895
+ * Minimal prom-client compatible adapter contract.
896
+ */
897
+ interface PromClientAdapterOptions {
898
+ requestsStarted?: CounterLike;
899
+ requestsCompleted?: CounterLike;
900
+ requestsFailed?: CounterLike;
901
+ requestDurationMs?: HistogramLike;
902
+ }
903
+ /**
904
+ * Create a metrics adapter for projects already using `prom-client`.
905
+ */
906
+ declare function createPromClientAdapter(options: PromClientAdapterOptions): MetricsAdapter;
907
+
908
+ /**
909
+ * Options for tag encoding.
910
+ */
911
+ interface EncodeTagOptions {
912
+ uppercase?: boolean | undefined;
913
+ }
914
+ /**
915
+ * Normalize a player/club tag and encode it for use inside API paths.
916
+ */
917
+ declare function encodeTag(tag: EntityTag, options?: EncodeTagOptions): string;
918
+
919
+ /**
920
+ * Public alias for constructor options.
921
+ */
922
+ interface ClientOptions extends BrawlStarsClientOptions {
923
+ }
924
+ /**
925
+ * Public validation mode options.
926
+ */
927
+ type ClientValidationMode = ValidationMode;
928
+
929
+ export { type Accessory, type AfterResponseContext, ApiError, type ApiErrorMetadata, type ApiErrorRequest, type ApiListResponse, type Battle, type BattleLogResponse, type BattleResult, type BeforeRequestContext, BrawlStarsClient, type BrawlStarsClientOptions, type Brawler, type BrawlerBuffies, type BrawlerId, type BrawlerStat, type BrawlersResponse, type CacheOptions, ClientError, type ClientErrorResponse, type ClientHooks, type ClientLogger, type ClientOptions, type ClientValidationMode, type Club, type ClubMember, type ClubMembersResponse, type ClubRanking, type ClubRankingsResponse, type CountryCode, type CursorPaginationQuery, type EncodeTagOptions, type EndpointCachePolicy, type EndpointName, type EntityTag, type ErrorContext, type Event, type EventRotationResponse, type EventType, type GameModesResponse, type GearStat, type GetBrawlerOptions, type GetBrawlerRankingsOptions, type GetClubMembersOptions, type GetClubOptions, type GetClubRankingsOptions, type GetEventRotationOptions, type GetPlayerBattleLogOptions, type GetPlayerOptions, type GetPlayerRankingsOptions, type HookFn, type HttpMethod, type HyperCharge, type JsonLocalizedName, type ListBrawlersOptions, type ListGameModesOptions, type MetricsAdapter, NetworkError, type ObservabilityListeners, type ObservabilityOptions, type PaginatedEndpointOptions, type Paging, type PagingCursors, type Player, type PlayerClub, type PlayerIcon, type PlayerRanking, type PlayerRankingsResponse, type RateLimitContext, RateLimitError, type RequestCacheOptions, type RequestEndEvent, type RequestErrorEvent, type RequestOptions, type RequestStartEvent, ResponseValidationError, type ResponseValidationMetadata, type RetryJitter, type RetryOptions, type ScheduledEvent, type ScheduledEventLocation, type Skin, type StarPower, TimeoutError, ValidationError, type ValidationMode, createBrawlStarsClient, createPromClientAdapter, encodeTag };