@yaelouuu/fortnite-api 3.1.0 → 4.1.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/dist/client.d.ts +6 -2
- package/dist/client.js +9 -5
- package/dist/resources/battlepass.d.ts +10 -0
- package/dist/resources/battlepass.js +15 -0
- package/dist/resources/quests.d.ts +14 -0
- package/dist/resources/quests.js +23 -0
- package/dist/resources/tournaments.d.ts +13 -0
- package/dist/resources/tournaments.js +27 -0
- package/dist/resources/weapons.js +1 -1
- package/dist/types/index.d.ts +75 -0
- package/package.json +1 -1
package/dist/client.d.ts
CHANGED
|
@@ -6,6 +6,8 @@ import { BundlesResource } from "./resources/bundles";
|
|
|
6
6
|
import { OauthResource } from "./resources/oauth";
|
|
7
7
|
import { ParsingResource } from "./resources/parsing";
|
|
8
8
|
import { WeaponsResource } from "./resources/weapons";
|
|
9
|
+
import { BattlePassResource } from "./resources/battlepass";
|
|
10
|
+
import { QuestsResource } from "./resources/quests";
|
|
9
11
|
export interface ClientOptions {
|
|
10
12
|
apiKey: string;
|
|
11
13
|
baseUrl?: string;
|
|
@@ -21,13 +23,15 @@ export declare class FortniteAPI {
|
|
|
21
23
|
oauth: OauthResource;
|
|
22
24
|
parsing: ParsingResource;
|
|
23
25
|
weapons: WeaponsResource;
|
|
26
|
+
battlepass: BattlePassResource;
|
|
27
|
+
quests: QuestsResource;
|
|
24
28
|
constructor(options: ClientOptions);
|
|
25
29
|
/**
|
|
26
30
|
* Internal method to make HTTP requests
|
|
27
31
|
*/
|
|
28
|
-
request<T>(endpoint: string, options?: RequestInit): Promise<T>;
|
|
32
|
+
request<T>(endpoint: string, options?: RequestInit, version?: "v1" | "v2" | "v3"): Promise<T>;
|
|
29
33
|
/**
|
|
30
34
|
* Internal method for multipart/form-data requests (file uploads)
|
|
31
35
|
*/
|
|
32
|
-
requestMultipart<T>(endpoint: string, formData: FormData): Promise<T>;
|
|
36
|
+
requestMultipart<T>(endpoint: string, formData: FormData, version?: "v1" | "v2" | "v3"): Promise<T>;
|
|
33
37
|
}
|
package/dist/client.js
CHANGED
|
@@ -10,10 +10,12 @@ const bundles_1 = require("./resources/bundles");
|
|
|
10
10
|
const oauth_1 = require("./resources/oauth");
|
|
11
11
|
const parsing_1 = require("./resources/parsing");
|
|
12
12
|
const weapons_1 = require("./resources/weapons");
|
|
13
|
+
const battlepass_1 = require("./resources/battlepass");
|
|
14
|
+
const quests_1 = require("./resources/quests");
|
|
13
15
|
class FortniteAPI {
|
|
14
16
|
constructor(options) {
|
|
15
17
|
this.apiKey = options.apiKey;
|
|
16
|
-
this.baseUrl = options.baseUrl || "https://prod.api-fortnite.com/api
|
|
18
|
+
this.baseUrl = options.baseUrl || "https://prod.api-fortnite.com/api";
|
|
17
19
|
// this.baseUrl = options.baseUrl || "http://localhost:4321/api/v1";
|
|
18
20
|
// Initialize resources
|
|
19
21
|
this.shop = new shop_1.ShopResource(this);
|
|
@@ -24,12 +26,14 @@ class FortniteAPI {
|
|
|
24
26
|
this.oauth = new oauth_1.OauthResource(this);
|
|
25
27
|
this.parsing = new parsing_1.ParsingResource(this);
|
|
26
28
|
this.weapons = new weapons_1.WeaponsResource(this);
|
|
29
|
+
this.battlepass = new battlepass_1.BattlePassResource(this);
|
|
30
|
+
this.quests = new quests_1.QuestsResource(this);
|
|
27
31
|
}
|
|
28
32
|
/**
|
|
29
33
|
* Internal method to make HTTP requests
|
|
30
34
|
*/
|
|
31
|
-
async request(endpoint, options = {}) {
|
|
32
|
-
const url = `${this.baseUrl}${endpoint}`;
|
|
35
|
+
async request(endpoint, options = {}, version = "v1") {
|
|
36
|
+
const url = `${this.baseUrl}/${version}${endpoint}`;
|
|
33
37
|
const response = await fetch(url, {
|
|
34
38
|
...options,
|
|
35
39
|
headers: {
|
|
@@ -54,8 +58,8 @@ class FortniteAPI {
|
|
|
54
58
|
/**
|
|
55
59
|
* Internal method for multipart/form-data requests (file uploads)
|
|
56
60
|
*/
|
|
57
|
-
async requestMultipart(endpoint, formData) {
|
|
58
|
-
const url = `${this.baseUrl}${endpoint}`;
|
|
61
|
+
async requestMultipart(endpoint, formData, version = "v1") {
|
|
62
|
+
const url = `${this.baseUrl}/${version}${endpoint}`;
|
|
59
63
|
const response = await fetch(url, {
|
|
60
64
|
method: "POST",
|
|
61
65
|
headers: {
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { FortniteAPI } from "../client";
|
|
2
|
+
import { BattlePass } from "../types";
|
|
3
|
+
export declare class BattlePassResource {
|
|
4
|
+
private client;
|
|
5
|
+
constructor(client: FortniteAPI);
|
|
6
|
+
/**
|
|
7
|
+
* Get current battle pass items
|
|
8
|
+
*/
|
|
9
|
+
getBattlePass(): Promise<BattlePass>;
|
|
10
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.BattlePassResource = void 0;
|
|
4
|
+
class BattlePassResource {
|
|
5
|
+
constructor(client) {
|
|
6
|
+
this.client = client;
|
|
7
|
+
}
|
|
8
|
+
/**
|
|
9
|
+
* Get current battle pass items
|
|
10
|
+
*/
|
|
11
|
+
async getBattlePass() {
|
|
12
|
+
return this.client.request("/battlepass");
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
exports.BattlePassResource = BattlePassResource;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { FortniteAPI } from "../client";
|
|
2
|
+
import { QuestsResponse } from "../types";
|
|
3
|
+
export declare class QuestsResource {
|
|
4
|
+
private client;
|
|
5
|
+
constructor(client: FortniteAPI);
|
|
6
|
+
/**
|
|
7
|
+
* Get account quests and level information
|
|
8
|
+
* Requires user's own Fortnite token
|
|
9
|
+
* @param accountId - Epic Games Account ID
|
|
10
|
+
* @param fortniteToken - User's Fortnite access token (from OAuth flow)
|
|
11
|
+
* @returns Quest progress, XP, playtime, and account level data
|
|
12
|
+
*/
|
|
13
|
+
getQuests(accountId: string, fortniteToken: string): Promise<QuestsResponse>;
|
|
14
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.QuestsResource = void 0;
|
|
4
|
+
class QuestsResource {
|
|
5
|
+
constructor(client) {
|
|
6
|
+
this.client = client;
|
|
7
|
+
}
|
|
8
|
+
/**
|
|
9
|
+
* Get account quests and level information
|
|
10
|
+
* Requires user's own Fortnite token
|
|
11
|
+
* @param accountId - Epic Games Account ID
|
|
12
|
+
* @param fortniteToken - User's Fortnite access token (from OAuth flow)
|
|
13
|
+
* @returns Quest progress, XP, playtime, and account level data
|
|
14
|
+
*/
|
|
15
|
+
async getQuests(accountId, fortniteToken) {
|
|
16
|
+
return this.client.request(`/quests/${accountId}`, {
|
|
17
|
+
headers: {
|
|
18
|
+
"x-fortnite-token": fortniteToken,
|
|
19
|
+
},
|
|
20
|
+
}, "v3");
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
exports.QuestsResource = QuestsResource;
|
|
@@ -66,4 +66,17 @@ 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
|
+
* @param params.eventId - Event ID
|
|
72
|
+
* @param params.eventWindowId - Event window ID
|
|
73
|
+
* @param params.leaderboardDef - Optional leaderboard definition (required for Ranked Cups)
|
|
74
|
+
* @param teams - Array of team member account ID arrays (e.g., [["accountId1"], ["accountId2"]])
|
|
75
|
+
* @param fortniteToken - Optional user's Fortnite token for personalized view
|
|
76
|
+
*/
|
|
77
|
+
getLeaderboardV2(params: {
|
|
78
|
+
eventId: string;
|
|
79
|
+
eventWindowId: string;
|
|
80
|
+
leaderboardDef?: string;
|
|
81
|
+
}, teams: string[][], fortniteToken?: string): Promise<Leaderboard>;
|
|
69
82
|
}
|
|
@@ -112,5 +112,32 @@ class TournamentsResource {
|
|
|
112
112
|
},
|
|
113
113
|
});
|
|
114
114
|
}
|
|
115
|
+
/**
|
|
116
|
+
* Get tournament leaderboard using V2 endpoint (POST with teams body)
|
|
117
|
+
* @param params.eventId - Event ID
|
|
118
|
+
* @param params.eventWindowId - Event window ID
|
|
119
|
+
* @param params.leaderboardDef - Optional leaderboard definition (required for Ranked Cups)
|
|
120
|
+
* @param teams - Array of team member account ID arrays (e.g., [["accountId1"], ["accountId2"]])
|
|
121
|
+
* @param fortniteToken - Optional user's Fortnite token for personalized view
|
|
122
|
+
*/
|
|
123
|
+
async getLeaderboardV2(params, teams, fortniteToken) {
|
|
124
|
+
const query = new URLSearchParams({
|
|
125
|
+
eventId: params.eventId,
|
|
126
|
+
eventWindowId: params.eventWindowId,
|
|
127
|
+
});
|
|
128
|
+
if (params.leaderboardDef) {
|
|
129
|
+
query.append("leaderboardDef", params.leaderboardDef);
|
|
130
|
+
}
|
|
131
|
+
const options = {
|
|
132
|
+
method: "POST",
|
|
133
|
+
body: JSON.stringify({ teams }),
|
|
134
|
+
};
|
|
135
|
+
if (fortniteToken) {
|
|
136
|
+
options.headers = {
|
|
137
|
+
"x-fortnite-token": fortniteToken,
|
|
138
|
+
};
|
|
139
|
+
}
|
|
140
|
+
return this.client.request(`/events/leaderboard?${query.toString()}`, options, "v2");
|
|
141
|
+
}
|
|
115
142
|
}
|
|
116
143
|
exports.TournamentsResource = TournamentsResource;
|
package/dist/types/index.d.ts
CHANGED
|
@@ -217,3 +217,78 @@ export interface WeaponsStats {
|
|
|
217
217
|
overheatedCooldownDelay: number;
|
|
218
218
|
maxDamagePerCartridge: number;
|
|
219
219
|
}
|
|
220
|
+
export interface BattlePass {
|
|
221
|
+
battlePassContent: BattlePassContent;
|
|
222
|
+
battlePassOffers: Array<BattlePassOffers>;
|
|
223
|
+
}
|
|
224
|
+
export interface MessagesBP {
|
|
225
|
+
layout: string;
|
|
226
|
+
image: string;
|
|
227
|
+
hidden?: boolean;
|
|
228
|
+
_type: string;
|
|
229
|
+
title: string;
|
|
230
|
+
body: string;
|
|
231
|
+
spotlight: boolean;
|
|
232
|
+
}
|
|
233
|
+
export interface BattlePassContent {
|
|
234
|
+
news: {
|
|
235
|
+
_type: string;
|
|
236
|
+
messages: Array<MessagesBP>;
|
|
237
|
+
};
|
|
238
|
+
_title: string;
|
|
239
|
+
_noIndex: boolean;
|
|
240
|
+
_activeDate: string;
|
|
241
|
+
lastModified: string;
|
|
242
|
+
_locale: string;
|
|
243
|
+
_templateName: string;
|
|
244
|
+
_suggestedPrefetch: Array<any>;
|
|
245
|
+
}
|
|
246
|
+
export interface PricesBP {
|
|
247
|
+
currencyType: string;
|
|
248
|
+
currencySubType: string;
|
|
249
|
+
regularPrice: number;
|
|
250
|
+
dynamicRegularPrice: number;
|
|
251
|
+
finalPrice: number;
|
|
252
|
+
saleExpiration: string;
|
|
253
|
+
basePrice: number;
|
|
254
|
+
}
|
|
255
|
+
export interface RequirementsBP {
|
|
256
|
+
requirementType: string;
|
|
257
|
+
requiredId: string;
|
|
258
|
+
minQuantity: number;
|
|
259
|
+
}
|
|
260
|
+
export interface MetaInfoBP {
|
|
261
|
+
key: string;
|
|
262
|
+
value: string;
|
|
263
|
+
}
|
|
264
|
+
export interface BattlePassOffers {
|
|
265
|
+
offerId: string;
|
|
266
|
+
devName: string;
|
|
267
|
+
offerType: string;
|
|
268
|
+
prices: Array<PricesBP>;
|
|
269
|
+
categories: Array<any>;
|
|
270
|
+
dailyLimit: number;
|
|
271
|
+
weeklyLimit: number;
|
|
272
|
+
monthlyLimit: number;
|
|
273
|
+
refundable: boolean;
|
|
274
|
+
appStoreId: Array<string>;
|
|
275
|
+
requirements: Array<RequirementsBP>;
|
|
276
|
+
metaInfo: Array<MetaInfoBP>;
|
|
277
|
+
catalogGroup: string;
|
|
278
|
+
catalogGroupPriority: number;
|
|
279
|
+
sortPriority: number;
|
|
280
|
+
title: string;
|
|
281
|
+
shortDescription: string;
|
|
282
|
+
description: string;
|
|
283
|
+
displayAssetPath: string;
|
|
284
|
+
itemGrants: Array<any>;
|
|
285
|
+
sectionId: string | null;
|
|
286
|
+
sectionDisplayName: string | null;
|
|
287
|
+
sectionPriority: number | null;
|
|
288
|
+
sectionBackground: null | null;
|
|
289
|
+
offerVisual: string | null;
|
|
290
|
+
tileSize: string;
|
|
291
|
+
}
|
|
292
|
+
export interface QuestsResponse {
|
|
293
|
+
[key: string]: any;
|
|
294
|
+
}
|