fnapi-js 1.0.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.
package/src/index.d.ts ADDED
@@ -0,0 +1,503 @@
1
+ declare module 'fnapi-js' {
2
+ export interface ApiClientOptions {
3
+ apiKey?: string;
4
+ language?: string;
5
+ headers?: Record<string, string>;
6
+ query?: Record<string, string>;
7
+ }
8
+
9
+ export interface StatsResponse {
10
+ account: {
11
+ id: string;
12
+ name: string;
13
+ };
14
+ battlePass: {
15
+ level: number;
16
+ progress: number;
17
+ };
18
+ image: string;
19
+ stats: {
20
+ all: StatsData;
21
+ keyboardMouse: StatsData;
22
+ gamepad: StatsData;
23
+ touch: StatsData;
24
+ };
25
+ }
26
+
27
+ interface StatsData {
28
+ overall: GameModeStats;
29
+ solo: GameModeStats;
30
+ duo: GameModeStats;
31
+ squad: GameModeStats;
32
+ ltm: GameModeStats;
33
+ }
34
+
35
+ interface GameModeStats {
36
+ score: number;
37
+ scorePerMin: number;
38
+ scorePerMatch: number;
39
+ wins: number;
40
+ top3?: number;
41
+ top5?: number;
42
+ top6?: number;
43
+ top10?: number;
44
+ top12?: number;
45
+ top25?: number;
46
+ kills: number;
47
+ killsPerMin: number;
48
+ killsPerMatch: number;
49
+ deaths: number;
50
+ kd: number;
51
+ matches: number;
52
+ winRate: number;
53
+ minutesPlayed: number;
54
+ playersOutlived: number;
55
+ lastModified: string;
56
+ }
57
+
58
+ export class Stats {
59
+ constructor(client: ApiClient);
60
+ get(name: string, accountType: string, timeWindow: string, image?: string): Promise<StatsResponse>;
61
+ byId(id: string, timeWindow: string, image?: string): Promise<StatsResponse>;
62
+ }
63
+
64
+ export interface CreatorCodeResponse {
65
+ code: string;
66
+ account: {
67
+ id: string;
68
+ name: string;
69
+ };
70
+ status: string;
71
+ verified: boolean;
72
+ }
73
+
74
+ export class CreatorCode {
75
+ constructor(client: ApiClient);
76
+ get(code: string): Promise<CreatorCodeResponse>;
77
+ }
78
+
79
+ export interface CosmeticResponse {
80
+ id: string;
81
+ name: string;
82
+ description: string;
83
+ type: {
84
+ value: string;
85
+ displayValue: string;
86
+ backendValue: string;
87
+ };
88
+ rarity: {
89
+ value: string;
90
+ displayValue: string;
91
+ backendValue: string;
92
+ };
93
+ series: {
94
+ value: string;
95
+ image: string;
96
+ backendValue: string;
97
+ } | null;
98
+ set: {
99
+ value: string;
100
+ text: string;
101
+ backendValue: string;
102
+ } | null;
103
+ introduction: {
104
+ chapter: string;
105
+ season: string;
106
+ text: string;
107
+ backendValue: number;
108
+ };
109
+ images: {
110
+ smallIcon: string;
111
+ icon: string;
112
+ featured: string | null;
113
+ other: Record<string, string>;
114
+ };
115
+ variants: Array<{
116
+ channel: string;
117
+ type: string;
118
+ options: Array<{
119
+ tag: string;
120
+ name: string;
121
+ image: string;
122
+ }>;
123
+ }> | null;
124
+ gameplayTags: string[];
125
+ showcaseVideo: string | null;
126
+ displayAssetPath: string | null;
127
+ definitionPath: string | null;
128
+ path: string;
129
+ added: string;
130
+ shopHistory: string[] | null;
131
+ }
132
+
133
+ export class Cosmetics {
134
+ constructor(client: ApiClient);
135
+ searchCosmetics(options: SearchOptions): Promise<CosmeticResponse[]>;
136
+ getNewCosmetics(): Promise<CosmeticResponse[]>;
137
+ getById(id: string): Promise<CosmeticResponse>;
138
+ getTracks(): Promise<CosmeticResponse[]>;
139
+ getInstruments(): Promise<CosmeticResponse[]>;
140
+ getCars(): Promise<CosmeticResponse[]>;
141
+ getLego(): Promise<CosmeticResponse[]>;
142
+ getLegoKits(): Promise<CosmeticResponse[]>;
143
+ getBeans(): Promise<CosmeticResponse[]>;
144
+ }
145
+
146
+ export class SearchOptions {
147
+ constructor();
148
+ setMatchMethod(method: string): this;
149
+ setSearchLanguage(language: string): this;
150
+ setType(type: string): this;
151
+ setRarity(rarity: string): this;
152
+ build(): Record<string, any>;
153
+ }
154
+
155
+ export interface AesResponse {
156
+ build: string;
157
+ mainKey: string;
158
+ dynamicKeys: Array<{
159
+ pakFilename: string;
160
+ pakGuid: string;
161
+ key: string;
162
+ }>;
163
+ }
164
+
165
+ export interface BannerResponse {
166
+ id: string;
167
+ devName: string;
168
+ name: string;
169
+ description: string;
170
+ category: string;
171
+ fullUsageRights: boolean;
172
+ images: {
173
+ smallIcon: string;
174
+ icon: string;
175
+ };
176
+ }
177
+
178
+ export interface BannerColorResponse {
179
+ id: string;
180
+ color: string;
181
+ category: string;
182
+ subCategory: string | null;
183
+ }
184
+
185
+ export interface MapResponse {
186
+ images: {
187
+ blank: string;
188
+ pois: string;
189
+ };
190
+ pois: Array<{
191
+ id: string;
192
+ name: string;
193
+ location: {
194
+ x: number;
195
+ y: number;
196
+ z: number;
197
+ };
198
+ }>;
199
+ }
200
+
201
+ export interface NewsResponse {
202
+ br: {
203
+ hash: string;
204
+ date: string;
205
+ image: string | null;
206
+ messages: Array<{
207
+ title: string;
208
+ body: string;
209
+ image: string;
210
+ adspace: string | null;
211
+ }>;
212
+ };
213
+ stw: {
214
+ hash: string;
215
+ date: string;
216
+ messages: Array<{
217
+ title: string;
218
+ body: string;
219
+ image: string;
220
+ adspace: string | null;
221
+ }>;
222
+ };
223
+ creative: {
224
+ hash: string;
225
+ date: string;
226
+ messages: Array<{
227
+ title: string;
228
+ body: string;
229
+ image: string;
230
+ adspace: string | null;
231
+ }>;
232
+ };
233
+ }
234
+
235
+ export interface PlaylistResponse {
236
+ id: string;
237
+ name: string;
238
+ description: string;
239
+ gameType: string;
240
+ ratingType: string;
241
+ minPlayers: number;
242
+ maxPlayers: number;
243
+ maxTeams: number;
244
+ maxTeamSize: number;
245
+ maxSquads: number;
246
+ maxSquadSize: number;
247
+ images: {
248
+ showcase: string | null;
249
+ missionIcon: string | null;
250
+ };
251
+ }
252
+
253
+ export interface ShopResponse {
254
+ hash: string;
255
+ date: string;
256
+ vbuckIcon: string;
257
+ featured: ShopSection;
258
+ daily: ShopSection;
259
+ specialFeatured: ShopSection;
260
+ specialDaily: ShopSection;
261
+ votes: ShopSection;
262
+ voteWinners: ShopSection;
263
+ }
264
+
265
+ interface ShopSection {
266
+ name: string;
267
+ entries: Array<{
268
+ regularPrice: number;
269
+ finalPrice: number;
270
+ bundle: {
271
+ name: string;
272
+ info: string;
273
+ image: string;
274
+ } | null;
275
+ banner: {
276
+ value: string;
277
+ intensity: string;
278
+ backendValue: string;
279
+ } | null;
280
+ giftable: boolean;
281
+ refundable: boolean;
282
+ sortPriority: number;
283
+ categories: string[];
284
+ sectionId: string;
285
+ section: {
286
+ id: string;
287
+ name: string;
288
+ index: number;
289
+ };
290
+ devName: string;
291
+ offerId: string;
292
+ displayAssetPath: string;
293
+ tileSize: string;
294
+ newDisplayAssetPath: string;
295
+ }>;
296
+ }
297
+
298
+ export class Aes {
299
+ constructor(client: ApiClient);
300
+ getKeys(): Promise<AesResponse>;
301
+ }
302
+
303
+ export class Banners {
304
+ constructor(client: ApiClient);
305
+ getBanners(): Promise<BannerResponse[]>;
306
+ getColors(): Promise<BannerColorResponse[]>;
307
+ }
308
+
309
+ export class Map {
310
+ constructor(client: ApiClient);
311
+ get(): Promise<MapResponse>;
312
+ }
313
+
314
+ export class News {
315
+ constructor(client: ApiClient);
316
+ get(): Promise<NewsResponse>;
317
+ }
318
+
319
+ export class Playlists {
320
+ constructor(client: ApiClient);
321
+ getPlaylists(): Promise<PlaylistResponse[]>;
322
+ getPlaylist(id: string): Promise<PlaylistResponse>;
323
+ }
324
+
325
+ export class Shop {
326
+ constructor(client: ApiClient);
327
+ get(): Promise<ShopResponse>;
328
+ }
329
+
330
+ export class ApiClient {
331
+ constructor(options?: ApiClientOptions);
332
+ stats: Stats;
333
+ sac: CreatorCode;
334
+ cosmetics: Cosmetics;
335
+ aes: Aes;
336
+ map: Map;
337
+ news: News;
338
+ playlists: Playlists;
339
+ shop: Shop;
340
+ banners: Banners;
341
+
342
+ request(method: string, path: string, data?: any, options?: {
343
+ headers?: Record<string, string>;
344
+ params?: Record<string, any>;
345
+ }): Promise<any>;
346
+ }
347
+
348
+ export class Response {
349
+ constructor(status: number, headers: Record<string, string>, data: any);
350
+ status(): number;
351
+ headers(): Record<string, string>;
352
+ body(): any;
353
+ isSuccess(): boolean;
354
+ }
355
+
356
+ export class AccountType {
357
+ static EPIC: string;
358
+ static PSN: string;
359
+ static XBL: string;
360
+ static epic(): string;
361
+ static psn(): string;
362
+ static xbl(): string;
363
+ }
364
+
365
+ export class CosmeticType {
366
+ static OUTFIT: string;
367
+ static BACKPACK: string;
368
+ static PICKAXE: string;
369
+ static GLIDER: string;
370
+ static EMOTE: string;
371
+ static EMOJI: string;
372
+ static LOADING: string;
373
+ static WRAP: string;
374
+ static BANNER: string;
375
+ static CONTRAIL: string;
376
+ static SPRAY: string;
377
+ static TOY: string;
378
+ static MUSIC: string;
379
+ static PET: string;
380
+ static BUNDLE: string;
381
+ static TRACK: string;
382
+ static INSTRUMENT: string;
383
+ static CAR: string;
384
+ static LEGO: string;
385
+ static LEGOKIT: string;
386
+ static BEAN: string;
387
+
388
+ static outfit(): string;
389
+ static backpack(): string;
390
+ static pickaxe(): string;
391
+ static glider(): string;
392
+ static emote(): string;
393
+ static emoji(): string;
394
+ static loading(): string;
395
+ static wrap(): string;
396
+ static banner(): string;
397
+ static contrail(): string;
398
+ static spray(): string;
399
+ static toy(): string;
400
+ static music(): string;
401
+ static pet(): string;
402
+ static bundle(): string;
403
+ static track(): string;
404
+ static instrument(): string;
405
+ static car(): string;
406
+ static lego(): string;
407
+ static legokit(): string;
408
+ static bean(): string;
409
+ }
410
+
411
+ export class Language {
412
+ static AR: string;
413
+ static DE: string;
414
+ static EN: string;
415
+ static ES: string;
416
+ static ES_419: string;
417
+ static FR: string;
418
+ static IT: string;
419
+ static JA: string;
420
+ static KO: string;
421
+ static PL: string;
422
+ static PT_BR: string;
423
+ static RU: string;
424
+ static TR: string;
425
+ static ZH_CN: string;
426
+ static ZH_HANT: string;
427
+
428
+ static ar(): string;
429
+ static de(): string;
430
+ static en(): string;
431
+ static es(): string;
432
+ static es419(): string;
433
+ static fr(): string;
434
+ static it(): string;
435
+ static ja(): string;
436
+ static ko(): string;
437
+ static pl(): string;
438
+ static ptBr(): string;
439
+ static ru(): string;
440
+ static tr(): string;
441
+ static zhCn(): string;
442
+ static zhHant(): string;
443
+ }
444
+
445
+ export class MatchMethod {
446
+ static FULL: string;
447
+ static CONTAINS: string;
448
+ static STARTS: string;
449
+ static ENDS: string;
450
+
451
+ static full(): string;
452
+ static exact(): string;
453
+ static contains(): string;
454
+ static starts(): string;
455
+ static ends(): string;
456
+ }
457
+
458
+ export class RequestFlags {
459
+ static FLAGS: {
460
+ NONE: number;
461
+ INCLUDE_PATHS: number;
462
+ INCLUDE_STATS: number;
463
+ INCLUDE_SHOP_HISTORY: number;
464
+ };
465
+
466
+ static multiple(...flags: number[]): string;
467
+ static hasFlag(value: number | string, flag: number): boolean;
468
+ static getSetFlags(value: number | string): string[];
469
+ static all(): string;
470
+ static none(): number;
471
+ static safeGet(obj: any, path: string, defaultValue?: any): any;
472
+ }
473
+
474
+ export class StatsImage {
475
+ static ALL: string;
476
+ static KEYBOARD_MOUSE: string;
477
+ static GAMEPAD: string;
478
+ static TOUCH: string;
479
+
480
+ static all(): string;
481
+ static keyboardMouse(): string;
482
+ static gamepad(): string;
483
+ static touch(): string;
484
+ }
485
+
486
+ export class TimeWindow {
487
+ static LIFETIME: string;
488
+ static SEASON: string;
489
+
490
+ static lifetime(): string;
491
+ static season(): string;
492
+ }
493
+
494
+ export class Enums {
495
+ static accountType: typeof AccountType;
496
+ static cosmeticType: typeof CosmeticType;
497
+ static language: typeof Language;
498
+ static matchMethod: typeof MatchMethod;
499
+ static requestFlags: typeof RequestFlags;
500
+ static statsImage: typeof StatsImage;
501
+ static timeWindow: typeof TimeWindow;
502
+ }
503
+ }
package/src/index.js ADDED
@@ -0,0 +1,13 @@
1
+ import ApiClient from './client/ApiClient.js';
2
+ import Response from './http/Response.js';
3
+ import RequestFlags from './enums/requestFlags.js';
4
+ import Enums from './utils/Enums.js';
5
+ import SearchOptions from './types/SearchOptions.js';
6
+
7
+ export {
8
+ ApiClient,
9
+ Response,
10
+ RequestFlags,
11
+ Enums,
12
+ SearchOptions
13
+ };
@@ -0,0 +1,50 @@
1
+ class SearchOptions {
2
+ constructor() {
3
+ this.params = {};
4
+ }
5
+
6
+ setLanguage(lang) { this.params.language = lang; return this; }
7
+ setSearchLanguage(lang) { this.params.searchLanguage = lang; return this; }
8
+ setMatchMethod(method) { this.params.matchMethod = method; return this; }
9
+ setId(id) { this.params.id = id; return this; }
10
+ setName(name) { this.params.name = name; return this; }
11
+ setDescription(desc) { this.params.description = desc; return this; }
12
+ setType(type) { this.params.type = type; return this; }
13
+ setDisplayType(type) { this.params.displayType = type; return this; }
14
+ setBackendType(type) { this.params.backendType = type; return this; }
15
+ setRarity(rarity) { this.params.rarity = rarity; return this; }
16
+ setDisplayRarity(rarity) { this.params.displayRarity = rarity; return this; }
17
+ setBackendRarity(rarity) { this.params.backendRarity = rarity; return this; }
18
+ setHasSeries(has) { this.params.hasSeries = has; return this; }
19
+ setSeries(series) { this.params.series = series; return this; }
20
+ setBackendSeries(series) { this.params.backendSeries = series; return this; }
21
+ setHasSet(has) { this.params.hasSet = has; return this; }
22
+ setSet(set) { this.params.set = set; return this; }
23
+ setSetText(text) { this.params.setText = text; return this; }
24
+ setBackendSet(set) { this.params.backendSet = set; return this; }
25
+ setHasIntroduction(has) { this.params.hasIntroduction = has; return this; }
26
+ setBackendIntroduction(value) { this.params.backendIntroduction = value; return this; }
27
+ setIntroductionChapter(chapter) { this.params.introductionChapter = chapter; return this; }
28
+ setIntroductionSeason(season) { this.params.introductionSeason = season; return this; }
29
+ setHasFeaturedImage(has) { this.params.hasFeaturedImage = has; return this; }
30
+ setHasVariants(has) { this.params.hasVariants = has; return this; }
31
+ setHasGameplayTags(has) { this.params.hasGameplayTags = has; return this; }
32
+ setGameplayTag(tag) { this.params.gameplayTag = tag; return this; }
33
+ setHasMetaTags(has) { this.params.hasMetaTags = has; return this; }
34
+ setMetaTag(tag) { this.params.metaTag = tag; return this; }
35
+ setHasDynamicPakId(has) { this.params.hasDynamicPakId = has; return this; }
36
+ setDynamicPakId(id) { this.params.dynamicPakId = id; return this; }
37
+ setAdded(timestamp) { this.params.added = timestamp; return this; }
38
+ setAddedSince(timestamp) { this.params.addedSince = timestamp; return this; }
39
+ setUnseenFor(duration) { this.params.unseenFor = duration; return this; }
40
+ setLastAppearance(timestamp) { this.params.lastAppearance = timestamp; return this; }
41
+
42
+ build() {
43
+ return Object.fromEntries(
44
+ Object.entries(this.params)
45
+ .filter(([_, value]) => value !== undefined)
46
+ );
47
+ }
48
+ }
49
+
50
+ export default SearchOptions;
@@ -0,0 +1,39 @@
1
+ import CosmeticType from '../enums/CosmeticType.js';
2
+ import Language from '../enums/Language.js';
3
+ import RequestFlags from '../enums/requestFlags.js';
4
+ import MatchMethod from '../enums/MatchMethod.js';
5
+ import AccountType from '../enums/AccountType.js';
6
+ import StatsImage from '../enums/StatsImage.js';
7
+ import TimeWindow from '../enums/TimeWindow.js';
8
+
9
+ class Enums {
10
+ static get cosmeticType() {
11
+ return CosmeticType;
12
+ }
13
+
14
+ static get requestFlags() {
15
+ return RequestFlags;
16
+ }
17
+
18
+ static get language() {
19
+ return Language;
20
+ }
21
+
22
+ static get matchMethod() {
23
+ return MatchMethod;
24
+ }
25
+
26
+ static get accountType() {
27
+ return AccountType;
28
+ }
29
+
30
+ static get statsImage() {
31
+ return StatsImage;
32
+ }
33
+
34
+ static get timeWindow() {
35
+ return TimeWindow;
36
+ }
37
+ }
38
+
39
+ export default Enums;