@yaelouuu/fortnite-api 4.0.0 → 4.2.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/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # Fortnite API SDK
2
2
 
3
- JavaScript/TypeScript SDK for the Fortnite API by Royal Arena.
3
+ Official JavaScript/TypeScript SDK for the Fortnite API by Royal Arena.
4
4
 
5
5
  ## Installation
6
6
 
@@ -10,7 +10,7 @@ npm install @yaelouuu/fortnite-api
10
10
 
11
11
  ## API Key
12
12
 
13
- Acquire your API Key by creating a Free Account here : https://api-fortnite.com
13
+ Acquire your API Key by creating a Free Account here: https://api-fortnite.com
14
14
 
15
15
  ## Quick Start
16
16
 
@@ -26,27 +26,502 @@ const shop = await client.shop.getCurrent();
26
26
 
27
27
  // Get tournament leaderboard
28
28
  const leaderboard = await client.tournaments.getLeaderboard({
29
- eventId: "epicgames_...",
30
- eventWindowId: "S37_...",
29
+ eventId: "epicgames_S37_BlitzCupsAllPlatforms_BR",
30
+ eventWindowId: "S37_BlitzCupsAllPlatforms_Event1_BR",
31
31
  page: 0,
32
32
  });
33
+ ```
34
+
35
+ ## Features
36
+
37
+ - ✅ Full TypeScript support with comprehensive type definitions
38
+ - ✅ Promise-based async/await API
39
+ - ✅ Automatic error handling with detailed error messages
40
+ - ✅ Support for all Fortnite API endpoints
41
+ - ✅ Built-in OAuth flow helpers
42
+ - ✅ Tree-shakeable for optimal bundle size
43
+
44
+ ---
45
+
46
+ ## 📚 API Resources
47
+
48
+ ### Shop
49
+
50
+ Access the Fortnite Item Shop and Battle Pass data.
51
+
52
+ ```typescript
53
+ // Get current item shop
54
+ const shop = await client.shop.getCurrent();
55
+
56
+ // Get current Battle Pass
57
+ const battlePass = await client.battlepass.getBattlePass();
58
+ ```
59
+
60
+ ---
61
+
62
+ ### Tournaments
63
+
64
+ Comprehensive tournament data including leaderboards, events, and eligibility tracking.
65
+
66
+ #### Get Current Events
67
+ ```typescript
68
+ const events = await client.tournaments.getCurrent();
69
+ ```
70
+
71
+ #### Get Tournament Leaderboard (V1)
72
+ ```typescript
73
+ const leaderboard = await client.tournaments.getLeaderboard({
74
+ eventId: "epicgames_S37_BlitzCupsAllPlatforms_BR",
75
+ eventWindowId: "S37_BlitzCupsAllPlatforms_Event1_BR",
76
+ page: 0,
77
+ });
78
+ ```
79
+
80
+ #### Get Tournament Leaderboard (V2) - **NEW**
81
+ Enhanced leaderboard endpoint with POST body for bulk team queries:
82
+
83
+ ```typescript
84
+ // Solo tournament - query multiple players
85
+ const leaderboard = await client.tournaments.getLeaderboardV2(
86
+ {
87
+ eventId: "epicgames_S37_BlitzCupsAllPlatforms_BR",
88
+ eventWindowId: "S37_BlitzCupsAllPlatforms_Event1_BR",
89
+ },
90
+ [
91
+ ["accountId1"],
92
+ ["accountId2"],
93
+ ["accountId3"],
94
+ ]
95
+ );
96
+
97
+ // Duo tournament
98
+ const duoLeaderboard = await client.tournaments.getLeaderboardV2(
99
+ {
100
+ eventId: "epicgames_S37_DuoCup_BR",
101
+ eventWindowId: "S37_DuoCup_Event1_BR",
102
+ },
103
+ [
104
+ ["player1Id", "player2Id"],
105
+ ["player3Id", "player4Id"],
106
+ ]
107
+ );
108
+ ```
109
+
110
+ #### Tournament Tracker
111
+ Track player participation history:
112
+
113
+ ```typescript
114
+ const tracker = await client.tournaments.getTracker(
115
+ "accountId",
116
+ "fortniteToken"
117
+ );
118
+ // Returns: All tournaments the player has participated in
119
+ ```
120
+
121
+ #### Check Tournament Eligibility
122
+ Verify if a player meets requirements for major tournaments (e.g., 14 tournaments in 180 days):
123
+
124
+ ```typescript
125
+ const eligibility = await client.tournaments.checkEligibility(
126
+ "accountId",
127
+ "fortniteToken",
128
+ {
129
+ days: 180,
130
+ requiredTournaments: 14,
131
+ }
132
+ );
133
+
134
+ console.log(eligibility.eligible); // true/false
135
+ console.log(eligibility.tournaments_remaining); // How many more needed
136
+ ```
137
+
138
+ #### Download Events
139
+ Get personalized event data:
140
+
141
+ ```typescript
142
+ const events = await client.tournaments.download(
143
+ {
144
+ accountId: "your-account-id",
145
+ region: "EU",
146
+ platform: "Windows",
147
+ },
148
+ "fortniteToken"
149
+ );
150
+ ```
151
+
152
+ ---
153
+
154
+ ### Quests - **NEW**
33
155
 
34
- // Get profile stats
35
- const stats = await client.profiles.getStats("PlayerName");
156
+ Access player quest progress, XP, and account level information.
36
157
 
37
- // Get season info
158
+ ```typescript
159
+ // Get quest data for an account
160
+ const quests = await client.quests.getQuests(
161
+ "accountId",
162
+ "fortniteToken"
163
+ );
164
+
165
+ // Returns comprehensive data:
166
+ // - Active quest progress
167
+ // - Account XP and level
168
+ // - Playtime statistics
169
+ // - Quest rewards
170
+ ```
171
+
172
+ **Authentication Required**: User's personal Fortnite OAuth token
173
+
174
+ ---
175
+
176
+ ### Profiles
177
+
178
+ Player profile information and statistics.
179
+
180
+ ```typescript
181
+ // Get profile by display name
182
+ const profile = await client.profiles.getByName("PlayerName");
183
+
184
+ // Get profile statistics
185
+ const stats = await client.profiles.getStats("accountId");
186
+ ```
187
+
188
+ ---
189
+
190
+ ### Calendar
191
+
192
+ Fortnite in-game calendar and season information.
193
+
194
+ ```typescript
195
+ // Get current season info
38
196
  const season = await client.calendar.getCurrentSeason();
197
+
198
+ // Returns: Season number, start/end dates, and more
39
199
  ```
40
200
 
41
- ## Features
201
+ ---
42
202
 
43
- - ✅ Full TypeScript support
44
- - ✅ Promise-based async/await API
45
- - Automatic error handling
46
- - ✅ Built-in retry logic (optional)
47
- - ✅ Tree-shakeable
203
+ ### Bundles
204
+
205
+ Fortnite game asset bundles and cosmetics.
206
+
207
+ ```typescript
208
+ // Get all available bundles
209
+ const bundles = await client.bundles.getAll();
210
+ ```
211
+
212
+ ---
213
+
214
+ ### Weapons
215
+
216
+ Comprehensive weapon data including stats and metadata.
217
+
218
+ ```typescript
219
+ // Get all weapons
220
+ const weapons = await client.weapons.getAll();
221
+
222
+ // Includes: Damage, fire rate, reload time, rarity, and more
223
+ ```
224
+
225
+ ---
226
+
227
+ ### OAuth
228
+
229
+ OAuth authentication flow helpers for obtaining user tokens.
230
+
231
+ ```typescript
232
+ // Start OAuth flow
233
+ const flow = await client.oauth.startFlow();
234
+ console.log(flow.verificationUri); // Show this URL to the user
235
+
236
+ // Complete OAuth flow
237
+ const authData = await client.oauth.completeFlow(flow.flowId);
238
+ console.log(authData.accessToken); // User's Fortnite token
239
+ console.log(authData.deviceAuth); // Device auth credentials
240
+
241
+ // Refresh token
242
+ const refreshed = await client.oauth.refreshToken(authData.refreshToken);
243
+ ```
244
+
245
+ ---
246
+
247
+ ### Parsing
248
+
249
+ Parse Fortnite replay files to extract match data.
250
+
251
+ ```typescript
252
+ // Parse a single replay file
253
+ const replayData = await client.parsing.parseReplay(fileBuffer);
254
+
255
+ // Parse multiple replays
256
+ const batchResults = await client.parsing.parseBatch([file1, file2, file3]);
257
+ ```
258
+
259
+ ---
260
+
261
+ ### Account - **NEW**
262
+
263
+ Comprehensive account lookup and management with cross-platform support.
264
+
265
+ #### Lookup by Account ID
266
+ ```typescript
267
+ const account = await client.account.getById('accountId123');
268
+ // Returns: { id, displayName, externalAuths }
269
+ ```
270
+
271
+ #### Lookup by Display Name
272
+ ```typescript
273
+ const account = await client.account.getByDisplayName('Ninja');
274
+ // Returns: Epic account information
275
+ ```
276
+
277
+ #### Cross-Platform Lookup
278
+ Search for accounts by platform usernames (PSN, Xbox, Steam, Nintendo, Twitch, GitHub):
279
+
280
+ ```typescript
281
+ // Find by PSN username
282
+ const account = await client.account.getByExternalDisplayName(
283
+ 'psn',
284
+ 'PSN_Username',
285
+ true // case insensitive
286
+ );
287
+
288
+ // Find by Xbox gamertag
289
+ const xboxAccount = await client.account.getByExternalDisplayName(
290
+ 'xbl',
291
+ 'Xbox_Gamertag',
292
+ false // case sensitive
293
+ );
294
+ ```
295
+
296
+ **Supported Platforms:**
297
+ - `psn` - PlayStation Network
298
+ - `xbl` - Xbox Live
299
+ - `steam` - Steam
300
+ - `nintendo` - Nintendo Switch
301
+ - `twitch` - Twitch
302
+ - `github` - GitHub
303
+
304
+ #### Bulk Operations
305
+ Process multiple accounts efficiently:
306
+
307
+ ```typescript
308
+ // Bulk account lookup (max 100)
309
+ const accounts = await client.account.getBulk([
310
+ 'accountId1',
311
+ 'accountId2',
312
+ 'accountId3'
313
+ ]);
314
+
315
+ // Bulk external display name lookup
316
+ const accounts = await client.account.getBulkExternalDisplayNames({
317
+ lookups: [
318
+ { externalAuthType: 'psn', displayName: 'PSNUser1' },
319
+ { externalAuthType: 'xbl', displayName: 'XboxUser1' },
320
+ { externalAuthType: 'steam', displayName: 'SteamUser1' }
321
+ ]
322
+ });
323
+
324
+ // Bulk external ID lookup
325
+ const accounts = await client.account.getBulkExternalIds({
326
+ lookups: [
327
+ { externalAuthType: 'psn', externalId: 'psn-id-123' },
328
+ { externalAuthType: 'xbl', externalId: 'xbl-id-456' }
329
+ ]
330
+ });
331
+ ```
332
+
333
+ #### External Authentications
334
+ Get platform connection information:
335
+
336
+ ```typescript
337
+ // List all linked platforms
338
+ const auths = await client.account.getExternalAuths('accountId123');
339
+ // Returns: Array of all connected platforms
340
+
341
+ // Get specific platform connection
342
+ const psnAuth = await client.account.getExternalAuth('accountId123', 'psn');
343
+ // Returns: PSN-specific connection details
344
+ ```
345
+
346
+ ---
347
+
348
+ ### FN (Fortnite Game) - **NEW**
349
+
350
+ Fortnite-specific game data including inventory, features, and settings.
351
+
352
+ #### Battle Royale Inventory
353
+ Get player V-Bucks and in-game currency:
354
+
355
+ ```typescript
356
+ const inventory = await client.fn.getBRInventory('accountId123');
357
+ // Returns: { stash: { globalcash: 1250 } }
358
+ console.log(`Player has ${inventory.stash.globalcash} V-Bucks`);
359
+ ```
360
+
361
+ #### Storefront Keychain
362
+ Get encryption keys for storefront data:
363
+
364
+ ```typescript
365
+ const keychain = await client.fn.getKeychain();
366
+ // Returns: Storefront encryption keychain
367
+ ```
368
+
369
+ #### Purchase Receipts
370
+ Get player purchase history:
371
+
372
+ ```typescript
373
+ const receipts = await client.fn.getReceipts('accountId123');
374
+ // Returns: Array of purchase receipts
375
+ ```
376
+
377
+ #### Enabled Features
378
+ Get currently active game features:
379
+
380
+ ```typescript
381
+ const features = await client.fn.getEnabledFeatures();
382
+ // Returns: Currently enabled game features
383
+ ```
384
+
385
+ #### Version Check
386
+ Validate game client version:
387
+
388
+ ```typescript
389
+ const versionCheck = await client.fn.checkVersion(
390
+ 'Windows',
391
+ '++Fortnite+Release-30.40-CL-35235494-Windows'
392
+ );
393
+ // Returns: { type: 'NO_UPDATE' } or update information
394
+ ```
395
+
396
+ #### Privacy Settings (Requires User Token)
397
+ Manage player privacy settings:
398
+
399
+ ```typescript
400
+ // Get privacy settings
401
+ const privacy = await client.fn.getPrivacySettings(
402
+ 'accountId123',
403
+ 'fortniteToken'
404
+ );
405
+
406
+ // Update privacy settings
407
+ await client.fn.updatePrivacySettings(
408
+ 'accountId123',
409
+ {
410
+ optOutOfPublicLeaderboards: true
411
+ },
412
+ 'fortniteToken'
413
+ );
414
+ ```
415
+
416
+ #### Entitlement (Requires User Token)
417
+ Check and request Fortnite access:
418
+
419
+ ```typescript
420
+ // Check if user has Fortnite access
421
+ const check = await client.fn.checkEntitlement('fortniteToken');
422
+
423
+ // Request Fortnite access
424
+ await client.fn.requestEntitlement('accountId123', 'fortniteToken');
425
+ ```
426
+
427
+ ---
428
+
429
+ ## 🔐 Authentication
430
+
431
+ Some endpoints require user-specific authentication:
432
+
433
+ ### Endpoints Requiring User Token:
434
+ - `client.quests.getQuests()`
435
+ - `client.tournaments.getTracker()`
436
+ - `client.tournaments.checkEligibility()`
437
+ - `client.tournaments.download()`
438
+ - `client.fn.getPrivacySettings()`
439
+ - `client.fn.updatePrivacySettings()`
440
+ - `client.fn.checkEntitlement()`
441
+ - `client.fn.requestEntitlement()`
442
+
443
+ **How to obtain user tokens:**
444
+
445
+ 1. Use the OAuth flow:
446
+ ```typescript
447
+ const flow = await client.oauth.startFlow();
448
+ // Direct user to flow.verificationUri
449
+ const auth = await client.oauth.completeFlow(flow.flowId);
450
+ // Use auth.accessToken as the fortniteToken parameter
451
+ ```
452
+
453
+ ---
454
+
455
+ ## 🚀 Advanced Usage
456
+
457
+ ### Custom Base URL
458
+
459
+ ```typescript
460
+ const client = new FortniteAPI({
461
+ apiKey: "your-api-key",
462
+ baseUrl: "https://custom-api-url.com/api",
463
+ });
464
+ ```
465
+
466
+ ### Error Handling
467
+
468
+ ```typescript
469
+ import { FortniteAPIError } from "@yaelouuu/fortnite-api";
470
+
471
+ try {
472
+ const shop = await client.shop.getCurrent();
473
+ } catch (error) {
474
+ if (error instanceof FortniteAPIError) {
475
+ console.error(`API Error: ${error.message}`);
476
+ console.error(`Status Code: ${error.statusCode}`);
477
+ console.error(`Details:`, error.data);
478
+ }
479
+ }
480
+ ```
481
+
482
+ ---
483
+
484
+ ## 📖 Documentation
485
+
486
+ - **Full API Documentation (Swagger)**: https://documentation.api-fortnite.com/documentation
487
+ - **SDK Documentation**: https://sdk.api-fortnite.com/
488
+ - **Support**: https://api-fortnite.com
489
+
490
+ ---
491
+
492
+ ## 📝 License
493
+
494
+ MIT
495
+
496
+ ---
497
+
498
+ ## 🆕 Changelog
499
+
500
+ ### v4.2.0 (2026-01-06)
501
+ - ✨ **NEW** `AccountResource` with 8 methods:
502
+ - Account lookups by ID, display name, and external platforms
503
+ - Cross-platform search (PSN, Xbox, Steam, Nintendo, Twitch, GitHub)
504
+ - Bulk operations (up to 100 accounts)
505
+ - External authentication management
506
+ - ✨ **NEW** `FNResource` with 9 methods:
507
+ - BR inventory (V-Bucks)
508
+ - Storefront keychain
509
+ - Purchase receipts
510
+ - Enabled features
511
+ - Version checking
512
+ - Privacy settings management
513
+ - Entitlement checking
514
+ - 📝 Comprehensive TypeScript types for all new endpoints
515
+ - 🎯 Full JSDoc documentation
516
+ - ✅ 100% backward compatible
48
517
 
49
- ## Documentation
518
+ ### v4.1.0
519
+ - ✨ Added `WeaponsResource` with weapon stats and metadata
520
+ - 🐛 Various bug fixes and improvements
50
521
 
51
- Full API documentation (swagger): https://documentation.api-fortnite.com/documentation
52
- SDK documentation: https://sdk.api-fortnite.com/
522
+ ### v4.0.0
523
+ - Added `QuestsResource` with `getQuests()` method
524
+ - ✨ Added `getLeaderboardV2()` method to `TournamentsResource`
525
+ - 🐛 Fixed typo in `battlepass` property name
526
+ - 📝 Comprehensive JSDoc documentation for all resources
527
+ - 🎯 Full TypeScript type coverage
package/dist/client.d.ts CHANGED
@@ -7,6 +7,9 @@ import { OauthResource } from "./resources/oauth";
7
7
  import { ParsingResource } from "./resources/parsing";
8
8
  import { WeaponsResource } from "./resources/weapons";
9
9
  import { BattlePassResource } from "./resources/battlepass";
10
+ import { QuestsResource } from "./resources/quests";
11
+ import { AccountResource } from "./resources/account";
12
+ import { FNResource } from "./resources/fn";
10
13
  export interface ClientOptions {
11
14
  apiKey: string;
12
15
  baseUrl?: string;
@@ -22,7 +25,10 @@ export declare class FortniteAPI {
22
25
  oauth: OauthResource;
23
26
  parsing: ParsingResource;
24
27
  weapons: WeaponsResource;
25
- batttlepass: BattlePassResource;
28
+ battlepass: BattlePassResource;
29
+ quests: QuestsResource;
30
+ account: AccountResource;
31
+ fn: FNResource;
26
32
  constructor(options: ClientOptions);
27
33
  /**
28
34
  * Internal method to make HTTP requests
package/dist/client.js CHANGED
@@ -11,6 +11,9 @@ const oauth_1 = require("./resources/oauth");
11
11
  const parsing_1 = require("./resources/parsing");
12
12
  const weapons_1 = require("./resources/weapons");
13
13
  const battlepass_1 = require("./resources/battlepass");
14
+ const quests_1 = require("./resources/quests");
15
+ const account_1 = require("./resources/account");
16
+ const fn_1 = require("./resources/fn");
14
17
  class FortniteAPI {
15
18
  constructor(options) {
16
19
  this.apiKey = options.apiKey;
@@ -25,7 +28,10 @@ class FortniteAPI {
25
28
  this.oauth = new oauth_1.OauthResource(this);
26
29
  this.parsing = new parsing_1.ParsingResource(this);
27
30
  this.weapons = new weapons_1.WeaponsResource(this);
28
- this.batttlepass = new battlepass_1.BattlePassResource(this);
31
+ this.battlepass = new battlepass_1.BattlePassResource(this);
32
+ this.quests = new quests_1.QuestsResource(this);
33
+ this.account = new account_1.AccountResource(this);
34
+ this.fn = new fn_1.FNResource(this);
29
35
  }
30
36
  /**
31
37
  * Internal method to make HTTP requests
package/dist/errors.d.ts CHANGED
File without changes
package/dist/errors.js CHANGED
File without changes
package/dist/index.d.ts CHANGED
File without changes
package/dist/index.js CHANGED
File without changes
@@ -0,0 +1,54 @@
1
+ import { FortniteAPI } from "../client";
2
+ import { Account, ExternalAuth, BulkExternalDisplayNameRequest, BulkExternalIdRequest } from "../types";
3
+ export declare class AccountResource {
4
+ private client;
5
+ constructor(client: FortniteAPI);
6
+ /**
7
+ * Lookup account by Account ID
8
+ * @param accountId - Epic Games account ID
9
+ * @param fortniteToken - Optional user Fortnite token
10
+ */
11
+ getById(accountId: string, fortniteToken?: string): Promise<Account>;
12
+ /**
13
+ * Bulk account lookup by Account IDs
14
+ * @param accountIds - Array of Epic Games account IDs (max 100)
15
+ */
16
+ getBulk(accountIds: string[]): Promise<Account[]>;
17
+ /**
18
+ * Lookup account by Epic display name
19
+ * @param displayName - Epic Games display name
20
+ * @param fortniteToken - Optional user Fortnite token
21
+ */
22
+ getByDisplayName(displayName: string, fortniteToken?: string): Promise<Account>;
23
+ /**
24
+ * Cross-platform account lookup by external display name
25
+ * @param platform - Platform type (psn, xbl, steam, nintendo, twitch, github)
26
+ * @param displayName - Platform display name
27
+ * @param caseInsensitive - Case-insensitive search (default: false)
28
+ * @param fortniteToken - Optional user Fortnite token
29
+ */
30
+ getByExternalDisplayName(platform: string, displayName: string, caseInsensitive?: boolean, fortniteToken?: string): Promise<Account>;
31
+ /**
32
+ * Bulk external display name lookup
33
+ * @param payload - Array of platform/displayName pairs (max 100)
34
+ */
35
+ getBulkExternalDisplayNames(payload: BulkExternalDisplayNameRequest): Promise<Account[]>;
36
+ /**
37
+ * Bulk external ID lookup
38
+ * @param payload - Array of platform/externalId pairs (max 100)
39
+ */
40
+ getBulkExternalIds(payload: BulkExternalIdRequest): Promise<Account[]>;
41
+ /**
42
+ * Get all external authentications for an account
43
+ * @param accountId - Epic Games account ID
44
+ * @param fortniteToken - Optional user Fortnite token
45
+ */
46
+ getExternalAuths(accountId: string, fortniteToken?: string): Promise<ExternalAuth[]>;
47
+ /**
48
+ * Get specific external authentication for an account
49
+ * @param accountId - Epic Games account ID
50
+ * @param platform - Platform type (psn, xbl, steam, nintendo, twitch, github)
51
+ * @param fortniteToken - Optional user Fortnite token
52
+ */
53
+ getExternalAuth(accountId: string, platform: string, fortniteToken?: string): Promise<ExternalAuth>;
54
+ }
@@ -0,0 +1,103 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.AccountResource = void 0;
4
+ class AccountResource {
5
+ constructor(client) {
6
+ this.client = client;
7
+ }
8
+ /**
9
+ * Lookup account by Account ID
10
+ * @param accountId - Epic Games account ID
11
+ * @param fortniteToken - Optional user Fortnite token
12
+ */
13
+ async getById(accountId, fortniteToken) {
14
+ const headers = {};
15
+ if (fortniteToken) {
16
+ headers["x-fortnite-token"] = fortniteToken;
17
+ }
18
+ return this.client.request(`/account/${accountId}`, { headers }, "v1");
19
+ }
20
+ /**
21
+ * Bulk account lookup by Account IDs
22
+ * @param accountIds - Array of Epic Games account IDs (max 100)
23
+ */
24
+ async getBulk(accountIds) {
25
+ const queryString = accountIds
26
+ .map((id) => `accountId=${encodeURIComponent(id)}`)
27
+ .join("&");
28
+ return this.client.request(`/account/bulk?${queryString}`, {}, "v1");
29
+ }
30
+ /**
31
+ * Lookup account by Epic display name
32
+ * @param displayName - Epic Games display name
33
+ * @param fortniteToken - Optional user Fortnite token
34
+ */
35
+ async getByDisplayName(displayName, fortniteToken) {
36
+ const headers = {};
37
+ if (fortniteToken) {
38
+ headers["x-fortnite-token"] = fortniteToken;
39
+ }
40
+ return this.client.request(`/account/displayName/${encodeURIComponent(displayName)}`, { headers }, "v1");
41
+ }
42
+ /**
43
+ * Cross-platform account lookup by external display name
44
+ * @param platform - Platform type (psn, xbl, steam, nintendo, twitch, github)
45
+ * @param displayName - Platform display name
46
+ * @param caseInsensitive - Case-insensitive search (default: false)
47
+ * @param fortniteToken - Optional user Fortnite token
48
+ */
49
+ async getByExternalDisplayName(platform, displayName, caseInsensitive = false, fortniteToken) {
50
+ const headers = {};
51
+ if (fortniteToken) {
52
+ headers["x-fortnite-token"] = fortniteToken;
53
+ }
54
+ const query = caseInsensitive ? "?caseInsensitive=true" : "";
55
+ return this.client.request(`/account/external/${platform}/displayName/${encodeURIComponent(displayName)}${query}`, { headers }, "v1");
56
+ }
57
+ /**
58
+ * Bulk external display name lookup
59
+ * @param payload - Array of platform/displayName pairs (max 100)
60
+ */
61
+ async getBulkExternalDisplayNames(payload) {
62
+ return this.client.request(`/account/external/displayNames/bulk`, {
63
+ method: "POST",
64
+ body: JSON.stringify(payload),
65
+ }, "v1");
66
+ }
67
+ /**
68
+ * Bulk external ID lookup
69
+ * @param payload - Array of platform/externalId pairs (max 100)
70
+ */
71
+ async getBulkExternalIds(payload) {
72
+ return this.client.request(`/account/external/ids/bulk`, {
73
+ method: "POST",
74
+ body: JSON.stringify(payload),
75
+ }, "v1");
76
+ }
77
+ /**
78
+ * Get all external authentications for an account
79
+ * @param accountId - Epic Games account ID
80
+ * @param fortniteToken - Optional user Fortnite token
81
+ */
82
+ async getExternalAuths(accountId, fortniteToken) {
83
+ const headers = {};
84
+ if (fortniteToken) {
85
+ headers["x-fortnite-token"] = fortniteToken;
86
+ }
87
+ return this.client.request(`/account/${accountId}/externalAuths`, { headers }, "v1");
88
+ }
89
+ /**
90
+ * Get specific external authentication for an account
91
+ * @param accountId - Epic Games account ID
92
+ * @param platform - Platform type (psn, xbl, steam, nintendo, twitch, github)
93
+ * @param fortniteToken - Optional user Fortnite token
94
+ */
95
+ async getExternalAuth(accountId, platform, fortniteToken) {
96
+ const headers = {};
97
+ if (fortniteToken) {
98
+ headers["x-fortnite-token"] = fortniteToken;
99
+ }
100
+ return this.client.request(`/account/${accountId}/externalAuths/${platform}`, { headers }, "v1");
101
+ }
102
+ }
103
+ exports.AccountResource = AccountResource;
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
@@ -0,0 +1,56 @@
1
+ import { FortniteAPI } from "../client";
2
+ import { BRInventory, Keychain, Receipt, EnabledFeatures, VersionCheck, PrivacySettings, EntitlementCheck } from "../types";
3
+ export declare class FNResource {
4
+ private client;
5
+ constructor(client: FortniteAPI);
6
+ /**
7
+ * Get Battle Royale inventory (V-Bucks and currency)
8
+ * @param accountId - Epic Games account ID
9
+ * @param fortniteToken - Optional user Fortnite token
10
+ */
11
+ getBRInventory(accountId: string, fortniteToken?: string): Promise<BRInventory>;
12
+ /**
13
+ * Get storefront encryption keychain
14
+ */
15
+ getKeychain(): Promise<Keychain>;
16
+ /**
17
+ * Get purchase receipts for an account
18
+ * @param accountId - Epic Games account ID
19
+ * @param fortniteToken - Optional user Fortnite token
20
+ */
21
+ getReceipts(accountId: string, fortniteToken?: string): Promise<Receipt[]>;
22
+ /**
23
+ * Get currently enabled game features
24
+ */
25
+ getEnabledFeatures(): Promise<EnabledFeatures>;
26
+ /**
27
+ * Check game version
28
+ * @param platform - Platform name (Windows, Mac, etc.)
29
+ * @param version - Version string to check
30
+ */
31
+ checkVersion(platform: string, version: string): Promise<VersionCheck>;
32
+ /**
33
+ * Get privacy settings for an account (requires user token)
34
+ * @param accountId - Epic Games account ID
35
+ * @param fortniteToken - User Fortnite token (required)
36
+ */
37
+ getPrivacySettings(accountId: string, fortniteToken: string): Promise<PrivacySettings>;
38
+ /**
39
+ * Update privacy settings for an account (requires user token)
40
+ * @param accountId - Epic Games account ID
41
+ * @param settings - Privacy settings to update
42
+ * @param fortniteToken - User Fortnite token (required)
43
+ */
44
+ updatePrivacySettings(accountId: string, settings: Partial<PrivacySettings>, fortniteToken: string): Promise<PrivacySettings>;
45
+ /**
46
+ * Check Fortnite entitlement (requires user token)
47
+ * @param fortniteToken - User Fortnite token (required)
48
+ */
49
+ checkEntitlement(fortniteToken: string): Promise<EntitlementCheck>;
50
+ /**
51
+ * Request Fortnite entitlement access (requires user token)
52
+ * @param accountId - Epic Games account ID
53
+ * @param fortniteToken - User Fortnite token (required)
54
+ */
55
+ requestEntitlement(accountId: string, fortniteToken: string): Promise<void>;
56
+ }
@@ -0,0 +1,104 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.FNResource = void 0;
4
+ class FNResource {
5
+ constructor(client) {
6
+ this.client = client;
7
+ }
8
+ /**
9
+ * Get Battle Royale inventory (V-Bucks and currency)
10
+ * @param accountId - Epic Games account ID
11
+ * @param fortniteToken - Optional user Fortnite token
12
+ */
13
+ async getBRInventory(accountId, fortniteToken) {
14
+ const headers = {};
15
+ if (fortniteToken) {
16
+ headers["x-fortnite-token"] = fortniteToken;
17
+ }
18
+ return this.client.request(`/fn/br-inventory/${accountId}`, { headers }, "v2");
19
+ }
20
+ /**
21
+ * Get storefront encryption keychain
22
+ */
23
+ async getKeychain() {
24
+ return this.client.request("/fn/keychain", {}, "v2");
25
+ }
26
+ /**
27
+ * Get purchase receipts for an account
28
+ * @param accountId - Epic Games account ID
29
+ * @param fortniteToken - Optional user Fortnite token
30
+ */
31
+ async getReceipts(accountId, fortniteToken) {
32
+ const headers = {};
33
+ if (fortniteToken) {
34
+ headers["x-fortnite-token"] = fortniteToken;
35
+ }
36
+ return this.client.request(`/fn/receipts/${accountId}`, { headers }, "v2");
37
+ }
38
+ /**
39
+ * Get currently enabled game features
40
+ */
41
+ async getEnabledFeatures() {
42
+ return this.client.request("/fn/enabled-features", {}, "v2");
43
+ }
44
+ /**
45
+ * Check game version
46
+ * @param platform - Platform name (Windows, Mac, etc.)
47
+ * @param version - Version string to check
48
+ */
49
+ async checkVersion(platform, version) {
50
+ return this.client.request(`/fn/version/${platform}?version=${encodeURIComponent(version)}`, {}, "v2");
51
+ }
52
+ /**
53
+ * Get privacy settings for an account (requires user token)
54
+ * @param accountId - Epic Games account ID
55
+ * @param fortniteToken - User Fortnite token (required)
56
+ */
57
+ async getPrivacySettings(accountId, fortniteToken) {
58
+ return this.client.request(`/fn/privacy/${accountId}`, {
59
+ headers: {
60
+ "x-fortnite-token": fortniteToken,
61
+ },
62
+ }, "v2");
63
+ }
64
+ /**
65
+ * Update privacy settings for an account (requires user token)
66
+ * @param accountId - Epic Games account ID
67
+ * @param settings - Privacy settings to update
68
+ * @param fortniteToken - User Fortnite token (required)
69
+ */
70
+ async updatePrivacySettings(accountId, settings, fortniteToken) {
71
+ return this.client.request(`/fn/privacy/${accountId}`, {
72
+ method: "POST",
73
+ headers: {
74
+ "x-fortnite-token": fortniteToken,
75
+ },
76
+ body: JSON.stringify(settings),
77
+ }, "v2");
78
+ }
79
+ /**
80
+ * Check Fortnite entitlement (requires user token)
81
+ * @param fortniteToken - User Fortnite token (required)
82
+ */
83
+ async checkEntitlement(fortniteToken) {
84
+ return this.client.request("/fn/entitlement", {
85
+ headers: {
86
+ "x-fortnite-token": fortniteToken,
87
+ },
88
+ }, "v2");
89
+ }
90
+ /**
91
+ * Request Fortnite entitlement access (requires user token)
92
+ * @param accountId - Epic Games account ID
93
+ * @param fortniteToken - User Fortnite token (required)
94
+ */
95
+ async requestEntitlement(accountId, fortniteToken) {
96
+ await this.client.request(`/fn/entitlement/${accountId}`, {
97
+ method: "POST",
98
+ headers: {
99
+ "x-fortnite-token": fortniteToken,
100
+ },
101
+ }, "v2");
102
+ }
103
+ }
104
+ exports.FNResource = FNResource;
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
@@ -0,0 +1,53 @@
1
+ import { FortniteAPI } from "../client";
2
+ import { QuestsResponse } from "../types";
3
+ /**
4
+ * QuestsResource provides access to Fortnite quests and account progression data
5
+ *
6
+ * This resource allows you to fetch player quest progress, XP, playtime, and account level.
7
+ * All methods require the user's personal Fortnite OAuth token obtained through the OAuth flow.
8
+ *
9
+ * @example
10
+ * ```typescript
11
+ * // Get quests for an account
12
+ * const quests = await client.quests.getQuests(
13
+ * "account-id-here",
14
+ * "user-fortnite-token-here"
15
+ * );
16
+ * ```
17
+ */
18
+ export declare class QuestsResource {
19
+ private client;
20
+ constructor(client: FortniteAPI);
21
+ /**
22
+ * Get account quests and level information
23
+ *
24
+ * Retrieves comprehensive quest data including:
25
+ * - Active quest progress and completion status
26
+ * - Account XP and level information
27
+ * - Total playtime statistics
28
+ * - Quest rewards and milestones
29
+ *
30
+ * **Authentication**: Requires user's personal Fortnite OAuth token
31
+ *
32
+ * **API Version**: v3
33
+ *
34
+ * **Rate Limit**: Standard API rate limits apply
35
+ *
36
+ * @param accountId - Epic Games Account ID (32 character hexadecimal string)
37
+ * @param fortniteToken - User's Fortnite access token obtained from OAuth flow
38
+ *
39
+ * @returns Promise resolving to quest progress, XP, playtime, and account level data
40
+ *
41
+ * @throws {FortniteAPIError} When the request fails (invalid token, account not found, etc.)
42
+ *
43
+ * @example
44
+ * ```typescript
45
+ * const accountId = "a1b2c3d4e5f6..."; // 32 character account ID
46
+ * const token = "eg1~..."; // User's Fortnite OAuth token
47
+ *
48
+ * const questData = await client.quests.getQuests(accountId, token);
49
+ * console.log(questData);
50
+ * ```
51
+ */
52
+ getQuests(accountId: string, fortniteToken: string): Promise<QuestsResponse>;
53
+ }
@@ -0,0 +1,62 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.QuestsResource = void 0;
4
+ /**
5
+ * QuestsResource provides access to Fortnite quests and account progression data
6
+ *
7
+ * This resource allows you to fetch player quest progress, XP, playtime, and account level.
8
+ * All methods require the user's personal Fortnite OAuth token obtained through the OAuth flow.
9
+ *
10
+ * @example
11
+ * ```typescript
12
+ * // Get quests for an account
13
+ * const quests = await client.quests.getQuests(
14
+ * "account-id-here",
15
+ * "user-fortnite-token-here"
16
+ * );
17
+ * ```
18
+ */
19
+ class QuestsResource {
20
+ constructor(client) {
21
+ this.client = client;
22
+ }
23
+ /**
24
+ * Get account quests and level information
25
+ *
26
+ * Retrieves comprehensive quest data including:
27
+ * - Active quest progress and completion status
28
+ * - Account XP and level information
29
+ * - Total playtime statistics
30
+ * - Quest rewards and milestones
31
+ *
32
+ * **Authentication**: Requires user's personal Fortnite OAuth token
33
+ *
34
+ * **API Version**: v3
35
+ *
36
+ * **Rate Limit**: Standard API rate limits apply
37
+ *
38
+ * @param accountId - Epic Games Account ID (32 character hexadecimal string)
39
+ * @param fortniteToken - User's Fortnite access token obtained from OAuth flow
40
+ *
41
+ * @returns Promise resolving to quest progress, XP, playtime, and account level data
42
+ *
43
+ * @throws {FortniteAPIError} When the request fails (invalid token, account not found, etc.)
44
+ *
45
+ * @example
46
+ * ```typescript
47
+ * const accountId = "a1b2c3d4e5f6..."; // 32 character account ID
48
+ * const token = "eg1~..."; // User's Fortnite OAuth token
49
+ *
50
+ * const questData = await client.quests.getQuests(accountId, token);
51
+ * console.log(questData);
52
+ * ```
53
+ */
54
+ async getQuests(accountId, fortniteToken) {
55
+ return this.client.request(`/quests/${accountId}`, {
56
+ headers: {
57
+ "x-fortnite-token": fortniteToken,
58
+ },
59
+ }, "v3");
60
+ }
61
+ }
62
+ exports.QuestsResource = QuestsResource;
File without changes
File without changes
@@ -66,4 +66,79 @@ export declare class TournamentsResource {
66
66
  days?: number;
67
67
  requiredTournaments?: number;
68
68
  }): Promise<TournamentEligibilityResponse>;
69
+ /**
70
+ * Get tournament leaderboard using V2 endpoint (POST with teams body)
71
+ *
72
+ * This is an enhanced version of the leaderboard endpoint that accepts a POST request
73
+ * with a teams array in the body. Use this endpoint when you need to query leaderboard
74
+ * data for multiple teams at once or for Ranked Cups that require specific team lookups.
75
+ *
76
+ * **Differences from V1**:
77
+ * - Uses POST method instead of GET
78
+ * - Accepts teams array in request body
79
+ * - Better suited for bulk team queries
80
+ * - Required for certain Ranked Cup leaderboards
81
+ *
82
+ * **Authentication**: Optional. Include fortniteToken for personalized leaderboard views
83
+ *
84
+ * **API Version**: v2
85
+ *
86
+ * **Rate Limit**: Standard API rate limits apply
87
+ *
88
+ * @param params - Leaderboard query parameters
89
+ * @param params.eventId - Event ID (e.g., "epicgames_S37_BlitzCupsAllPlatforms_BR")
90
+ * @param params.eventWindowId - Event window ID (e.g., "S37_BlitzCupsAllPlatforms_Event1_BR")
91
+ * @param params.leaderboardDef - Optional leaderboard definition ID (required for Ranked Cups with multiple leaderboards)
92
+ * @param teams - Array of team member account ID arrays. Each team is an array of account IDs.
93
+ * For solo events: [["accountId1"], ["accountId2"]]
94
+ * For duo events: [["player1Id", "player2Id"], ["player3Id", "player4Id"]]
95
+ * @param fortniteToken - Optional user's Fortnite access token for personalized leaderboard view
96
+ *
97
+ * @returns Promise resolving to leaderboard data with entries, ranks, and stats
98
+ *
99
+ * @throws {FortniteAPIError} When the request fails (invalid event, missing leaderboardDef, etc.)
100
+ *
101
+ * @example
102
+ * ```typescript
103
+ * // Get leaderboard for multiple solo players
104
+ * const leaderboard = await client.tournaments.getLeaderboardV2(
105
+ * {
106
+ * eventId: "epicgames_S37_BlitzCupsAllPlatforms_BR",
107
+ * eventWindowId: "S37_BlitzCupsAllPlatforms_Event1_BR"
108
+ * },
109
+ * [
110
+ * ["accountId1"],
111
+ * ["accountId2"],
112
+ * ["accountId3"]
113
+ * ]
114
+ * );
115
+ *
116
+ * // For duo tournament
117
+ * const duoLeaderboard = await client.tournaments.getLeaderboardV2(
118
+ * {
119
+ * eventId: "epicgames_S37_DuoCup_BR",
120
+ * eventWindowId: "S37_DuoCup_Event1_BR"
121
+ * },
122
+ * [
123
+ * ["player1Id", "player2Id"],
124
+ * ["player3Id", "player4Id"]
125
+ * ]
126
+ * );
127
+ *
128
+ * // For Ranked Cup with leaderboardDef
129
+ * const rankedLeaderboard = await client.tournaments.getLeaderboardV2(
130
+ * {
131
+ * eventId: "epicgames_S37_RankedCup_BR",
132
+ * eventWindowId: "S37_RankedCup_Event1_BR",
133
+ * leaderboardDef: "ranked_br_division_7"
134
+ * },
135
+ * [["accountId1"], ["accountId2"]]
136
+ * );
137
+ * ```
138
+ */
139
+ getLeaderboardV2(params: {
140
+ eventId: string;
141
+ eventWindowId: string;
142
+ leaderboardDef?: string;
143
+ }, teams: string[][], fortniteToken?: string): Promise<Leaderboard>;
69
144
  }
@@ -112,5 +112,94 @@ class TournamentsResource {
112
112
  },
113
113
  });
114
114
  }
115
+ /**
116
+ * Get tournament leaderboard using V2 endpoint (POST with teams body)
117
+ *
118
+ * This is an enhanced version of the leaderboard endpoint that accepts a POST request
119
+ * with a teams array in the body. Use this endpoint when you need to query leaderboard
120
+ * data for multiple teams at once or for Ranked Cups that require specific team lookups.
121
+ *
122
+ * **Differences from V1**:
123
+ * - Uses POST method instead of GET
124
+ * - Accepts teams array in request body
125
+ * - Better suited for bulk team queries
126
+ * - Required for certain Ranked Cup leaderboards
127
+ *
128
+ * **Authentication**: Optional. Include fortniteToken for personalized leaderboard views
129
+ *
130
+ * **API Version**: v2
131
+ *
132
+ * **Rate Limit**: Standard API rate limits apply
133
+ *
134
+ * @param params - Leaderboard query parameters
135
+ * @param params.eventId - Event ID (e.g., "epicgames_S37_BlitzCupsAllPlatforms_BR")
136
+ * @param params.eventWindowId - Event window ID (e.g., "S37_BlitzCupsAllPlatforms_Event1_BR")
137
+ * @param params.leaderboardDef - Optional leaderboard definition ID (required for Ranked Cups with multiple leaderboards)
138
+ * @param teams - Array of team member account ID arrays. Each team is an array of account IDs.
139
+ * For solo events: [["accountId1"], ["accountId2"]]
140
+ * For duo events: [["player1Id", "player2Id"], ["player3Id", "player4Id"]]
141
+ * @param fortniteToken - Optional user's Fortnite access token for personalized leaderboard view
142
+ *
143
+ * @returns Promise resolving to leaderboard data with entries, ranks, and stats
144
+ *
145
+ * @throws {FortniteAPIError} When the request fails (invalid event, missing leaderboardDef, etc.)
146
+ *
147
+ * @example
148
+ * ```typescript
149
+ * // Get leaderboard for multiple solo players
150
+ * const leaderboard = await client.tournaments.getLeaderboardV2(
151
+ * {
152
+ * eventId: "epicgames_S37_BlitzCupsAllPlatforms_BR",
153
+ * eventWindowId: "S37_BlitzCupsAllPlatforms_Event1_BR"
154
+ * },
155
+ * [
156
+ * ["accountId1"],
157
+ * ["accountId2"],
158
+ * ["accountId3"]
159
+ * ]
160
+ * );
161
+ *
162
+ * // For duo tournament
163
+ * const duoLeaderboard = await client.tournaments.getLeaderboardV2(
164
+ * {
165
+ * eventId: "epicgames_S37_DuoCup_BR",
166
+ * eventWindowId: "S37_DuoCup_Event1_BR"
167
+ * },
168
+ * [
169
+ * ["player1Id", "player2Id"],
170
+ * ["player3Id", "player4Id"]
171
+ * ]
172
+ * );
173
+ *
174
+ * // For Ranked Cup with leaderboardDef
175
+ * const rankedLeaderboard = await client.tournaments.getLeaderboardV2(
176
+ * {
177
+ * eventId: "epicgames_S37_RankedCup_BR",
178
+ * eventWindowId: "S37_RankedCup_Event1_BR",
179
+ * leaderboardDef: "ranked_br_division_7"
180
+ * },
181
+ * [["accountId1"], ["accountId2"]]
182
+ * );
183
+ * ```
184
+ */
185
+ async getLeaderboardV2(params, teams, fortniteToken) {
186
+ const query = new URLSearchParams({
187
+ eventId: params.eventId,
188
+ eventWindowId: params.eventWindowId,
189
+ });
190
+ if (params.leaderboardDef) {
191
+ query.append("leaderboardDef", params.leaderboardDef);
192
+ }
193
+ const options = {
194
+ method: "POST",
195
+ body: JSON.stringify({ teams }),
196
+ };
197
+ if (fortniteToken) {
198
+ options.headers = {
199
+ "x-fortnite-token": fortniteToken,
200
+ };
201
+ }
202
+ return this.client.request(`/events/leaderboard?${query.toString()}`, options, "v2");
203
+ }
115
204
  }
116
205
  exports.TournamentsResource = TournamentsResource;
File without changes
File without changes
@@ -289,3 +289,69 @@ export interface BattlePassOffers {
289
289
  offerVisual: string | null;
290
290
  tileSize: string;
291
291
  }
292
+ export interface QuestsResponse {
293
+ [key: string]: any;
294
+ }
295
+ export interface Account {
296
+ id: string;
297
+ displayName: string;
298
+ externalAuths?: Record<string, ExternalAuth>;
299
+ }
300
+ export interface ExternalAuth {
301
+ accountId: string;
302
+ type: string;
303
+ externalAuthId?: string;
304
+ externalDisplayName?: string;
305
+ authIds?: Array<{
306
+ id: string;
307
+ type: string;
308
+ }>;
309
+ }
310
+ export interface BulkExternalDisplayNameRequest {
311
+ lookups: Array<{
312
+ externalAuthType: string;
313
+ displayName: string;
314
+ }>;
315
+ }
316
+ export interface BulkExternalIdRequest {
317
+ lookups: Array<{
318
+ externalAuthType: string;
319
+ externalId: string;
320
+ }>;
321
+ }
322
+ export interface BRInventory {
323
+ stash?: {
324
+ globalcash?: number;
325
+ [key: string]: any;
326
+ };
327
+ [key: string]: any;
328
+ }
329
+ export interface Keychain {
330
+ keychain?: Array<{
331
+ key: string;
332
+ [key: string]: any;
333
+ }>;
334
+ [key: string]: any;
335
+ }
336
+ export interface Receipt {
337
+ receiptId: string;
338
+ purchaseDate: string;
339
+ offerId: string;
340
+ [key: string]: any;
341
+ }
342
+ export interface EnabledFeatures {
343
+ [key: string]: any;
344
+ }
345
+ export interface VersionCheck {
346
+ type: string;
347
+ [key: string]: any;
348
+ }
349
+ export interface PrivacySettings {
350
+ accountId?: string;
351
+ optOutOfPublicLeaderboards?: boolean;
352
+ [key: string]: any;
353
+ }
354
+ export interface EntitlementCheck {
355
+ entitlement?: boolean;
356
+ [key: string]: any;
357
+ }
File without changes
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@yaelouuu/fortnite-api",
3
- "version": "4.0.0",
3
+ "version": "4.2.0",
4
4
  "description": "SDK for Fortnite Tournaments API by Royal Arena - Author : Yael Brinkert",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",