@yaelouuu/fortnite-api 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +47 -0
- package/dist/client.d.ts +23 -0
- package/dist/client.js +49 -0
- package/dist/errors.d.ts +5 -0
- package/dist/errors.js +12 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.js +22 -0
- package/dist/resources/bundles.d.ts +14 -0
- package/dist/resources/bundles.js +21 -0
- package/dist/resources/calendar.d.ts +10 -0
- package/dist/resources/calendar.js +15 -0
- package/dist/resources/profiles.d.ts +22 -0
- package/dist/resources/profiles.js +34 -0
- package/dist/resources/shop.d.ts +10 -0
- package/dist/resources/shop.js +15 -0
- package/dist/resources/tournaments.d.ts +31 -0
- package/dist/resources/tournaments.js +46 -0
- package/dist/types/index.d.ts +60 -0
- package/dist/types/index.js +3 -0
- package/package.json +27 -0
package/README.md
ADDED
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
# Fortnite API SDK
|
|
2
|
+
|
|
3
|
+
JavaScript/TypeScript SDK for the Fortnite API by Royal Arena.
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm install @yaelouuu/fortnite-api
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Quick Start
|
|
12
|
+
|
|
13
|
+
```typescript
|
|
14
|
+
import { FortniteAPI } from "@yaelouuu/fortnite-api";
|
|
15
|
+
|
|
16
|
+
const client = new FortniteAPI({
|
|
17
|
+
apiKey: "your-api-key-here",
|
|
18
|
+
});
|
|
19
|
+
|
|
20
|
+
// Get current shop
|
|
21
|
+
const shop = await client.shop.getCurrent();
|
|
22
|
+
|
|
23
|
+
// Get tournament leaderboard
|
|
24
|
+
const leaderboard = await client.tournaments.getLeaderboard({
|
|
25
|
+
eventId: "epicgames_...",
|
|
26
|
+
eventWindowId: "S37_...",
|
|
27
|
+
page: 0,
|
|
28
|
+
});
|
|
29
|
+
|
|
30
|
+
// Get profile stats
|
|
31
|
+
const stats = await client.profiles.getStats("PlayerName");
|
|
32
|
+
|
|
33
|
+
// Get season info
|
|
34
|
+
const season = await client.calendar.getCurrentSeason();
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
## Features
|
|
38
|
+
|
|
39
|
+
- ✅ Full TypeScript support
|
|
40
|
+
- ✅ Promise-based async/await API
|
|
41
|
+
- ✅ Automatic error handling
|
|
42
|
+
- ✅ Built-in retry logic (optional)
|
|
43
|
+
- ✅ Tree-shakeable
|
|
44
|
+
|
|
45
|
+
## Documentation
|
|
46
|
+
|
|
47
|
+
Full API documentation: https://api.api-fortnite.com/documentation
|
package/dist/client.d.ts
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { ShopResource } from "./resources/shop";
|
|
2
|
+
import { TournamentsResource } from "./resources/tournaments";
|
|
3
|
+
import { ProfilesResource } from "./resources/profiles";
|
|
4
|
+
import { CalendarResource } from "./resources/calendar";
|
|
5
|
+
import { BundlesResource } from "./resources/bundles";
|
|
6
|
+
export interface ClientOptions {
|
|
7
|
+
apiKey: string;
|
|
8
|
+
baseUrl?: string;
|
|
9
|
+
}
|
|
10
|
+
export declare class FortniteAPI {
|
|
11
|
+
private apiKey;
|
|
12
|
+
private baseUrl;
|
|
13
|
+
shop: ShopResource;
|
|
14
|
+
tournaments: TournamentsResource;
|
|
15
|
+
profiles: ProfilesResource;
|
|
16
|
+
calendar: CalendarResource;
|
|
17
|
+
bundles: BundlesResource;
|
|
18
|
+
constructor(options: ClientOptions);
|
|
19
|
+
/**
|
|
20
|
+
* Internal method to make HTTP requests
|
|
21
|
+
*/
|
|
22
|
+
request<T>(endpoint: string, options?: RequestInit): Promise<T>;
|
|
23
|
+
}
|
package/dist/client.js
ADDED
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.FortniteAPI = void 0;
|
|
4
|
+
const shop_1 = require("./resources/shop");
|
|
5
|
+
const tournaments_1 = require("./resources/tournaments");
|
|
6
|
+
const profiles_1 = require("./resources/profiles");
|
|
7
|
+
const calendar_1 = require("./resources/calendar");
|
|
8
|
+
const errors_1 = require("./errors");
|
|
9
|
+
const bundles_1 = require("./resources/bundles");
|
|
10
|
+
class FortniteAPI {
|
|
11
|
+
constructor(options) {
|
|
12
|
+
this.apiKey = options.apiKey;
|
|
13
|
+
this.baseUrl = options.baseUrl || "https://prod.api-fortnite.com/api/v1";
|
|
14
|
+
// this.baseUrl = options.baseUrl || "http://localhost:4321/api/v1";
|
|
15
|
+
// Initialize resources
|
|
16
|
+
this.shop = new shop_1.ShopResource(this);
|
|
17
|
+
this.tournaments = new tournaments_1.TournamentsResource(this);
|
|
18
|
+
this.profiles = new profiles_1.ProfilesResource(this);
|
|
19
|
+
this.calendar = new calendar_1.CalendarResource(this);
|
|
20
|
+
this.bundles = new bundles_1.BundlesResource(this);
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Internal method to make HTTP requests
|
|
24
|
+
*/
|
|
25
|
+
async request(endpoint, options = {}) {
|
|
26
|
+
const url = `${this.baseUrl}${endpoint}`;
|
|
27
|
+
const response = await fetch(url, {
|
|
28
|
+
...options,
|
|
29
|
+
headers: {
|
|
30
|
+
"x-api-key": this.apiKey,
|
|
31
|
+
"Content-Type": "application/json",
|
|
32
|
+
...options.headers,
|
|
33
|
+
},
|
|
34
|
+
});
|
|
35
|
+
if (!response.ok) {
|
|
36
|
+
let errorData;
|
|
37
|
+
try {
|
|
38
|
+
errorData = await response.json();
|
|
39
|
+
}
|
|
40
|
+
catch {
|
|
41
|
+
errorData = { error: "Request failed" };
|
|
42
|
+
}
|
|
43
|
+
throw new errors_1.FortniteAPIError(errorData.error || `Request failed with status ${response.status}`, response.status, errorData);
|
|
44
|
+
}
|
|
45
|
+
const data = await response.json();
|
|
46
|
+
return data;
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
exports.FortniteAPI = FortniteAPI;
|
package/dist/errors.d.ts
ADDED
package/dist/errors.js
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.FortniteAPIError = void 0;
|
|
4
|
+
class FortniteAPIError extends Error {
|
|
5
|
+
constructor(message, status, data) {
|
|
6
|
+
super(message);
|
|
7
|
+
this.name = "FortniteAPIError";
|
|
8
|
+
this.status = status;
|
|
9
|
+
this.data = data;
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
exports.FortniteAPIError = FortniteAPIError;
|
package/dist/index.d.ts
ADDED
package/dist/index.js
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
exports.FortniteAPIError = exports.FortniteAPI = void 0;
|
|
18
|
+
var client_1 = require("./client");
|
|
19
|
+
Object.defineProperty(exports, "FortniteAPI", { enumerable: true, get: function () { return client_1.FortniteAPI; } });
|
|
20
|
+
__exportStar(require("./types"), exports);
|
|
21
|
+
var errors_1 = require("./errors");
|
|
22
|
+
Object.defineProperty(exports, "FortniteAPIError", { enumerable: true, get: function () { return errors_1.FortniteAPIError; } });
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { FortniteAPI } from "../client";
|
|
2
|
+
import { TournamentsBundle, ShopBundle } from "../types";
|
|
3
|
+
export declare class BundlesResource {
|
|
4
|
+
private client;
|
|
5
|
+
constructor(client: FortniteAPI);
|
|
6
|
+
/**
|
|
7
|
+
* Get current season information
|
|
8
|
+
*/
|
|
9
|
+
getBundlesTournament(): Promise<TournamentsBundle>;
|
|
10
|
+
/**
|
|
11
|
+
* Get current season information
|
|
12
|
+
*/
|
|
13
|
+
getBundlesShop(): Promise<ShopBundle>;
|
|
14
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.BundlesResource = void 0;
|
|
4
|
+
class BundlesResource {
|
|
5
|
+
constructor(client) {
|
|
6
|
+
this.client = client;
|
|
7
|
+
}
|
|
8
|
+
/**
|
|
9
|
+
* Get current season information
|
|
10
|
+
*/
|
|
11
|
+
async getBundlesTournament() {
|
|
12
|
+
return this.client.request("/assets/bundles/tournaments");
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* Get current season information
|
|
16
|
+
*/
|
|
17
|
+
async getBundlesShop() {
|
|
18
|
+
return this.client.request("/assets/bundles/shop");
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
exports.BundlesResource = BundlesResource;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { FortniteAPI } from "../client";
|
|
2
|
+
import { SeasonInfo } from "../types";
|
|
3
|
+
export declare class CalendarResource {
|
|
4
|
+
private client;
|
|
5
|
+
constructor(client: FortniteAPI);
|
|
6
|
+
/**
|
|
7
|
+
* Get current season information
|
|
8
|
+
*/
|
|
9
|
+
getCurrentSeason(): Promise<SeasonInfo>;
|
|
10
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.CalendarResource = void 0;
|
|
4
|
+
class CalendarResource {
|
|
5
|
+
constructor(client) {
|
|
6
|
+
this.client = client;
|
|
7
|
+
}
|
|
8
|
+
/**
|
|
9
|
+
* Get current season information
|
|
10
|
+
*/
|
|
11
|
+
async getCurrentSeason() {
|
|
12
|
+
return this.client.request("/season");
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
exports.CalendarResource = CalendarResource;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { FortniteAPI } from "../client";
|
|
2
|
+
import { Profile, ProfileStats } from "../types";
|
|
3
|
+
export declare class ProfilesResource {
|
|
4
|
+
private client;
|
|
5
|
+
constructor(client: FortniteAPI);
|
|
6
|
+
/**
|
|
7
|
+
* Get profile progress by display name
|
|
8
|
+
*/
|
|
9
|
+
getProgress(displayName: string): Promise<any>;
|
|
10
|
+
/**
|
|
11
|
+
* Get profile stats by display name
|
|
12
|
+
*/
|
|
13
|
+
getStats(displayName: string): Promise<ProfileStats>;
|
|
14
|
+
/**
|
|
15
|
+
* Get account info by ID
|
|
16
|
+
*/
|
|
17
|
+
getAccount(accountId: string): Promise<Profile>;
|
|
18
|
+
/**
|
|
19
|
+
* Get multiple display names
|
|
20
|
+
*/
|
|
21
|
+
getDisplayNames(accountIds: string[]): Promise<Record<string, string>>;
|
|
22
|
+
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ProfilesResource = void 0;
|
|
4
|
+
class ProfilesResource {
|
|
5
|
+
constructor(client) {
|
|
6
|
+
this.client = client;
|
|
7
|
+
}
|
|
8
|
+
/**
|
|
9
|
+
* Get profile progress by display name
|
|
10
|
+
*/
|
|
11
|
+
async getProgress(displayName) {
|
|
12
|
+
return this.client.request(`/profile/progress?displayName=${displayName}`);
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* Get profile stats by display name
|
|
16
|
+
*/
|
|
17
|
+
async getStats(displayName) {
|
|
18
|
+
return this.client.request(`/profile/stats?displayName=${displayName}`);
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Get account info by ID
|
|
22
|
+
*/
|
|
23
|
+
async getAccount(accountId) {
|
|
24
|
+
return this.client.request(`/account/${accountId}`);
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Get multiple display names
|
|
28
|
+
*/
|
|
29
|
+
async getDisplayNames(accountIds) {
|
|
30
|
+
const ids = accountIds.join(",");
|
|
31
|
+
return this.client.request(`/displaynames/multiple?ids=${ids}`);
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
exports.ProfilesResource = ProfilesResource;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ShopResource = void 0;
|
|
4
|
+
class ShopResource {
|
|
5
|
+
constructor(client) {
|
|
6
|
+
this.client = client;
|
|
7
|
+
}
|
|
8
|
+
/**
|
|
9
|
+
* Get current shop items
|
|
10
|
+
*/
|
|
11
|
+
async getCurrent() {
|
|
12
|
+
return this.client.request("/shop");
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
exports.ShopResource = ShopResource;
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { FortniteAPI } from "../client";
|
|
2
|
+
import { Leaderboard } from "../types";
|
|
3
|
+
export declare class TournamentsResource {
|
|
4
|
+
private client;
|
|
5
|
+
constructor(client: FortniteAPI);
|
|
6
|
+
/**
|
|
7
|
+
* Get current events
|
|
8
|
+
*/
|
|
9
|
+
getCurrent(params?: {
|
|
10
|
+
accountId?: string;
|
|
11
|
+
}): Promise<any>;
|
|
12
|
+
/**
|
|
13
|
+
* Get past events
|
|
14
|
+
*/
|
|
15
|
+
getPast(params?: {
|
|
16
|
+
accountId?: string;
|
|
17
|
+
}): Promise<any>;
|
|
18
|
+
/**
|
|
19
|
+
* Get global events
|
|
20
|
+
*/
|
|
21
|
+
getGlobal(): Promise<any>;
|
|
22
|
+
/**
|
|
23
|
+
* Get tournament leaderboard
|
|
24
|
+
*/
|
|
25
|
+
getLeaderboard(params: {
|
|
26
|
+
eventId: string;
|
|
27
|
+
eventWindowId: string;
|
|
28
|
+
page?: number;
|
|
29
|
+
leaderboardDef?: string;
|
|
30
|
+
}): Promise<Leaderboard>;
|
|
31
|
+
}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.TournamentsResource = void 0;
|
|
4
|
+
class TournamentsResource {
|
|
5
|
+
constructor(client) {
|
|
6
|
+
this.client = client;
|
|
7
|
+
}
|
|
8
|
+
/**
|
|
9
|
+
* Get current events
|
|
10
|
+
*/
|
|
11
|
+
async getCurrent(params) {
|
|
12
|
+
const queryString = params?.accountId
|
|
13
|
+
? `?accountId=${params.accountId}`
|
|
14
|
+
: "";
|
|
15
|
+
return this.client.request(`/events/data/current${queryString}`);
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Get past events
|
|
19
|
+
*/
|
|
20
|
+
async getPast(params) {
|
|
21
|
+
const queryString = params?.accountId
|
|
22
|
+
? `?accountId=${params.accountId}`
|
|
23
|
+
: "";
|
|
24
|
+
return this.client.request(`/events/data/past${queryString}`);
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Get global events
|
|
28
|
+
*/
|
|
29
|
+
async getGlobal() {
|
|
30
|
+
return this.client.request("/events/global");
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Get tournament leaderboard
|
|
34
|
+
*/
|
|
35
|
+
async getLeaderboard(params) {
|
|
36
|
+
const { eventId, eventWindowId, page = 0, leaderboardDef } = params;
|
|
37
|
+
const query = new URLSearchParams({
|
|
38
|
+
eventId,
|
|
39
|
+
eventWindowId,
|
|
40
|
+
page: page.toString(),
|
|
41
|
+
...(leaderboardDef && { leaderboardDef }),
|
|
42
|
+
}).toString();
|
|
43
|
+
return this.client.request(`/events/leaderboard?${query}`);
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
exports.TournamentsResource = TournamentsResource;
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
export interface Shop {
|
|
2
|
+
date: string;
|
|
3
|
+
bundles: ShopBundle[];
|
|
4
|
+
}
|
|
5
|
+
export interface ShopBundle {
|
|
6
|
+
id: string;
|
|
7
|
+
name: string;
|
|
8
|
+
price: number;
|
|
9
|
+
items: ShopItem[];
|
|
10
|
+
}
|
|
11
|
+
export interface TournamentsBundle {
|
|
12
|
+
}
|
|
13
|
+
export interface ShopItem {
|
|
14
|
+
id: string;
|
|
15
|
+
name: string;
|
|
16
|
+
type: string;
|
|
17
|
+
rarity: string;
|
|
18
|
+
images: {
|
|
19
|
+
icon: string;
|
|
20
|
+
featured?: string;
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
export interface Tournament {
|
|
24
|
+
eventId: string;
|
|
25
|
+
eventName: string;
|
|
26
|
+
beginTime: string;
|
|
27
|
+
endTime: string;
|
|
28
|
+
regions: string[];
|
|
29
|
+
}
|
|
30
|
+
export interface Leaderboard {
|
|
31
|
+
gameId: string;
|
|
32
|
+
eventId: string;
|
|
33
|
+
eventWindowId: string;
|
|
34
|
+
page: number;
|
|
35
|
+
totalPages: number;
|
|
36
|
+
entries: LeaderboardEntry[];
|
|
37
|
+
}
|
|
38
|
+
export interface LeaderboardEntry {
|
|
39
|
+
teamAccountIds: string[];
|
|
40
|
+
teamAccountDisplayNames: string[];
|
|
41
|
+
pointsEarned: number;
|
|
42
|
+
rank: number;
|
|
43
|
+
sessionHistory: any[];
|
|
44
|
+
}
|
|
45
|
+
export interface Profile {
|
|
46
|
+
id: string;
|
|
47
|
+
displayName: string;
|
|
48
|
+
email?: string;
|
|
49
|
+
country?: string;
|
|
50
|
+
}
|
|
51
|
+
export interface ProfileStats {
|
|
52
|
+
accountId: string;
|
|
53
|
+
stats: Record<string, number>;
|
|
54
|
+
}
|
|
55
|
+
export interface SeasonInfo {
|
|
56
|
+
seasonDateBegin: string;
|
|
57
|
+
seasonDateEnd: string;
|
|
58
|
+
seasonNumber: number;
|
|
59
|
+
exTime: number;
|
|
60
|
+
}
|
package/package.json
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@yaelouuu/fortnite-api",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "SDK for Fortnite Tournaments API by Royal Arena - Author : yaelouuu",
|
|
5
|
+
"main": "dist/index.js",
|
|
6
|
+
"types": "dist/index.d.ts",
|
|
7
|
+
"scripts": {
|
|
8
|
+
"build": "tsc",
|
|
9
|
+
"prepublishOnly": "npm run build"
|
|
10
|
+
},
|
|
11
|
+
"keywords": [
|
|
12
|
+
"fortnite",
|
|
13
|
+
"api",
|
|
14
|
+
"tournaments",
|
|
15
|
+
"sdk"
|
|
16
|
+
],
|
|
17
|
+
"author": "Your Name",
|
|
18
|
+
"license": "MIT",
|
|
19
|
+
"devDependencies": {
|
|
20
|
+
"@types/node": "^20.0.0",
|
|
21
|
+
"typescript": "^5.0.0"
|
|
22
|
+
},
|
|
23
|
+
"files": [
|
|
24
|
+
"dist",
|
|
25
|
+
"README.md"
|
|
26
|
+
]
|
|
27
|
+
}
|