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 +21 -21
- package/README.md +81 -57
- package/config.example.json +24 -0
- package/dist/index.cjs +10508 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +5737 -0
- package/dist/index.d.ts +5737 -0
- package/dist/index.js +10218 -0
- package/dist/index.js.map +1 -0
- package/docs.md +8848 -0
- package/package.json +54 -13
- package/src/client/Aes.js +0 -23
- package/src/client/ApiClient.js +0 -114
- package/src/client/Banners.js +0 -23
- package/src/client/Cosmetics.js +0 -103
- package/src/client/CreatorCode.js +0 -19
- package/src/client/Map.js +0 -15
- package/src/client/Misc.js +0 -21
- package/src/client/News.js +0 -16
- package/src/client/Playlists.js +0 -25
- package/src/client/Shop.js +0 -17
- package/src/client/Stats.js +0 -50
- package/src/docs/DOCUMENTATION.md +0 -435
- package/src/enums/AccountType.js +0 -11
- package/src/enums/CosmeticType.js +0 -251
- package/src/enums/Language.js +0 -58
- package/src/enums/MatchMethod.js +0 -14
- package/src/enums/RequestFlags.js +0 -62
- package/src/enums/StatsImage.js +0 -15
- package/src/enums/TimeWindow.js +0 -9
- package/src/examples/api-example.js +0 -220
- package/src/examples/fnbrjsAndfnapi.js +0 -63
- package/src/http/Response.js +0 -30
- package/src/index.d.ts +0 -503
- package/src/index.js +0 -13
- package/src/types/SearchOptions.js +0 -50
- package/src/utils/Enums.js +0 -39
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
|
-
|
|
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
|
-
|
|
5
|
+
[](./LICENSE)
|
|
6
|
+
[](https://nodejs.org)
|
|
7
|
+
[](#)
|
|
8
|
+
|
|
9
|
+
## Install
|
|
6
10
|
|
|
7
11
|
```bash
|
|
8
12
|
npm install fnapi-js
|
|
9
13
|
```
|
|
10
14
|
|
|
11
|
-
|
|
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
|
-
```
|
|
14
|
-
|
|
15
|
-
import { ApiClient, Enums } from 'fnapi-js';
|
|
49
|
+
```ts
|
|
50
|
+
import { EpicGamesClient } from 'fnapi-js';
|
|
16
51
|
|
|
17
|
-
|
|
18
|
-
const { ApiClient, Enums } = require('fnapi-js');
|
|
52
|
+
const epic = new EpicGamesClient();
|
|
19
53
|
|
|
20
|
-
|
|
21
|
-
const
|
|
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
|
-
|
|
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
|
-
|
|
32
|
-
const
|
|
33
|
-
.setType('outfit')
|
|
34
|
-
.setRarity('epic')
|
|
35
|
-
.setMatchMethod(Enums.matchMethod.contains());
|
|
64
|
+
```ts
|
|
65
|
+
const session = await epic.loginWithDeviceAuth(creds);
|
|
36
66
|
|
|
37
|
-
const
|
|
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
|
-
|
|
40
|
-
|
|
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
|
-
|
|
43
|
-
|
|
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
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
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
|
+
}
|