fnapi-js 1.1.2 → 2.0.0-beta.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/LICENSE CHANGED
@@ -1,21 +1,21 @@
1
- MIT License
2
-
3
- Copyright (c) 2025 Ajaxfnc
4
-
5
- Permission is hereby granted, free of charge, to any person obtaining a copy
6
- of this software and associated documentation files (the "Software"), to deal
7
- in the Software without restriction, including without limitation the rights
8
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
- copies of the Software, and to permit persons to whom the Software is
10
- furnished to do so, subject to the following conditions:
11
-
12
- The above copyright notice and this permission notice shall be included in all
13
- copies or substantial portions of the Software.
14
-
15
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
- SOFTWARE.
1
+ MIT License
2
+
3
+ Copyright (c) 2025 Ajaxfnc
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,78 +1,102 @@
1
1
  # fnapi-js
2
2
 
3
- An unofficial JavaScript/Typescript wrapper for the [Fortnite-API](https://fortnite-api.com/) REST API.
3
+ Zero-dependency TypeScript wrapper for the public Fortnite APIs, with a complete Epic Games account-service auth, realtime (XMPP/EOS), party, MCP and item-shop/gifting layer.
4
4
 
5
- ## Installation
5
+ [![license](https://img.shields.io/badge/license-MIT-blue.svg)](./LICENSE)
6
+ [![node](https://img.shields.io/badge/node-%3E%3D18-brightgreen.svg)](https://nodejs.org)
7
+ [![types](https://img.shields.io/badge/types-included-blue.svg)](#)
8
+
9
+ ## Install
6
10
 
7
11
  ```bash
8
12
  npm install fnapi-js
9
13
  ```
10
14
 
11
- ## Usage
15
+ Node 18+. Ships dual ESM/CJS builds and full `.d.ts` types; works identically from TypeScript and plain JavaScript. No runtime dependencies.
16
+
17
+ ## Two halves
18
+
19
+ Everything is imported from the package root:
20
+
21
+ ```ts
22
+ import { FortniteAPI, EpicGamesClient } from 'fnapi-js';
23
+ ```
24
+
25
+ - **`FortniteAPI`** — the [fortnite-api.com](https://fortnite-api.com) wrapper: `shop`, `cosmetics`, `aes`, `banners`, `creatorCode` (`sac`), `map`, `news`, `playlists`, `stats`.
26
+ - **`EpicGamesClient`** — the Epic Games account service: every OAuth grant, device-code login, device auths, account lookups, sessions with auto-refresh — and on top of a signed-in session: MCP profile operations, the item shop + gifting, friends, party create/join/lifecycle, XMPP + EOS realtime, and an event-driven `LiveClient` bot.
27
+
28
+ ## Quick start
29
+
30
+ ### Fortnite API
31
+
32
+ ```ts
33
+ import { FortniteAPI, Language, MatchMethod } from 'fnapi-js';
34
+
35
+ const client = new FortniteAPI({ language: Language.English });
36
+
37
+ const shop = await client.shop.get();
38
+ console.log(`Shop for ${shop.date} has ${shop.entries.length} entries`);
39
+
40
+ const renegade = await client.cosmetics.search({
41
+ name: 'Renegade Raider',
42
+ matchMethod: MatchMethod.Full,
43
+ });
44
+ console.log(`${renegade.name} — ${renegade.rarity.displayValue}`);
45
+ ```
46
+
47
+ ### Epic Games auth
12
48
 
13
- ```javascript
14
- // ESM
15
- import { ApiClient, Enums } from 'fnapi-js';
49
+ ```ts
50
+ import { EpicGamesClient } from 'fnapi-js';
16
51
 
17
- // CommonJS
18
- const { ApiClient, Enums } = require('fnapi-js');
52
+ const epic = new EpicGamesClient();
19
53
 
20
- // Initialize the client
21
- const fnApi = new ApiClient({ apiKey: 'your-api-key' });
54
+ const session = await epic.loginClientCredentials();
55
+ const verified = await session.verify();
56
+ console.log(`verified client ${verified.client_id}`);
57
+ await session.logout();
58
+ ```
59
+
60
+ To sign in as a user, use the device-code flow — see the docs.
22
61
 
23
- // Get player stats
24
- const stats = await fnApi.stats.get(
25
- 'username',
26
- Enums.accountType.epic(),
27
- Enums.timeWindow.lifetime(),
28
- Enums.statsImage.all()
29
- );
62
+ ### Live bot, shop & party
30
63
 
31
- // Search cosmetics
32
- const searchOptions = new SearchOptions()
33
- .setType('outfit')
34
- .setRarity('epic')
35
- .setMatchMethod(Enums.matchMethod.contains());
64
+ ```ts
65
+ const session = await epic.loginWithDeviceAuth(creds);
36
66
 
37
- const cosmetics = await fnApi.cosmetics.searchCosmetics(searchOptions);
67
+ const bot = await session.live();
68
+ bot.on('friend:request', (request) => request.accept());
69
+ bot.on('party:invite', (invite) => invite.accept());
38
70
 
39
- // Get creator code
40
- const creatorCode = await fnApi.sac.get('code');
71
+ const shop = await session.shop();
72
+ await shop.find('Renegade Raider')?.gift('SomeFriend');
73
+
74
+ const party = await bot.createParty();
75
+ await party.setPrivacy('private');
76
+ ```
41
77
 
42
- // Get AES keys
43
- const aesKeys = await fnApi.aes.getKeys();
78
+ ## Configuration
79
+
80
+ Runtime configuration lives in `config.json` (no `.env`). Copy the template and fill in your own values:
81
+
82
+ ```bash
83
+ cp config.example.json config.json
44
84
  ```
45
85
 
46
- ## Check out the docs
47
- - [Documentation](https://github.com/AjaxFNC-YT/fnapi-js/blob/main/src/docs/DOCUMENTATION.md)
48
-
49
- ## Available Endpoints
50
-
51
- - Stats
52
- - Get player stats
53
- - Get stats by account ID
54
- - Cosmetics
55
- - Search cosmetics
56
- - Get new cosmetics
57
- - Get by ID
58
- - Get tracks, instruments, cars, LEGO items, etc.
59
- - Creator Codes
60
- - Get creator code info
61
- - AES
62
- - Get encryption keys
63
- - Map
64
- - Get current map info
65
- - News
66
- - Get game news
67
- - Playlists
68
- - Get available playlists
69
- - Get playlist by ID
70
- - Shop
71
- - Get current shop items
72
- - Banners
73
- - Get all available banners
74
- - Get all avaible banner colors
86
+ `config.json` is git-ignored it holds account/device-auth secrets and must never be committed.
87
+
88
+ ## Documentation
89
+
90
+ The full API reference is consolidated in [`docs.md`](./docs.md), and the source pages live under [`docs/`](./docs) (built with VitePress).
91
+
92
+ ## CLI
93
+
94
+ An interactive CLI covers most of the surface — auth, shop, gifting, party, live events, Fortnite endpoints:
95
+
96
+ ```bash
97
+ npm run cli
98
+ ```
75
99
 
76
100
  ## License
77
101
 
78
- MIT
102
+ [MIT](./LICENSE)
@@ -0,0 +1,24 @@
1
+ {
2
+ "apiKey": "",
3
+ "language": "en",
4
+ "timeout": 30000,
5
+ "retries": 3,
6
+ "cache": {
7
+ "enabled": false,
8
+ "ttl": 60000
9
+ },
10
+ "live": {
11
+ "playerName": "Ninja",
12
+ "cosmeticId": "CID_028_Athena_Commando_F",
13
+ "playlistId": "playlist_defaultsolo",
14
+ "creatorCode": "ninja"
15
+ },
16
+ "epic": {
17
+ "client": "fortniteAndroid",
18
+ "deviceAuth": {
19
+ "accountId": "",
20
+ "deviceId": "",
21
+ "secret": ""
22
+ }
23
+ }
24
+ }