@yaelouuu/fortnite-api 4.2.0 → 4.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.
- package/dist/client.d.ts +6 -0
- package/dist/client.js +6 -0
- package/dist/resources/events.d.ts +83 -0
- package/dist/resources/events.js +138 -0
- package/dist/resources/friends.d.ts +68 -0
- package/dist/resources/friends.js +119 -0
- package/dist/resources/stats.d.ts +40 -0
- package/dist/resources/stats.js +85 -0
- package/dist/types/index.d.ts +142 -0
- package/package.json +1 -1
package/dist/client.d.ts
CHANGED
|
@@ -10,6 +10,9 @@ import { BattlePassResource } from "./resources/battlepass";
|
|
|
10
10
|
import { QuestsResource } from "./resources/quests";
|
|
11
11
|
import { AccountResource } from "./resources/account";
|
|
12
12
|
import { FNResource } from "./resources/fn";
|
|
13
|
+
import { FriendsResource } from "./resources/friends";
|
|
14
|
+
import { StatsResource } from "./resources/stats";
|
|
15
|
+
import { EventsResource } from "./resources/events";
|
|
13
16
|
export interface ClientOptions {
|
|
14
17
|
apiKey: string;
|
|
15
18
|
baseUrl?: string;
|
|
@@ -29,6 +32,9 @@ export declare class FortniteAPI {
|
|
|
29
32
|
quests: QuestsResource;
|
|
30
33
|
account: AccountResource;
|
|
31
34
|
fn: FNResource;
|
|
35
|
+
friends: FriendsResource;
|
|
36
|
+
stats: StatsResource;
|
|
37
|
+
events: EventsResource;
|
|
32
38
|
constructor(options: ClientOptions);
|
|
33
39
|
/**
|
|
34
40
|
* Internal method to make HTTP requests
|
package/dist/client.js
CHANGED
|
@@ -14,6 +14,9 @@ const battlepass_1 = require("./resources/battlepass");
|
|
|
14
14
|
const quests_1 = require("./resources/quests");
|
|
15
15
|
const account_1 = require("./resources/account");
|
|
16
16
|
const fn_1 = require("./resources/fn");
|
|
17
|
+
const friends_1 = require("./resources/friends");
|
|
18
|
+
const stats_1 = require("./resources/stats");
|
|
19
|
+
const events_1 = require("./resources/events");
|
|
17
20
|
class FortniteAPI {
|
|
18
21
|
constructor(options) {
|
|
19
22
|
this.apiKey = options.apiKey;
|
|
@@ -32,6 +35,9 @@ class FortniteAPI {
|
|
|
32
35
|
this.quests = new quests_1.QuestsResource(this);
|
|
33
36
|
this.account = new account_1.AccountResource(this);
|
|
34
37
|
this.fn = new fn_1.FNResource(this);
|
|
38
|
+
this.friends = new friends_1.FriendsResource(this);
|
|
39
|
+
this.stats = new stats_1.StatsResource(this);
|
|
40
|
+
this.events = new events_1.EventsResource(this);
|
|
35
41
|
}
|
|
36
42
|
/**
|
|
37
43
|
* Internal method to make HTTP requests
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
import { FortniteAPI } from "../client";
|
|
2
|
+
import { EventWindows, PlayerEventHistory, TournamentDetails, ScoringRules, EventLeaderboard, PlayerEventData, EligibilityStatus, ArenaHype, EventRewards } from "../types";
|
|
3
|
+
/**
|
|
4
|
+
* Events Resource
|
|
5
|
+
* Handles tournament and competitive events data
|
|
6
|
+
*/
|
|
7
|
+
export declare class EventsResource {
|
|
8
|
+
private client;
|
|
9
|
+
constructor(client: FortniteAPI);
|
|
10
|
+
/**
|
|
11
|
+
* Get event windows
|
|
12
|
+
* @param eventId - Event ID
|
|
13
|
+
* @param fortniteToken - Optional user Fortnite token
|
|
14
|
+
* @returns Event windows data
|
|
15
|
+
*/
|
|
16
|
+
getEventWindows(eventId: string, fortniteToken?: string): Promise<EventWindows>;
|
|
17
|
+
/**
|
|
18
|
+
* Get player event history
|
|
19
|
+
* @param accountId - Account ID
|
|
20
|
+
* @param fortniteToken - Optional user Fortnite token
|
|
21
|
+
* @returns Array of events player participated in
|
|
22
|
+
*/
|
|
23
|
+
getPlayerHistory(accountId: string, fortniteToken?: string): Promise<PlayerEventHistory[]>;
|
|
24
|
+
/**
|
|
25
|
+
* Get tournament details
|
|
26
|
+
* @param eventId - Event ID
|
|
27
|
+
* @param eventWindowId - Event window ID
|
|
28
|
+
* @param fortniteToken - Optional user Fortnite token
|
|
29
|
+
* @returns Tournament details
|
|
30
|
+
*/
|
|
31
|
+
getTournamentDetails(eventId: string, eventWindowId: string, fortniteToken?: string): Promise<TournamentDetails>;
|
|
32
|
+
/**
|
|
33
|
+
* Get event scoring rules
|
|
34
|
+
* @param eventId - Event ID
|
|
35
|
+
* @param eventWindowId - Event window ID
|
|
36
|
+
* @param fortniteToken - Optional user Fortnite token
|
|
37
|
+
* @returns Scoring rules
|
|
38
|
+
*/
|
|
39
|
+
getScoringRules(eventId: string, eventWindowId: string, fortniteToken?: string): Promise<ScoringRules>;
|
|
40
|
+
/**
|
|
41
|
+
* Get event leaderboard
|
|
42
|
+
* @param eventId - Event ID
|
|
43
|
+
* @param eventWindowId - Event window ID
|
|
44
|
+
* @param options - Query options
|
|
45
|
+
* @param fortniteToken - Optional user Fortnite token
|
|
46
|
+
* @returns Leaderboard data
|
|
47
|
+
*/
|
|
48
|
+
getLeaderboard(eventId: string, eventWindowId: string, options?: {
|
|
49
|
+
page?: number;
|
|
50
|
+
}, fortniteToken?: string): Promise<EventLeaderboard>;
|
|
51
|
+
/**
|
|
52
|
+
* Get player event data
|
|
53
|
+
* @param eventId - Event ID
|
|
54
|
+
* @param eventWindowId - Event window ID
|
|
55
|
+
* @param accountId - Account ID
|
|
56
|
+
* @param fortniteToken - Optional user Fortnite token
|
|
57
|
+
* @returns Player's event performance data
|
|
58
|
+
*/
|
|
59
|
+
getPlayerEventData(eventId: string, eventWindowId: string, accountId: string, fortniteToken?: string): Promise<PlayerEventData>;
|
|
60
|
+
/**
|
|
61
|
+
* Check tournament eligibility
|
|
62
|
+
* @param accountId - Account ID
|
|
63
|
+
* @param eventId - Event ID
|
|
64
|
+
* @param fortniteToken - User Fortnite token (REQUIRED)
|
|
65
|
+
* @returns Eligibility status
|
|
66
|
+
*/
|
|
67
|
+
checkEligibility(accountId: string, eventId: string, fortniteToken: string): Promise<EligibilityStatus>;
|
|
68
|
+
/**
|
|
69
|
+
* Get Arena hype and division
|
|
70
|
+
* @param accountId - Account ID
|
|
71
|
+
* @param fortniteToken - Optional user Fortnite token
|
|
72
|
+
* @returns Arena hype, division, and progress
|
|
73
|
+
*/
|
|
74
|
+
getArenaHype(accountId: string, fortniteToken?: string): Promise<ArenaHype>;
|
|
75
|
+
/**
|
|
76
|
+
* Get event rewards/prizes
|
|
77
|
+
* @param eventId - Event ID
|
|
78
|
+
* @param eventWindowId - Event window ID
|
|
79
|
+
* @param fortniteToken - Optional user Fortnite token
|
|
80
|
+
* @returns Event rewards structure
|
|
81
|
+
*/
|
|
82
|
+
getEventRewards(eventId: string, eventWindowId: string, fortniteToken?: string): Promise<EventRewards>;
|
|
83
|
+
}
|
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.EventsResource = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* Events Resource
|
|
6
|
+
* Handles tournament and competitive events data
|
|
7
|
+
*/
|
|
8
|
+
class EventsResource {
|
|
9
|
+
constructor(client) {
|
|
10
|
+
this.client = client;
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* Get event windows
|
|
14
|
+
* @param eventId - Event ID
|
|
15
|
+
* @param fortniteToken - Optional user Fortnite token
|
|
16
|
+
* @returns Event windows data
|
|
17
|
+
*/
|
|
18
|
+
async getEventWindows(eventId, fortniteToken) {
|
|
19
|
+
const headers = {};
|
|
20
|
+
if (fortniteToken) {
|
|
21
|
+
headers["x-fortnite-token"] = fortniteToken;
|
|
22
|
+
}
|
|
23
|
+
return this.client.request(`/events/${eventId}/windows`, { headers }, "v2");
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Get player event history
|
|
27
|
+
* @param accountId - Account ID
|
|
28
|
+
* @param fortniteToken - Optional user Fortnite token
|
|
29
|
+
* @returns Array of events player participated in
|
|
30
|
+
*/
|
|
31
|
+
async getPlayerHistory(accountId, fortniteToken) {
|
|
32
|
+
const headers = {};
|
|
33
|
+
if (fortniteToken) {
|
|
34
|
+
headers["x-fortnite-token"] = fortniteToken;
|
|
35
|
+
}
|
|
36
|
+
return this.client.request(`/events/history/${accountId}`, { headers }, "v2");
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Get tournament details
|
|
40
|
+
* @param eventId - Event ID
|
|
41
|
+
* @param eventWindowId - Event window ID
|
|
42
|
+
* @param fortniteToken - Optional user Fortnite token
|
|
43
|
+
* @returns Tournament details
|
|
44
|
+
*/
|
|
45
|
+
async getTournamentDetails(eventId, eventWindowId, fortniteToken) {
|
|
46
|
+
const headers = {};
|
|
47
|
+
if (fortniteToken) {
|
|
48
|
+
headers["x-fortnite-token"] = fortniteToken;
|
|
49
|
+
}
|
|
50
|
+
return this.client.request(`/events/${eventId}/windows/${eventWindowId}`, { headers }, "v2");
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* Get event scoring rules
|
|
54
|
+
* @param eventId - Event ID
|
|
55
|
+
* @param eventWindowId - Event window ID
|
|
56
|
+
* @param fortniteToken - Optional user Fortnite token
|
|
57
|
+
* @returns Scoring rules
|
|
58
|
+
*/
|
|
59
|
+
async getScoringRules(eventId, eventWindowId, fortniteToken) {
|
|
60
|
+
const headers = {};
|
|
61
|
+
if (fortniteToken) {
|
|
62
|
+
headers["x-fortnite-token"] = fortniteToken;
|
|
63
|
+
}
|
|
64
|
+
return this.client.request(`/events/${eventId}/windows/${eventWindowId}/scoring`, { headers }, "v2");
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* Get event leaderboard
|
|
68
|
+
* @param eventId - Event ID
|
|
69
|
+
* @param eventWindowId - Event window ID
|
|
70
|
+
* @param options - Query options
|
|
71
|
+
* @param fortniteToken - Optional user Fortnite token
|
|
72
|
+
* @returns Leaderboard data
|
|
73
|
+
*/
|
|
74
|
+
async getLeaderboard(eventId, eventWindowId, options, fortniteToken) {
|
|
75
|
+
const headers = {};
|
|
76
|
+
if (fortniteToken) {
|
|
77
|
+
headers["x-fortnite-token"] = fortniteToken;
|
|
78
|
+
}
|
|
79
|
+
const query = options?.page ? `?page=${options.page}` : "";
|
|
80
|
+
return this.client.request(`/events/${eventId}/windows/${eventWindowId}/leaderboard${query}`, { headers }, "v2");
|
|
81
|
+
}
|
|
82
|
+
/**
|
|
83
|
+
* Get player event data
|
|
84
|
+
* @param eventId - Event ID
|
|
85
|
+
* @param eventWindowId - Event window ID
|
|
86
|
+
* @param accountId - Account ID
|
|
87
|
+
* @param fortniteToken - Optional user Fortnite token
|
|
88
|
+
* @returns Player's event performance data
|
|
89
|
+
*/
|
|
90
|
+
async getPlayerEventData(eventId, eventWindowId, accountId, fortniteToken) {
|
|
91
|
+
const headers = {};
|
|
92
|
+
if (fortniteToken) {
|
|
93
|
+
headers["x-fortnite-token"] = fortniteToken;
|
|
94
|
+
}
|
|
95
|
+
return this.client.request(`/events/${eventId}/windows/${eventWindowId}/players/${accountId}`, { headers }, "v2");
|
|
96
|
+
}
|
|
97
|
+
/**
|
|
98
|
+
* Check tournament eligibility
|
|
99
|
+
* @param accountId - Account ID
|
|
100
|
+
* @param eventId - Event ID
|
|
101
|
+
* @param fortniteToken - User Fortnite token (REQUIRED)
|
|
102
|
+
* @returns Eligibility status
|
|
103
|
+
*/
|
|
104
|
+
async checkEligibility(accountId, eventId, fortniteToken) {
|
|
105
|
+
const headers = {
|
|
106
|
+
"x-fortnite-token": fortniteToken,
|
|
107
|
+
};
|
|
108
|
+
return this.client.request(`/events/${eventId}/eligibility/${accountId}`, { headers }, "v2");
|
|
109
|
+
}
|
|
110
|
+
/**
|
|
111
|
+
* Get Arena hype and division
|
|
112
|
+
* @param accountId - Account ID
|
|
113
|
+
* @param fortniteToken - Optional user Fortnite token
|
|
114
|
+
* @returns Arena hype, division, and progress
|
|
115
|
+
*/
|
|
116
|
+
async getArenaHype(accountId, fortniteToken) {
|
|
117
|
+
const headers = {};
|
|
118
|
+
if (fortniteToken) {
|
|
119
|
+
headers["x-fortnite-token"] = fortniteToken;
|
|
120
|
+
}
|
|
121
|
+
return this.client.request(`/events/arena/${accountId}`, { headers }, "v2");
|
|
122
|
+
}
|
|
123
|
+
/**
|
|
124
|
+
* Get event rewards/prizes
|
|
125
|
+
* @param eventId - Event ID
|
|
126
|
+
* @param eventWindowId - Event window ID
|
|
127
|
+
* @param fortniteToken - Optional user Fortnite token
|
|
128
|
+
* @returns Event rewards structure
|
|
129
|
+
*/
|
|
130
|
+
async getEventRewards(eventId, eventWindowId, fortniteToken) {
|
|
131
|
+
const headers = {};
|
|
132
|
+
if (fortniteToken) {
|
|
133
|
+
headers["x-fortnite-token"] = fortniteToken;
|
|
134
|
+
}
|
|
135
|
+
return this.client.request(`/events/${eventId}/windows/${eventWindowId}/rewards`, { headers }, "v2");
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
exports.EventsResource = EventsResource;
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import { FortniteAPI } from "../client";
|
|
2
|
+
import { FriendsSummary, Friend, FriendRequest, BlockedUser, FriendshipInfo, SuggestedFriend } from "../types";
|
|
3
|
+
/**
|
|
4
|
+
* Friends Resource
|
|
5
|
+
* Handles all friend-related operations
|
|
6
|
+
*/
|
|
7
|
+
export declare class FriendsResource {
|
|
8
|
+
private client;
|
|
9
|
+
constructor(client: FortniteAPI);
|
|
10
|
+
/**
|
|
11
|
+
* Get complete friends summary (most efficient - everything in one call)
|
|
12
|
+
* @param accountId - Account ID
|
|
13
|
+
* @param fortniteToken - Optional user Fortnite token
|
|
14
|
+
* @returns Complete summary with friends, requests, blocklist, settings
|
|
15
|
+
*/
|
|
16
|
+
getSummary(accountId: string, fortniteToken?: string): Promise<FriendsSummary>;
|
|
17
|
+
/**
|
|
18
|
+
* Get friends list
|
|
19
|
+
* @param accountId - Account ID
|
|
20
|
+
* @param fortniteToken - Optional user Fortnite token
|
|
21
|
+
* @returns Array of friends with aliases and metadata
|
|
22
|
+
*/
|
|
23
|
+
getFriendsList(accountId: string, fortniteToken?: string): Promise<Friend[]>;
|
|
24
|
+
/**
|
|
25
|
+
* Get incoming friend requests
|
|
26
|
+
* @param accountId - Account ID
|
|
27
|
+
* @param fortniteToken - Optional user Fortnite token
|
|
28
|
+
* @returns Array of incoming requests
|
|
29
|
+
*/
|
|
30
|
+
getIncomingRequests(accountId: string, fortniteToken?: string): Promise<FriendRequest[]>;
|
|
31
|
+
/**
|
|
32
|
+
* Get outgoing friend requests
|
|
33
|
+
* @param accountId - Account ID
|
|
34
|
+
* @param fortniteToken - Optional user Fortnite token
|
|
35
|
+
* @returns Array of outgoing requests
|
|
36
|
+
*/
|
|
37
|
+
getOutgoingRequests(accountId: string, fortniteToken?: string): Promise<FriendRequest[]>;
|
|
38
|
+
/**
|
|
39
|
+
* Get mutual friends between two users
|
|
40
|
+
* @param accountId - Your account ID
|
|
41
|
+
* @param friendId - Friend's account ID
|
|
42
|
+
* @param fortniteToken - Optional user Fortnite token
|
|
43
|
+
* @returns Array of mutual friend account IDs
|
|
44
|
+
*/
|
|
45
|
+
getMutualFriends(accountId: string, friendId: string, fortniteToken?: string): Promise<string[]>;
|
|
46
|
+
/**
|
|
47
|
+
* Get block list
|
|
48
|
+
* @param accountId - Account ID
|
|
49
|
+
* @param fortniteToken - Optional user Fortnite token
|
|
50
|
+
* @returns Array of blocked users
|
|
51
|
+
*/
|
|
52
|
+
getBlocklist(accountId: string, fortniteToken?: string): Promise<BlockedUser[]>;
|
|
53
|
+
/**
|
|
54
|
+
* Get friendship info for specific friend
|
|
55
|
+
* @param accountId - Your account ID
|
|
56
|
+
* @param friendId - Friend's account ID
|
|
57
|
+
* @param fortniteToken - Optional user Fortnite token
|
|
58
|
+
* @returns Friendship details including mutual count
|
|
59
|
+
*/
|
|
60
|
+
getFriendshipInfo(accountId: string, friendId: string, fortniteToken?: string): Promise<FriendshipInfo>;
|
|
61
|
+
/**
|
|
62
|
+
* Get suggested friends
|
|
63
|
+
* @param accountId - Account ID
|
|
64
|
+
* @param fortniteToken - Optional user Fortnite token
|
|
65
|
+
* @returns Array of suggested friends
|
|
66
|
+
*/
|
|
67
|
+
getSuggestedFriends(accountId: string, fortniteToken?: string): Promise<SuggestedFriend[]>;
|
|
68
|
+
}
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.FriendsResource = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* Friends Resource
|
|
6
|
+
* Handles all friend-related operations
|
|
7
|
+
*/
|
|
8
|
+
class FriendsResource {
|
|
9
|
+
constructor(client) {
|
|
10
|
+
this.client = client;
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* Get complete friends summary (most efficient - everything in one call)
|
|
14
|
+
* @param accountId - Account ID
|
|
15
|
+
* @param fortniteToken - Optional user Fortnite token
|
|
16
|
+
* @returns Complete summary with friends, requests, blocklist, settings
|
|
17
|
+
*/
|
|
18
|
+
async getSummary(accountId, fortniteToken) {
|
|
19
|
+
const headers = {};
|
|
20
|
+
if (fortniteToken) {
|
|
21
|
+
headers["x-fortnite-token"] = fortniteToken;
|
|
22
|
+
}
|
|
23
|
+
return this.client.request(`/friends/${accountId}/summary`, { headers }, "v1");
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Get friends list
|
|
27
|
+
* @param accountId - Account ID
|
|
28
|
+
* @param fortniteToken - Optional user Fortnite token
|
|
29
|
+
* @returns Array of friends with aliases and metadata
|
|
30
|
+
*/
|
|
31
|
+
async getFriendsList(accountId, fortniteToken) {
|
|
32
|
+
const headers = {};
|
|
33
|
+
if (fortniteToken) {
|
|
34
|
+
headers["x-fortnite-token"] = fortniteToken;
|
|
35
|
+
}
|
|
36
|
+
return this.client.request(`/friends/${accountId}/friends`, { headers }, "v1");
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Get incoming friend requests
|
|
40
|
+
* @param accountId - Account ID
|
|
41
|
+
* @param fortniteToken - Optional user Fortnite token
|
|
42
|
+
* @returns Array of incoming requests
|
|
43
|
+
*/
|
|
44
|
+
async getIncomingRequests(accountId, fortniteToken) {
|
|
45
|
+
const headers = {};
|
|
46
|
+
if (fortniteToken) {
|
|
47
|
+
headers["x-fortnite-token"] = fortniteToken;
|
|
48
|
+
}
|
|
49
|
+
return this.client.request(`/friends/${accountId}/incoming`, { headers }, "v1");
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* Get outgoing friend requests
|
|
53
|
+
* @param accountId - Account ID
|
|
54
|
+
* @param fortniteToken - Optional user Fortnite token
|
|
55
|
+
* @returns Array of outgoing requests
|
|
56
|
+
*/
|
|
57
|
+
async getOutgoingRequests(accountId, fortniteToken) {
|
|
58
|
+
const headers = {};
|
|
59
|
+
if (fortniteToken) {
|
|
60
|
+
headers["x-fortnite-token"] = fortniteToken;
|
|
61
|
+
}
|
|
62
|
+
return this.client.request(`/friends/${accountId}/outgoing`, { headers }, "v1");
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* Get mutual friends between two users
|
|
66
|
+
* @param accountId - Your account ID
|
|
67
|
+
* @param friendId - Friend's account ID
|
|
68
|
+
* @param fortniteToken - Optional user Fortnite token
|
|
69
|
+
* @returns Array of mutual friend account IDs
|
|
70
|
+
*/
|
|
71
|
+
async getMutualFriends(accountId, friendId, fortniteToken) {
|
|
72
|
+
const headers = {};
|
|
73
|
+
if (fortniteToken) {
|
|
74
|
+
headers["x-fortnite-token"] = fortniteToken;
|
|
75
|
+
}
|
|
76
|
+
return this.client.request(`/friends/${accountId}/friends/${friendId}/mutual`, { headers }, "v1");
|
|
77
|
+
}
|
|
78
|
+
/**
|
|
79
|
+
* Get block list
|
|
80
|
+
* @param accountId - Account ID
|
|
81
|
+
* @param fortniteToken - Optional user Fortnite token
|
|
82
|
+
* @returns Array of blocked users
|
|
83
|
+
*/
|
|
84
|
+
async getBlocklist(accountId, fortniteToken) {
|
|
85
|
+
const headers = {};
|
|
86
|
+
if (fortniteToken) {
|
|
87
|
+
headers["x-fortnite-token"] = fortniteToken;
|
|
88
|
+
}
|
|
89
|
+
return this.client.request(`/friends/${accountId}/blocklist`, { headers }, "v1");
|
|
90
|
+
}
|
|
91
|
+
/**
|
|
92
|
+
* Get friendship info for specific friend
|
|
93
|
+
* @param accountId - Your account ID
|
|
94
|
+
* @param friendId - Friend's account ID
|
|
95
|
+
* @param fortniteToken - Optional user Fortnite token
|
|
96
|
+
* @returns Friendship details including mutual count
|
|
97
|
+
*/
|
|
98
|
+
async getFriendshipInfo(accountId, friendId, fortniteToken) {
|
|
99
|
+
const headers = {};
|
|
100
|
+
if (fortniteToken) {
|
|
101
|
+
headers["x-fortnite-token"] = fortniteToken;
|
|
102
|
+
}
|
|
103
|
+
return this.client.request(`/friends/${accountId}/friends/${friendId}`, { headers }, "v1");
|
|
104
|
+
}
|
|
105
|
+
/**
|
|
106
|
+
* Get suggested friends
|
|
107
|
+
* @param accountId - Account ID
|
|
108
|
+
* @param fortniteToken - Optional user Fortnite token
|
|
109
|
+
* @returns Array of suggested friends
|
|
110
|
+
*/
|
|
111
|
+
async getSuggestedFriends(accountId, fortniteToken) {
|
|
112
|
+
const headers = {};
|
|
113
|
+
if (fortniteToken) {
|
|
114
|
+
headers["x-fortnite-token"] = fortniteToken;
|
|
115
|
+
}
|
|
116
|
+
return this.client.request(`/friends/${accountId}/suggested`, { headers }, "v1");
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
exports.FriendsResource = FriendsResource;
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { FortniteAPI } from "../client";
|
|
2
|
+
import { PlayerStats, BulkStatsResponse, LeaderboardResponse, LeaderboardOptions } from "../types";
|
|
3
|
+
/**
|
|
4
|
+
* Stats Resource
|
|
5
|
+
* Handles player statistics queries
|
|
6
|
+
*/
|
|
7
|
+
export declare class StatsResource {
|
|
8
|
+
private client;
|
|
9
|
+
constructor(client: FortniteAPI);
|
|
10
|
+
/**
|
|
11
|
+
* Get player stats with optional filters
|
|
12
|
+
* @param accountId - Account ID
|
|
13
|
+
* @param options - Query options
|
|
14
|
+
* @param fortniteToken - Optional user Fortnite token
|
|
15
|
+
* @returns Player statistics
|
|
16
|
+
*/
|
|
17
|
+
getPlayerStats(accountId: string, options?: {
|
|
18
|
+
startDate?: string;
|
|
19
|
+
endDate?: string;
|
|
20
|
+
stats?: string[];
|
|
21
|
+
}, fortniteToken?: string): Promise<PlayerStats>;
|
|
22
|
+
/**
|
|
23
|
+
* Get bulk stats for multiple players
|
|
24
|
+
* @param accountIds - Array of account IDs (max 100)
|
|
25
|
+
* @param options - Query options
|
|
26
|
+
* @param fortniteToken - Optional user Fortnite token
|
|
27
|
+
* @returns Array of player statistics
|
|
28
|
+
*/
|
|
29
|
+
getBulkStats(accountIds: string[], options?: {
|
|
30
|
+
stats?: string[];
|
|
31
|
+
}, fortniteToken?: string): Promise<BulkStatsResponse[]>;
|
|
32
|
+
/**
|
|
33
|
+
* Get leaderboard for specific stat
|
|
34
|
+
* @param stat - Stat name to query
|
|
35
|
+
* @param options - Query options
|
|
36
|
+
* @param fortniteToken - Optional user Fortnite token
|
|
37
|
+
* @returns Leaderboard data
|
|
38
|
+
*/
|
|
39
|
+
getLeaderboard(stat: string, options?: LeaderboardOptions, fortniteToken?: string): Promise<LeaderboardResponse>;
|
|
40
|
+
}
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.StatsResource = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* Stats Resource
|
|
6
|
+
* Handles player statistics queries
|
|
7
|
+
*/
|
|
8
|
+
class StatsResource {
|
|
9
|
+
constructor(client) {
|
|
10
|
+
this.client = client;
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* Get player stats with optional filters
|
|
14
|
+
* @param accountId - Account ID
|
|
15
|
+
* @param options - Query options
|
|
16
|
+
* @param fortniteToken - Optional user Fortnite token
|
|
17
|
+
* @returns Player statistics
|
|
18
|
+
*/
|
|
19
|
+
async getPlayerStats(accountId, options, fortniteToken) {
|
|
20
|
+
const headers = {};
|
|
21
|
+
if (fortniteToken) {
|
|
22
|
+
headers["x-fortnite-token"] = fortniteToken;
|
|
23
|
+
}
|
|
24
|
+
const queryParams = new URLSearchParams();
|
|
25
|
+
if (options?.startDate)
|
|
26
|
+
queryParams.append("startDate", options.startDate);
|
|
27
|
+
if (options?.endDate)
|
|
28
|
+
queryParams.append("endDate", options.endDate);
|
|
29
|
+
if (options?.stats)
|
|
30
|
+
queryParams.append("stats", options.stats.join(","));
|
|
31
|
+
const query = queryParams.toString();
|
|
32
|
+
const url = `/stats/${accountId}${query ? `?${query}` : ""}`;
|
|
33
|
+
return this.client.request(url, { headers }, "v2");
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Get bulk stats for multiple players
|
|
37
|
+
* @param accountIds - Array of account IDs (max 100)
|
|
38
|
+
* @param options - Query options
|
|
39
|
+
* @param fortniteToken - Optional user Fortnite token
|
|
40
|
+
* @returns Array of player statistics
|
|
41
|
+
*/
|
|
42
|
+
async getBulkStats(accountIds, options, fortniteToken) {
|
|
43
|
+
const headers = {
|
|
44
|
+
"Content-Type": "application/json",
|
|
45
|
+
};
|
|
46
|
+
if (fortniteToken) {
|
|
47
|
+
headers["x-fortnite-token"] = fortniteToken;
|
|
48
|
+
}
|
|
49
|
+
const body = {
|
|
50
|
+
accountIds,
|
|
51
|
+
};
|
|
52
|
+
if (options?.stats) {
|
|
53
|
+
body.stats = options.stats;
|
|
54
|
+
}
|
|
55
|
+
return this.client.request("/stats/bulk", {
|
|
56
|
+
method: "POST",
|
|
57
|
+
headers,
|
|
58
|
+
body: JSON.stringify(body),
|
|
59
|
+
}, "v2");
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* Get leaderboard for specific stat
|
|
63
|
+
* @param stat - Stat name to query
|
|
64
|
+
* @param options - Query options
|
|
65
|
+
* @param fortniteToken - Optional user Fortnite token
|
|
66
|
+
* @returns Leaderboard data
|
|
67
|
+
*/
|
|
68
|
+
async getLeaderboard(stat, options, fortniteToken) {
|
|
69
|
+
const headers = {};
|
|
70
|
+
if (fortniteToken) {
|
|
71
|
+
headers["x-fortnite-token"] = fortniteToken;
|
|
72
|
+
}
|
|
73
|
+
const queryParams = new URLSearchParams();
|
|
74
|
+
if (options?.limit)
|
|
75
|
+
queryParams.append("limit", options.limit.toString());
|
|
76
|
+
if (options?.offset)
|
|
77
|
+
queryParams.append("offset", options.offset.toString());
|
|
78
|
+
if (options?.window)
|
|
79
|
+
queryParams.append("window", options.window);
|
|
80
|
+
const query = queryParams.toString();
|
|
81
|
+
const url = `/stats/leaderboard/${stat}${query ? `?${query}` : ""}`;
|
|
82
|
+
return this.client.request(url, { headers }, "v2");
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
exports.StatsResource = StatsResource;
|
package/dist/types/index.d.ts
CHANGED
|
@@ -355,3 +355,145 @@ export interface EntitlementCheck {
|
|
|
355
355
|
entitlement?: boolean;
|
|
356
356
|
[key: string]: any;
|
|
357
357
|
}
|
|
358
|
+
export interface FriendsSummary {
|
|
359
|
+
friends?: Friend[];
|
|
360
|
+
incoming?: FriendRequest[];
|
|
361
|
+
outgoing?: FriendRequest[];
|
|
362
|
+
blocklist?: BlockedUser[];
|
|
363
|
+
settings?: {
|
|
364
|
+
[key: string]: any;
|
|
365
|
+
};
|
|
366
|
+
}
|
|
367
|
+
export interface Friend {
|
|
368
|
+
accountId: string;
|
|
369
|
+
displayName?: string;
|
|
370
|
+
status: "ACCEPTED" | "PENDING";
|
|
371
|
+
direction: "INBOUND" | "OUTBOUND";
|
|
372
|
+
created: string;
|
|
373
|
+
favorite?: boolean;
|
|
374
|
+
mutual?: number;
|
|
375
|
+
}
|
|
376
|
+
export interface FriendRequest {
|
|
377
|
+
accountId: string;
|
|
378
|
+
displayName?: string;
|
|
379
|
+
status: string;
|
|
380
|
+
direction: string;
|
|
381
|
+
created: string;
|
|
382
|
+
}
|
|
383
|
+
export interface BlockedUser {
|
|
384
|
+
accountId: string;
|
|
385
|
+
displayName?: string;
|
|
386
|
+
}
|
|
387
|
+
export interface FriendshipInfo extends Friend {
|
|
388
|
+
mutual: number;
|
|
389
|
+
}
|
|
390
|
+
export interface SuggestedFriend {
|
|
391
|
+
accountId: string;
|
|
392
|
+
displayName?: string;
|
|
393
|
+
mutualFriends?: number;
|
|
394
|
+
}
|
|
395
|
+
export interface PlayerStats {
|
|
396
|
+
accountId: string;
|
|
397
|
+
stats: {
|
|
398
|
+
[key: string]: any;
|
|
399
|
+
};
|
|
400
|
+
}
|
|
401
|
+
export interface BulkStatsRequest {
|
|
402
|
+
accountIds: string[];
|
|
403
|
+
stats?: string[];
|
|
404
|
+
}
|
|
405
|
+
export interface BulkStatsResponse {
|
|
406
|
+
accountId: string;
|
|
407
|
+
stats: {
|
|
408
|
+
[key: string]: any;
|
|
409
|
+
};
|
|
410
|
+
}
|
|
411
|
+
export interface LeaderboardOptions {
|
|
412
|
+
limit?: number;
|
|
413
|
+
offset?: number;
|
|
414
|
+
window?: "alltime" | "season" | "weekly" | "daily";
|
|
415
|
+
}
|
|
416
|
+
export interface LeaderboardResponse {
|
|
417
|
+
stat: string;
|
|
418
|
+
window: string;
|
|
419
|
+
entries: Array<{
|
|
420
|
+
rank: number;
|
|
421
|
+
accountId: string;
|
|
422
|
+
displayName?: string;
|
|
423
|
+
value: number;
|
|
424
|
+
}>;
|
|
425
|
+
pagination?: {
|
|
426
|
+
limit: number;
|
|
427
|
+
offset: number;
|
|
428
|
+
total?: number;
|
|
429
|
+
};
|
|
430
|
+
}
|
|
431
|
+
export interface EventWindows {
|
|
432
|
+
eventId: string;
|
|
433
|
+
displayName?: string;
|
|
434
|
+
windows: Array<{
|
|
435
|
+
eventWindowId: string;
|
|
436
|
+
beginTime: string;
|
|
437
|
+
endTime: string;
|
|
438
|
+
round?: number;
|
|
439
|
+
}>;
|
|
440
|
+
}
|
|
441
|
+
export interface PlayerEventHistory {
|
|
442
|
+
eventId: string;
|
|
443
|
+
eventWindowId: string;
|
|
444
|
+
eventName?: string;
|
|
445
|
+
beginTime: string;
|
|
446
|
+
endTime: string;
|
|
447
|
+
region?: string;
|
|
448
|
+
}
|
|
449
|
+
export interface TournamentDetails {
|
|
450
|
+
eventId: string;
|
|
451
|
+
eventWindowId: string;
|
|
452
|
+
beginTime: string;
|
|
453
|
+
endTime: string;
|
|
454
|
+
round?: number;
|
|
455
|
+
payoutDelay?: number;
|
|
456
|
+
[key: string]: any;
|
|
457
|
+
}
|
|
458
|
+
export interface ScoringRules {
|
|
459
|
+
scoring: Array<{
|
|
460
|
+
eventName: string;
|
|
461
|
+
points: number;
|
|
462
|
+
}>;
|
|
463
|
+
}
|
|
464
|
+
export interface EventLeaderboard {
|
|
465
|
+
entries: Array<{
|
|
466
|
+
rank: number;
|
|
467
|
+
accountId: string;
|
|
468
|
+
teamId?: string;
|
|
469
|
+
pointsEarned: number;
|
|
470
|
+
score: number;
|
|
471
|
+
[key: string]: any;
|
|
472
|
+
}>;
|
|
473
|
+
}
|
|
474
|
+
export interface PlayerEventData {
|
|
475
|
+
accountId: string;
|
|
476
|
+
teamId?: string;
|
|
477
|
+
pointsEarned: number;
|
|
478
|
+
rank?: number;
|
|
479
|
+
percentile?: number;
|
|
480
|
+
sessions?: Array<any>;
|
|
481
|
+
}
|
|
482
|
+
export interface EligibilityStatus {
|
|
483
|
+
eligible: boolean;
|
|
484
|
+
reasons?: string[];
|
|
485
|
+
}
|
|
486
|
+
export interface ArenaHype {
|
|
487
|
+
accountId: string;
|
|
488
|
+
currentHype?: number;
|
|
489
|
+
division?: string;
|
|
490
|
+
divisionNumber?: number;
|
|
491
|
+
progress?: number;
|
|
492
|
+
}
|
|
493
|
+
export interface EventRewards {
|
|
494
|
+
prizes: Array<{
|
|
495
|
+
placement: string;
|
|
496
|
+
amount: number;
|
|
497
|
+
currency?: string;
|
|
498
|
+
}>;
|
|
499
|
+
}
|