@spinzaf/freefire-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/LICENSE +674 -0
- package/README.md +297 -0
- package/config/settings.yaml +26 -0
- package/data/items.json +153075 -0
- package/index.js +3 -0
- package/lib/api.js +229 -0
- package/lib/constants.js +115 -0
- package/lib/crypto.js +15 -0
- package/lib/protobuf.js +51 -0
- package/lib/utils.js +112 -0
- package/package.json +45 -0
- package/proto/MajorLogin.proto +173 -0
- package/proto/PlayerCSStats.proto +43 -0
- package/proto/PlayerPersonalShow.proto +641 -0
- package/proto/PlayerStats.proto +38 -0
- package/proto/SearchAccountByName.proto +13 -0
- package/proto/SetPlayerGalleryShowInfo.proto +70 -0
- package/test/all.js +26 -0
- package/test/items.js +51 -0
- package/test/login.js +16 -0
- package/test/profile.js +40 -0
- package/test/search.js +24 -0
- package/test/stats.js +47 -0
package/README.md
ADDED
|
@@ -0,0 +1,297 @@
|
|
|
1
|
+
<div align="center">
|
|
2
|
+
<img src="https://capsule-render.vercel.app/api?type=waving&color=0:1f2937,100:111827&height=180§ion=header&text=Free%20Fire%20API&fontSize=48&fontColor=ffffff&animation=fadeIn" width="100%" alt="Free Fire API Hero" />
|
|
3
|
+
<img src="https://dl.dir.freefiremobile.com/common/test/official/FF_SHORT_LOGO.PNG.png" width="120" alt="Free Fire Logo" />
|
|
4
|
+
</div>
|
|
5
|
+
|
|
6
|
+
# Free Fire API
|
|
7
|
+
|
|
8
|
+
A Node.js library to interact with Free Fire endpoints using Protobuf.
|
|
9
|
+
|
|
10
|
+
## Disclaimer
|
|
11
|
+
This project is **unofficial** and is not affiliated with Garena.
|
|
12
|
+
|
|
13
|
+
## Features
|
|
14
|
+
- Login and session management
|
|
15
|
+
- Search account by nickname
|
|
16
|
+
- Get player profile
|
|
17
|
+
- Get BR/CS stats
|
|
18
|
+
- Get equipped player items
|
|
19
|
+
- YAML-based configuration
|
|
20
|
+
|
|
21
|
+
## Installation
|
|
22
|
+
```bash
|
|
23
|
+
npm install @spinzaf/freefire-api
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
## Requirements
|
|
27
|
+
- Node.js 14+
|
|
28
|
+
|
|
29
|
+
## Quick Start
|
|
30
|
+
```js
|
|
31
|
+
const FreeFireAPI = require('@spinzaf/freefire-api');
|
|
32
|
+
|
|
33
|
+
async function main() {
|
|
34
|
+
const api = new FreeFireAPI();
|
|
35
|
+
|
|
36
|
+
// Auto login via config/credentials.yaml
|
|
37
|
+
const players = await api.searchAccount('Spin');
|
|
38
|
+
console.log(players);
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
main().catch(console.error);
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
## Configuration (Optional)
|
|
45
|
+
|
|
46
|
+
### 1. Credentials (`config/credentials.yaml`)
|
|
47
|
+
Used when calling `login()` without parameters.
|
|
48
|
+
|
|
49
|
+
```yaml
|
|
50
|
+
UID: "YOUR_UID"
|
|
51
|
+
PASSWORD: "YOUR_PASSWORD"
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
### 2. Core Settings (`config/settings.yaml`)
|
|
55
|
+
Primary source for internal constants: `AE`, `HEADERS`, `URLS`, `GARENA_CLIENT`.
|
|
56
|
+
|
|
57
|
+
```yaml
|
|
58
|
+
HEADERS_COMMON_RELEASE_VERSION: "OB52"
|
|
59
|
+
URL_MAJOR_LOGIN: "https://loginbp.ggblueshark.com/MajorLogin"
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
## API Reference
|
|
63
|
+
|
|
64
|
+
### `new FreeFireAPI()`
|
|
65
|
+
Creates a new API client instance.
|
|
66
|
+
|
|
67
|
+
### `api.login(uid?, password?)`
|
|
68
|
+
Optional account authentication (not required).
|
|
69
|
+
|
|
70
|
+
```js
|
|
71
|
+
await api.login('YOUR_UID', 'YOUR_PASSWORD');
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
Use this only if you want to login manually.
|
|
75
|
+
Default provider credentials are already available, so calling `login()` is optional.
|
|
76
|
+
|
|
77
|
+
If parameters are omitted, the library reads credentials from `config/credentials.yaml`.
|
|
78
|
+
|
|
79
|
+
### `api.searchAccount(keyword)`
|
|
80
|
+
Searches accounts by nickname.
|
|
81
|
+
|
|
82
|
+
```js
|
|
83
|
+
const results = await api.searchAccount('Spin');
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
### `api.getPlayerProfile(uid)`
|
|
87
|
+
Fetches detailed player profile information.
|
|
88
|
+
|
|
89
|
+
```js
|
|
90
|
+
const profile = await api.getPlayerProfile('16207002');
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
### `api.getPlayerStats(uid, mode, matchType)`
|
|
94
|
+
Fetches player statistics.
|
|
95
|
+
|
|
96
|
+
- `mode`: `br` | `cs`
|
|
97
|
+
- `matchType`: `career` | `ranked` | `normal`
|
|
98
|
+
|
|
99
|
+
```js
|
|
100
|
+
const brCareer = await api.getPlayerStats('16207002', 'br', 'career');
|
|
101
|
+
const csRanked = await api.getPlayerStats('16207002', 'cs', 'ranked');
|
|
102
|
+
```
|
|
103
|
+
|
|
104
|
+
### `api.getPlayerItems(uid)`
|
|
105
|
+
Fetches currently equipped player items.
|
|
106
|
+
|
|
107
|
+
```js
|
|
108
|
+
const items = await api.getPlayerItems('16207002');
|
|
109
|
+
console.log(items);
|
|
110
|
+
```
|
|
111
|
+
|
|
112
|
+
Sample response:
|
|
113
|
+
```json
|
|
114
|
+
{
|
|
115
|
+
"basic_info": {
|
|
116
|
+
"accountid": "16207002",
|
|
117
|
+
"nickname": "Spin",
|
|
118
|
+
"level": 74,
|
|
119
|
+
"region": "ID"
|
|
120
|
+
},
|
|
121
|
+
"items": {
|
|
122
|
+
"outfit": [{ "id": 101001, "name": "Skull Mask" }],
|
|
123
|
+
"weapons": {
|
|
124
|
+
"shown_skins": [{ "id": 907001, "name": "AK47 - Blue Flame" }]
|
|
125
|
+
},
|
|
126
|
+
"skills": {
|
|
127
|
+
"equipped": [{ "id": 123, "name": "Alok: Drop the Beat" }]
|
|
128
|
+
},
|
|
129
|
+
"pet": {
|
|
130
|
+
"name": "Falco"
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
```
|
|
135
|
+
|
|
136
|
+
## Error Handling
|
|
137
|
+
Use `try/catch` for all async calls.
|
|
138
|
+
|
|
139
|
+
```js
|
|
140
|
+
try {
|
|
141
|
+
const profile = await api.getPlayerProfile('16207002');
|
|
142
|
+
console.log(profile);
|
|
143
|
+
} catch (err) {
|
|
144
|
+
console.error('API error:', err.message);
|
|
145
|
+
}
|
|
146
|
+
```
|
|
147
|
+
|
|
148
|
+
## Testing
|
|
149
|
+
```bash
|
|
150
|
+
npm test
|
|
151
|
+
npm run test:login
|
|
152
|
+
npm run test:search
|
|
153
|
+
npm run test:profile
|
|
154
|
+
npm run test:stats
|
|
155
|
+
npm run test:items
|
|
156
|
+
npm run test:all
|
|
157
|
+
```
|
|
158
|
+
|
|
159
|
+
### Full Test Output Example
|
|
160
|
+
The following is a complete, readable example from `npm run test:all`:
|
|
161
|
+
|
|
162
|
+
```text
|
|
163
|
+
Running all tests sequentially...
|
|
164
|
+
|
|
165
|
+
-------------- login.js:
|
|
166
|
+
Loaded 27989 items into database.
|
|
167
|
+
Starting Login Test...
|
|
168
|
+
[i] No credentials provided, loading from config/credentials.yaml.
|
|
169
|
+
Login success!
|
|
170
|
+
Token: eyJhbGciOiJIUzI1NiIs...
|
|
171
|
+
OpenID: ee3fa75646052bbf713d9f7f3e0a5c81
|
|
172
|
+
|
|
173
|
+
-------------- search.js:
|
|
174
|
+
Loaded 27989 items into database.
|
|
175
|
+
Starting Search Test for 'folaa'...
|
|
176
|
+
[i] No credentials provided, loading from config/credentials.yaml.
|
|
177
|
+
Found 10 players.
|
|
178
|
+
Top Result: Folaa (UID: 16778836)
|
|
179
|
+
[1] Folaa - UID: 16778836 - LVL: 3
|
|
180
|
+
[2] FolAa_66 - UID: 1943283579 - LVL: 46
|
|
181
|
+
[3] Folaa_golgem - UID: 14576052221 - LVL: 6
|
|
182
|
+
[4] folaa_ji - UID: 9436868269 - LVL: 7
|
|
183
|
+
[5] Folaa- - UID: 2357144535 - LVL: 1
|
|
184
|
+
[6] FOLAA-khna9 - UID: 2359319137 - LVL: 1
|
|
185
|
+
[7] Folaa! - UID: 8638700824 - LVL: 7
|
|
186
|
+
[8] folaa!! - UID: 8341924255 - LVL: 17
|
|
187
|
+
[9] folaa..... - UID: 6973843243 - LVL: 2
|
|
188
|
+
[10] folaa***** - UID: 5824293752 - LVL: 5
|
|
189
|
+
|
|
190
|
+
-------------- profile.js:
|
|
191
|
+
Loaded 27989 items into database.
|
|
192
|
+
Starting Profile Test for UID: 12345678...
|
|
193
|
+
[i] No credentials provided, loading from config/credentials.yaml.
|
|
194
|
+
|
|
195
|
+
--- Basic Info ---
|
|
196
|
+
Nickname: FB:ㅤ@GMRemyX
|
|
197
|
+
Level: 68
|
|
198
|
+
EXP: 2327466
|
|
199
|
+
Region: SG
|
|
200
|
+
Likes: 3682188
|
|
201
|
+
Created At: 12/7/2017, 5:19:29 AM
|
|
202
|
+
Last Login: 2/19/2026, 6:02:53 PM
|
|
203
|
+
|
|
204
|
+
--- Pet Info ---
|
|
205
|
+
Pet Name: SiNo
|
|
206
|
+
Pet Level: 7
|
|
207
|
+
|
|
208
|
+
-------------- stats.js:
|
|
209
|
+
Loaded 27989 items into database.
|
|
210
|
+
Starting Stats Test for UID: 16207002...
|
|
211
|
+
Fetching BR Career...
|
|
212
|
+
[i] No credentials provided, loading from config/credentials.yaml.
|
|
213
|
+
|
|
214
|
+
--- BR Career ---
|
|
215
|
+
Solo: {"accountid":"16207002","gamesplayed":1055,"wins":88,"kills":2769,"detailedstats":{"deaths":967,"top10times":0,"topntimes":279,"distancetravelled":3224879,"survivaltime":458396,"revives":0,"highestkills":20,"damage":812652,"roadkills":47,"headshots":1453,"headshotkills":630,"knockdown":0,"pickups":58619}}
|
|
216
|
+
Duo: {"accountid":"16207002","gamesplayed":461,"wins":80,"kills":1383,"detailedstats":{"deaths":381,"top10times":0,"topntimes":144,"distancetravelled":1544324,"survivaltime":217132,"revives":98,"highestkills":22,"damage":487692,"roadkills":48,"headshots":960,"headshotkills":367,"knockdown":1320,"pickups":32130}}
|
|
217
|
+
Squad: {"accountid":"16207002","gamesplayed":6451,"wins":1225,"kills":16041,"detailedstats":{"deaths":5226,"top10times":0,"topntimes":2059,"distancetravelled":26527594,"survivaltime":3204309,"revives":1305,"highestkills":34,"damage":7241365,"roadkills":122,"headshots":12622,"headshotkills":3899,"knockdown":17564,"pickups":586395}}
|
|
218
|
+
Fetching BR Ranked...
|
|
219
|
+
|
|
220
|
+
--- BR Ranked ---
|
|
221
|
+
Solo: {"accountid":"16207002","gamesplayed":4,"wins":1,"kills":25,"detailedstats":{"deaths":3,"top10times":0,"topntimes":3,"distancetravelled":13591,"survivaltime":1857,"revives":0,"highestkills":15,"damage":6317,"roadkills":0,"headshots":19,"headshotkills":8,"knockdown":0,"pickups":483}}
|
|
222
|
+
Duo: {"accountid":"16207002","gamesplayed":3,"wins":1,"kills":8,"detailedstats":{"deaths":2,"top10times":0,"topntimes":2,"distancetravelled":14501,"survivaltime":1607,"revives":3,"highestkills":4,"damage":2561,"roadkills":0,"headshots":2,"headshotkills":0,"knockdown":10,"pickups":383}}
|
|
223
|
+
Squad: {"accountid":"16207002","gamesplayed":548,"wins":50,"kills":1520,"detailedstats":{"deaths":498,"top10times":0,"topntimes":74,"distancetravelled":1859691,"survivaltime":169414,"revives":57,"highestkills":21,"damage":672006,"roadkills":0,"headshots":1287,"headshotkills":392,"knockdown":1741,"pickups":47692}}
|
|
224
|
+
Fetching CS Career...
|
|
225
|
+
|
|
226
|
+
--- CS Career ---
|
|
227
|
+
Data: {
|
|
228
|
+
"csstats": {
|
|
229
|
+
"accountid": "16207002",
|
|
230
|
+
"gamesplayed": 3102,
|
|
231
|
+
"wins": 1788,
|
|
232
|
+
"kills": 12555
|
|
233
|
+
}
|
|
234
|
+
}
|
|
235
|
+
Fetching CS Ranked...
|
|
236
|
+
|
|
237
|
+
--- CS Ranked ---
|
|
238
|
+
Data: {
|
|
239
|
+
"csstats": {
|
|
240
|
+
"accountid": "16207002",
|
|
241
|
+
"gamesplayed": 56,
|
|
242
|
+
"wins": 30,
|
|
243
|
+
"kills": 196
|
|
244
|
+
}
|
|
245
|
+
}
|
|
246
|
+
|
|
247
|
+
-------------- items.js:
|
|
248
|
+
Loaded 27989 items into database.
|
|
249
|
+
Starting Items Test for UID: 12345678...
|
|
250
|
+
Getting Player Items...
|
|
251
|
+
[i] No credentials provided, loading from config/credentials.yaml.
|
|
252
|
+
|
|
253
|
+
--- Summary ---
|
|
254
|
+
Nickname: FB:ㅤ@GMRemyX
|
|
255
|
+
UID: 12345678
|
|
256
|
+
Outfit Items: 1
|
|
257
|
+
Weapon Items: 0
|
|
258
|
+
Skills Equipped: 6
|
|
259
|
+
Skills: 211000028, 214049006, 205000805, 211043045, 203038045, 204041011
|
|
260
|
+
Pet Name: SiNo
|
|
261
|
+
Pet ID: Poring
|
|
262
|
+
|
|
263
|
+
--- First 5 Outfits ---
|
|
264
|
+
- Unknown Item (ID: 50)
|
|
265
|
+
|
|
266
|
+
All tests passed successfully!
|
|
267
|
+
```
|
|
268
|
+
|
|
269
|
+
## Project Structure
|
|
270
|
+
- `lib/api.js`: core API client
|
|
271
|
+
- `lib/protobuf.js`: protobuf encode/decode
|
|
272
|
+
- `lib/crypto.js`: AES encryption
|
|
273
|
+
- `lib/utils.js`: item processing utilities
|
|
274
|
+
- `config/settings.yaml`: core settings
|
|
275
|
+
- `config/credentials.yaml`: default login credentials
|
|
276
|
+
- `proto/`: protobuf schema files
|
|
277
|
+
- `data/items.json`: item data source
|
|
278
|
+
|
|
279
|
+
## Metadata
|
|
280
|
+
- npm: `@spinzaf/freefire-api`
|
|
281
|
+
- repository: `https://github.com/spinzaf/freefire-api`
|
|
282
|
+
- license: GPL-3.0
|
|
283
|
+
|
|
284
|
+
## Acknowledgements
|
|
285
|
+
We perform this work standing on the shoulders of giants. Special thanks to the open-source community for their Reverse Engineering efforts.
|
|
286
|
+
|
|
287
|
+
- `0xMe/FreeFire-Api`: Prior research established a Python-based workflow. This project converts that logic into an easy-to-use JavaScript implementation, with equivalent functionality.
|
|
288
|
+
|
|
289
|
+
## Support
|
|
290
|
+
If you find this project helpful and would like to support the development, you can treat me to a coffee! ☕
|
|
291
|
+
|
|
292
|
+
- Donate via Saweria: https://saweria.co/spinzaf
|
|
293
|
+
|
|
294
|
+
A huge thank you to everyone who has supported! Your support keeps this project alive. ❤️
|
|
295
|
+
|
|
296
|
+
## License
|
|
297
|
+
GNU General Public License v3.0
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
# Core SDK settings
|
|
2
|
+
AE_MAIN_KEY: "Yg&tc%DEuh6%Zc^8"
|
|
3
|
+
AE_MAIN_IV: "6oyZDr22E3ychjM%"
|
|
4
|
+
|
|
5
|
+
HEADERS_COMMON_USER_AGENT: "Dalvik/2.1.0 (Linux; U; Android 13; A063 Build/TKQ1.221220.001)"
|
|
6
|
+
HEADERS_COMMON_CONNECTION: "Keep-Alive"
|
|
7
|
+
HEADERS_COMMON_ACCEPT_ENCODING: "gzip"
|
|
8
|
+
HEADERS_COMMON_EXPECT: "100-continue"
|
|
9
|
+
HEADERS_COMMON_X_UNITY_VERSION: "2018.4.11f1"
|
|
10
|
+
HEADERS_COMMON_X_GA: "v1 1"
|
|
11
|
+
HEADERS_COMMON_RELEASE_VERSION: "OB52"
|
|
12
|
+
HEADERS_COMMON_CONTENT_TYPE: "application/x-www-form-urlencoded"
|
|
13
|
+
|
|
14
|
+
HEADERS_GARENA_AUTH_USER_AGENT: "GarenaMSDK/4.0.19P9(A063 ;Android 13;en;IN;)"
|
|
15
|
+
HEADERS_GARENA_AUTH_CONNECTION: "Keep-Alive"
|
|
16
|
+
HEADERS_GARENA_AUTH_ACCEPT_ENCODING: "gzip"
|
|
17
|
+
|
|
18
|
+
URL_GARENA_TOKEN: "https://ffmconnect.live.gop.garenanow.com/oauth/guest/token/grant"
|
|
19
|
+
URL_MAJOR_LOGIN: "https://loginbp.ggblueshark.com/MajorLogin"
|
|
20
|
+
URL_PATH_SEARCH: "/FuzzySearchAccountByName"
|
|
21
|
+
URL_PATH_PERSONAL_SHOW: "/GetPlayerPersonalShow"
|
|
22
|
+
URL_PATH_PLAYER_STATS: "/GetPlayerStats"
|
|
23
|
+
URL_PATH_PLAYER_CS_STATS: "/GetPlayerTCStats"
|
|
24
|
+
|
|
25
|
+
GARENA_CLIENT_ID: "100067"
|
|
26
|
+
GARENA_CLIENT_SECRET: "2ee44819e9b4598845141067b281621874d0d5d7af9d8f7e00c1e54715b7d1e3"
|