@yaelouuu/fortnite-api 9.0.0 → 9.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/README.md CHANGED
@@ -115,7 +115,9 @@ const tracker = await client.tournaments.getTracker(
115
115
  "accountId",
116
116
  "fortniteToken"
117
117
  );
118
- // Returns: All tournaments the player has participated in
118
+ // Returns: tournaments the player took part in over the last 180 days.
119
+ // The first call for an account queues a backfill of a few minutes: while
120
+ // tracker.history.complete is false the count is a lower bound — re-poll.
119
121
  ```
120
122
 
121
123
  #### Player Result in One Tournament — **no user token**
@@ -135,8 +137,8 @@ console.log(result.teamAccountIds.length); // 2 -> team size
135
137
  console.log(result.matches[0].trackedStats.PLACEMENT_STAT_INDEX);
136
138
  ```
137
139
 
138
- #### Full Match History — **token required**
139
- Every tournament match a player has played, grouped by event window. Epic only serves this to the player it belongs to, so a token-less call returns `403`:
140
+ #### Recent Tournament Sessions — **token required**
141
+ A player's recent tournament sessions, grouped by event window. Epic keeps roughly the last **36 hours** of this data, so it is not a full history (use the tracker for 180 days), and private custom-key matches never appear. Epic only serves it to the player it belongs to, so a token-less call returns `403`:
140
142
 
141
143
  ```typescript
142
144
  const matches = await client.tournaments.getPlayerMatches(
@@ -146,6 +148,18 @@ const matches = await client.tournaments.getPlayerMatches(
146
148
  );
147
149
  ```
148
150
 
151
+ #### Current Match of a Consenting Player — **token required, Custom plan**
152
+ The match a player is in right now, any mode — Battle Royale, Reload, Ranked or a custom-key scrim hosted by anyone. The only route to non-tournament matches: Epic has no match-history listing. `sessionId` is the replay match ID; `playlist` lets you filter for scrims before parsing.
153
+
154
+ ```typescript
155
+ const session = await client.tournaments.getPlayerSession("accountId", "fortniteToken");
156
+ if (session.inMatch && session.playlist === "playlist_showdown_cts_solo") {
157
+ console.log(session.sessionId); // parse it with the replay endpoints once the match has ended
158
+ }
159
+ ```
160
+
161
+ Read before building on it: the token must be that player's **own** (verified — any other account's token is `403`); Fortnite kills every other session of an account when the game launches, so mint it from stored device auth (`/oauth/link`, then `/oauth/refresh-device` on `401`); the response is cached 10 s per account and Epic's party state lags the real match by about 1–2 minutes; the custom key is never returned (`hasCustomKey` only) and teammates appear as account ids only.
162
+
149
163
  #### Check Tournament Eligibility
150
164
  Verify if a player meets requirements for major tournaments (e.g., 14 tournaments in 180 days):
151
165
 
@@ -1,5 +1,5 @@
1
1
  import { FortniteAPI } from "../client";
2
- import { Leaderboard, TournamentTrackerResponse, TournamentEligibilityResponse, EventTokenEligibilityResponse, CashPrizesResponse, PayoutTable } from "../types";
2
+ import { Leaderboard, TournamentTrackerResponse, TournamentEligibilityResponse, EventTokenEligibilityResponse, CashPrizesResponse, PayoutTable, PlayerSession } from "../types";
3
3
  export declare class TournamentsResource {
4
4
  private client;
5
5
  constructor(client: FortniteAPI);
@@ -91,18 +91,21 @@ export declare class TournamentsResource {
91
91
  maxPages?: number;
92
92
  }): Promise<any>;
93
93
  /**
94
- * Get every tournament match a player has played, grouped by event window.
94
+ * A player's RECENT tournament sessions, grouped by event window. Epic keeps roughly
95
+ * the last 36 hours of this data — it is not a full history. Tournament sessions
96
+ * only: private custom-key matches never appear here.
95
97
  *
96
98
  * Sourced from Epic's player-scoped download data, which Epic only serves to the
97
- * player it belongs to — so `fortniteToken` is effectively required (without it
98
- * Epic returns **403**). For a token-free lookup scoped to one tournament, use
99
- * {@link getPlayerWindowMatches}.
99
+ * player it belongs to — so `fortniteToken` is required (without it Epic returns
100
+ * **403**). For a 180-day participation history use {@link getTracker}; for a
101
+ * token-free lookup scoped to one tournament use {@link getPlayerWindowMatches};
102
+ * for the match a player is in right now use {@link getPlayerSession}.
100
103
  *
101
104
  * @param accountId - Epic Games Account ID
102
105
  * @param fortniteToken - Fortnite access token of that same player (from OAuth flow)
103
106
  * @param options.after - Only matches ending at or after this UTC timestamp
104
107
  * @param options.before - Only matches ending before this UTC timestamp
105
- * @param options.region - Region for the events catalogue (default: EU). Match history itself is global.
108
+ * @param options.region - Region for the events catalogue (default: EU). The sessions themselves are global.
106
109
  * @param options.platform - Platform (default: Windows)
107
110
  */
108
111
  getPlayerMatches(accountId: string, fortniteToken: string, options?: {
@@ -266,4 +269,26 @@ export declare class TournamentsResource {
266
269
  eventWindowId: string;
267
270
  leaderboardDef?: string;
268
271
  }, teams: string[][], fortniteToken?: string): Promise<Leaderboard>;
272
+ /**
273
+ * The match a consenting player is in right now — any mode: Battle Royale, Reload,
274
+ * Ranked, or a custom-key scrim hosted by anyone. This is the only route to a player's
275
+ * non-tournament matches: Epic exposes no match-history listing. **Custom plan.**
276
+ *
277
+ * Requires that player's OWN Fortnite token: it is verified against `accountId` before
278
+ * anything is forwarded (any other account's token returns **403**). Fortnite kills every
279
+ * other session of an account when the game launches, so a token obtained before the
280
+ * player started playing is dead by the time they play — obtain it from stored device
281
+ * auth (`/oauth/link` once, then `/oauth/refresh-device` on 401), not a one-off login.
282
+ *
283
+ * While the player is in a game, `sessionId` is the replay match ID: pass it to the
284
+ * replay endpoints once the match has ended. `playlist` lets you filter (e.g. scrims)
285
+ * before parsing. Cached 10 s per account (polling faster gains nothing); Epic's own
286
+ * party state lags the real match by about 1-2 minutes; a session ID does not change
287
+ * during a match. Never returns the custom match key (`hasCustomKey` only) nor
288
+ * teammates' state (account ids only). `inParty` is false when the client is offline.
289
+ *
290
+ * @param accountId - Epic Games Account ID
291
+ * @param fortniteToken - That same player's Fortnite access token
292
+ */
293
+ getPlayerSession(accountId: string, fortniteToken: string): Promise<PlayerSession>;
269
294
  }
@@ -127,18 +127,21 @@ class TournamentsResource {
127
127
  return this.client.request(`/events/${encodeURIComponent(eventId)}/${encodeURIComponent(eventWindowId)}/player/${encodeURIComponent(accountId)}/matches${qs ? `?${qs}` : ""}`);
128
128
  }
129
129
  /**
130
- * Get every tournament match a player has played, grouped by event window.
130
+ * A player's RECENT tournament sessions, grouped by event window. Epic keeps roughly
131
+ * the last 36 hours of this data — it is not a full history. Tournament sessions
132
+ * only: private custom-key matches never appear here.
131
133
  *
132
134
  * Sourced from Epic's player-scoped download data, which Epic only serves to the
133
- * player it belongs to — so `fortniteToken` is effectively required (without it
134
- * Epic returns **403**). For a token-free lookup scoped to one tournament, use
135
- * {@link getPlayerWindowMatches}.
135
+ * player it belongs to — so `fortniteToken` is required (without it Epic returns
136
+ * **403**). For a 180-day participation history use {@link getTracker}; for a
137
+ * token-free lookup scoped to one tournament use {@link getPlayerWindowMatches};
138
+ * for the match a player is in right now use {@link getPlayerSession}.
136
139
  *
137
140
  * @param accountId - Epic Games Account ID
138
141
  * @param fortniteToken - Fortnite access token of that same player (from OAuth flow)
139
142
  * @param options.after - Only matches ending at or after this UTC timestamp
140
143
  * @param options.before - Only matches ending before this UTC timestamp
141
- * @param options.region - Region for the events catalogue (default: EU). Match history itself is global.
144
+ * @param options.region - Region for the events catalogue (default: EU). The sessions themselves are global.
142
145
  * @param options.platform - Platform (default: Windows)
143
146
  */
144
147
  async getPlayerMatches(accountId, fortniteToken, options) {
@@ -359,5 +362,29 @@ class TournamentsResource {
359
362
  }
360
363
  return this.client.request(`/events/leaderboard?${query.toString()}`, options, "v2");
361
364
  }
365
+ /**
366
+ * The match a consenting player is in right now — any mode: Battle Royale, Reload,
367
+ * Ranked, or a custom-key scrim hosted by anyone. This is the only route to a player's
368
+ * non-tournament matches: Epic exposes no match-history listing. **Custom plan.**
369
+ *
370
+ * Requires that player's OWN Fortnite token: it is verified against `accountId` before
371
+ * anything is forwarded (any other account's token returns **403**). Fortnite kills every
372
+ * other session of an account when the game launches, so a token obtained before the
373
+ * player started playing is dead by the time they play — obtain it from stored device
374
+ * auth (`/oauth/link` once, then `/oauth/refresh-device` on 401), not a one-off login.
375
+ *
376
+ * While the player is in a game, `sessionId` is the replay match ID: pass it to the
377
+ * replay endpoints once the match has ended. `playlist` lets you filter (e.g. scrims)
378
+ * before parsing. Cached 10 s per account (polling faster gains nothing); Epic's own
379
+ * party state lags the real match by about 1-2 minutes; a session ID does not change
380
+ * during a match. Never returns the custom match key (`hasCustomKey` only) nor
381
+ * teammates' state (account ids only). `inParty` is false when the client is offline.
382
+ *
383
+ * @param accountId - Epic Games Account ID
384
+ * @param fortniteToken - That same player's Fortnite access token
385
+ */
386
+ async getPlayerSession(accountId, fortniteToken) {
387
+ return this.client.request(`/events/player/${encodeURIComponent(accountId)}/session`, { headers: { "x-fortnite-token": fortniteToken } });
388
+ }
362
389
  }
363
390
  exports.TournamentsResource = TournamentsResource;
@@ -1187,3 +1187,30 @@ export interface SpriteBoonsResponse {
1187
1187
  status: number;
1188
1188
  data: SpriteBoon[];
1189
1189
  }
1190
+ /** GET /events/player/{accountId}/session — the match a consenting player is in right now. */
1191
+ export interface PlayerSession {
1192
+ accountId: string;
1193
+ /** False when the player's client is offline; no other field is meaningful then. */
1194
+ inParty: boolean;
1195
+ inMatch: boolean;
1196
+ /** The replay match ID while in a game; null in the lobby or offline. */
1197
+ sessionId: string | null;
1198
+ partySize?: number;
1199
+ isLeader?: boolean;
1200
+ /** e.g. "PreLobby" | "InGame" */
1201
+ location?: string | null;
1202
+ gameMode?: string | null;
1203
+ /** e.g. "playlist_showdown_cts_solo" — what they play, or what they have selected in the lobby. */
1204
+ playlist?: string | null;
1205
+ region?: string | null;
1206
+ /** The party runs on a custom match key. The key itself is never returned. */
1207
+ hasCustomKey?: boolean;
1208
+ matchStartedAt?: string | null;
1209
+ playersLeft?: number | null;
1210
+ /** Teammates by account id only. */
1211
+ members?: Array<{
1212
+ accountId: string | null;
1213
+ isLeader: boolean;
1214
+ }>;
1215
+ note?: string;
1216
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@yaelouuu/fortnite-api",
3
- "version": "9.0.0",
3
+ "version": "9.1.0",
4
4
  "description": "SDK for Fortnite API - api-fortnite.com - Author : Yael Brinkert",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",