r6-data.js 1.0.1
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 +538 -0
- package/axiosInstance/axiosInstance.js +12 -0
- package/index.js +27 -0
- package/methods/getAttachment.js +21 -0
- package/methods/getCharms.js +21 -0
- package/methods/getMaps.js +21 -0
- package/methods/getOperators.js +21 -0
- package/methods/getRanks.js +25 -0
- package/methods/getSearchAll.js +27 -0
- package/methods/getSeasons.js +21 -0
- package/methods/getServiceStatus.js +19 -0
- package/methods/getStats.js +90 -0
- package/methods/getUniversalSkins.js +21 -0
- package/methods/getWeapons.js +21 -0
- package/methods/tokenManager.js +42 -0
- package/methods/util.js +11 -0
- package/package.json +53 -0
package/README.md
ADDED
|
@@ -0,0 +1,538 @@
|
|
|
1
|
+
## r6-data.js
|
|
2
|
+
A wrapper for the R6Siege API that gives you information about player's stats, maps, operators, ranks, seasons, charms etc.
|
|
3
|
+
|
|
4
|
+
<div align="center">
|
|
5
|
+
<p>
|
|
6
|
+
<a href="https://github.com/mazeor9/r6-data.js/releases/latest">
|
|
7
|
+
<img src="https://img.shields.io/github/v/release/mazeor9/r6-data.js?style=for-the-badge" alt="GitHub release (latest SemVer)" /></a>
|
|
8
|
+
<a href="https://github.com/mazeor9/r6-data.js/releases/latest">
|
|
9
|
+
<img src="https://img.shields.io/github/release-date/mazeor9/r6-data.js?label=latest%20release&style=for-the-badge" alt="Latest release" /></a>
|
|
10
|
+
<a href="https://www.npmjs.com/package/r6-data.js"><img src="https://img.shields.io/npm/v/r6-data.js.svg?logo=npm&style=for-the-badge" alt="npm version" /></a>
|
|
11
|
+
<a href="https://www.npmjs.com/package/r6-data.js"><img src="https://img.shields.io/npm/dt/r6-data.js.svg?style=for-the-badge" alt="NPM downloads" /></a>
|
|
12
|
+
</p>
|
|
13
|
+
</div>
|
|
14
|
+
|
|
15
|
+
## Installation
|
|
16
|
+
|
|
17
|
+
```sh
|
|
18
|
+
npm install r6-data.js
|
|
19
|
+
```
|
|
20
|
+
```sh
|
|
21
|
+
npm i r6-data.js
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
`Last updated Y10S2`
|
|
25
|
+
|
|
26
|
+
## Getting Player Stats and Account Information
|
|
27
|
+
|
|
28
|
+
The `getStats()` function allows you to retrieve player statistics and account information from the official Rainbow Six Siege API. This function supports two types of requests: `accountInfo` for retrieving player profile data and `stats` for retrieving gameplay statistics.
|
|
29
|
+
|
|
30
|
+
```javascript
|
|
31
|
+
const r6Info = require('r6-data.js');
|
|
32
|
+
|
|
33
|
+
async function main() {
|
|
34
|
+
try {
|
|
35
|
+
// Get player account information
|
|
36
|
+
const accountInfo = await r6Info.getStats({
|
|
37
|
+
type: 'accountInfo',
|
|
38
|
+
nameOnPlatform: 'PlayerName',
|
|
39
|
+
platformType: 'uplay'
|
|
40
|
+
});
|
|
41
|
+
|
|
42
|
+
return accountInfo;
|
|
43
|
+
|
|
44
|
+
// Get player statistics
|
|
45
|
+
const playerStats = await r6Info.getStats({
|
|
46
|
+
type: 'stats',
|
|
47
|
+
nameOnPlatform: 'PlayerName',
|
|
48
|
+
platformType: 'uplay',
|
|
49
|
+
platform_families: 'pc'
|
|
50
|
+
});
|
|
51
|
+
|
|
52
|
+
return playerStats;
|
|
53
|
+
|
|
54
|
+
// Get player statistics for ranked mode only
|
|
55
|
+
const rankedStats = await r6Info.getStats({
|
|
56
|
+
type: 'stats',
|
|
57
|
+
nameOnPlatform: 'PlayerName',
|
|
58
|
+
platformType: 'uplay',
|
|
59
|
+
platform_families: 'pc',
|
|
60
|
+
board_id: 'ranked'
|
|
61
|
+
});
|
|
62
|
+
|
|
63
|
+
return rankedStats;
|
|
64
|
+
|
|
65
|
+
} catch (error) {
|
|
66
|
+
console.error('Error retrieving player data:', error.message);
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
main();
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
### Parameters
|
|
74
|
+
|
|
75
|
+
The `getStats()` function accepts an object with the following parameters:
|
|
76
|
+
For both request types:
|
|
77
|
+
|
|
78
|
+
- `type`: (Required) The type of request - must be either "accountInfo" or "stats"
|
|
79
|
+
- `nameOnPlatform`: (Required) The player's name on the platform
|
|
80
|
+
- `platformType`: (Required) The platform type - "uplay", "psn", or "xbl"
|
|
81
|
+
|
|
82
|
+
Additional parameters for stats type:
|
|
83
|
+
|
|
84
|
+
- `platform_families`: (Required) The platform family - "pc" or "console"
|
|
85
|
+
- `board_id`: (Optional) The game mode to filter statistics - "casual", "event", "warmup", "standard", or "ranked"
|
|
86
|
+
|
|
87
|
+
### Account Information
|
|
88
|
+
When using the `accountInfo` type, you'll receive data about the player's profile, including:
|
|
89
|
+
|
|
90
|
+
- Player level and experience
|
|
91
|
+
- Clearance level
|
|
92
|
+
- Achievement status
|
|
93
|
+
- Play time statistics
|
|
94
|
+
- Player profile settings and customization
|
|
95
|
+
|
|
96
|
+
### Player Statistics
|
|
97
|
+
When using the stats type, you'll receive detailed gameplay statistics, including:
|
|
98
|
+
|
|
99
|
+
- Rank information
|
|
100
|
+
- MMR (Matchmaking Rating)
|
|
101
|
+
- Win/loss records
|
|
102
|
+
- Seasonal performance data
|
|
103
|
+
- Skill metrics across different gameplay modes
|
|
104
|
+
|
|
105
|
+
You can filter these statistics by game mode using the `board_id` parameter:
|
|
106
|
+
|
|
107
|
+
- `casual`: Statistics for casual matches
|
|
108
|
+
- `event`: Statistics for limited-time events
|
|
109
|
+
- `warmup`: Statistics for warmup matches
|
|
110
|
+
- `standard`: Statistics for standard matches
|
|
111
|
+
- `ranked`: Statistics for ranked competitive matches
|
|
112
|
+
|
|
113
|
+
## Searching Across All Entities
|
|
114
|
+
|
|
115
|
+
The `getSearchAll()` function allows you to search across all Rainbow Six Siege entities (operators, weapons, maps, seasons, charms, and attachments) with a single query. This is useful for finding relevant information across multiple categories at once.
|
|
116
|
+
|
|
117
|
+
```javascript
|
|
118
|
+
const r6Info = require('r6-data.js');
|
|
119
|
+
|
|
120
|
+
async function main() {
|
|
121
|
+
try {
|
|
122
|
+
// Search for all entities containing "black"
|
|
123
|
+
const searchResults = await r6Info.getSearchAll('black');
|
|
124
|
+
console.log('Search results summary:', searchResults.summary);
|
|
125
|
+
|
|
126
|
+
// Access specific result categories
|
|
127
|
+
console.log('Operator results:', searchResults.results.operators);
|
|
128
|
+
console.log('Weapon results:', searchResults.results.weapons);
|
|
129
|
+
console.log('Map results:', searchResults.results.maps);
|
|
130
|
+
console.log('Season results:', searchResults.results.seasons);
|
|
131
|
+
console.log('Charm results:', searchResults.results.charms);
|
|
132
|
+
console.log('Attachment results:', searchResults.results.attachments);
|
|
133
|
+
|
|
134
|
+
// Search for a specific operator
|
|
135
|
+
const operatorSearch = await r6Info.getSearchAll('ash');
|
|
136
|
+
console.log('Ash search results:', operatorSearch);
|
|
137
|
+
|
|
138
|
+
// Search for a specific map
|
|
139
|
+
const mapSearch = await r6Info.getSearchAll('bank');
|
|
140
|
+
console.log('Bank search results:', mapSearch);
|
|
141
|
+
|
|
142
|
+
} catch (error) {
|
|
143
|
+
console.error('Error during search:', error.message);
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
main();
|
|
148
|
+
```
|
|
149
|
+
|
|
150
|
+
### Parameters
|
|
151
|
+
|
|
152
|
+
The `getSearchAll()` function accepts a single required parameter:
|
|
153
|
+
|
|
154
|
+
- `query`: (Required) The search term to query across all entities
|
|
155
|
+
|
|
156
|
+
### Search Results
|
|
157
|
+
|
|
158
|
+
The function returns a structured object containing:
|
|
159
|
+
|
|
160
|
+
- query: The original search term
|
|
161
|
+
- summary: A summary object with counts of results by category and total
|
|
162
|
+
- results: An object containing arrays of results for each entity type:
|
|
163
|
+
- operators: Array of operator results
|
|
164
|
+
- weapons: Array of weapon results
|
|
165
|
+
- maps: Array of map results
|
|
166
|
+
- seasons: Array of season results
|
|
167
|
+
- charms: Array of charm results
|
|
168
|
+
- attachments: Array of attachment results
|
|
169
|
+
|
|
170
|
+
|
|
171
|
+
Each result includes an `entity_type` field indicating its category, along with relevant data fields for that entity type.
|
|
172
|
+
|
|
173
|
+
## Getting Rank Information
|
|
174
|
+
|
|
175
|
+
The `getRanks()` function supports retrieving rank information across different versions of the game's ranking system, from v1 to v6. This flexibility allows users to query rank data that aligns with specific game seasons or ranking system updates. Here are examples demonstrating how to use the `getRanks()` function for each version, including filtering options for `min_mmr` and `max_mmr`.
|
|
176
|
+
|
|
177
|
+
`v1: Until Y1S3 | #3 | Skull Rain`
|
|
178
|
+
|
|
179
|
+
`v2: Y1S4 | #4 | Red Crow`
|
|
180
|
+
|
|
181
|
+
`v3: Y2S1 - Y4S2 | #5 - #14 | Velvet Shell - Phantom Sight`
|
|
182
|
+
|
|
183
|
+
`v4: Y4S3 - Y6S2 | #15 - #22 | Ember Rise - North Star`
|
|
184
|
+
|
|
185
|
+
`v5: Y6S3 - Y7S3 | #23 - #27 | Crystal Guard - Brutal Swarm`
|
|
186
|
+
|
|
187
|
+
`V6: Y7S4+ | #28+ | Solar Raid+ (Ranked 2.0)`
|
|
188
|
+
|
|
189
|
+
### Version 1 (v1)
|
|
190
|
+
|
|
191
|
+
```javascript
|
|
192
|
+
const r6Info = require('r6-data.js');
|
|
193
|
+
|
|
194
|
+
async function main() {
|
|
195
|
+
|
|
196
|
+
try {
|
|
197
|
+
|
|
198
|
+
const ranksV1 = await r6Info.getRanks({ version: 'v1' });
|
|
199
|
+
console.log('All ranks for version v1:', ranksV1);
|
|
200
|
+
|
|
201
|
+
const filteredRanksV1 = await r6Info.getRanks({ min_mmr: 2000, max_mmr: 2500, version: 'v1' });
|
|
202
|
+
console.log('Filtered ranks for version v1:', filteredRanksV1);
|
|
203
|
+
|
|
204
|
+
} catch (error) {
|
|
205
|
+
console.error('Error while requesting ranks:', error.message);
|
|
206
|
+
}
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
main();
|
|
210
|
+
```
|
|
211
|
+
`getRanks()` function with the version parameter set to 'v1' to retrieve all ranks for version 1 of the ranking system. We also demonstrate filtering the ranks by specifying the min_mmr and max_mmr parameters to get ranks within a specific MMR range.
|
|
212
|
+
|
|
213
|
+
For the others versions you can replace the v1 with v2, v3... and the others parameters
|
|
214
|
+
|
|
215
|
+
|
|
216
|
+
## Getting Service Status
|
|
217
|
+
|
|
218
|
+
The `getServiceStatus()` function allows you to retrieve the current status of the Rainbow Six Siege game servers. This information can be useful for monitoring the health and availability of the game service. Here's an example of how to use the `getServiceStatus()` function:
|
|
219
|
+
|
|
220
|
+
```javascript
|
|
221
|
+
const r6Info = require('r6-data.js');
|
|
222
|
+
|
|
223
|
+
async function main() {
|
|
224
|
+
|
|
225
|
+
try {
|
|
226
|
+
|
|
227
|
+
const serviceStatus = await r6Info.getServiceStatus();
|
|
228
|
+
console.log('Service status:', serviceStatus);
|
|
229
|
+
|
|
230
|
+
} catch (error) {
|
|
231
|
+
console.error('Error while requesting service status:', error.message);
|
|
232
|
+
}
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
main();
|
|
236
|
+
```
|
|
237
|
+
|
|
238
|
+
## Getting Map Information
|
|
239
|
+
|
|
240
|
+
The `getMaps()` function allows you to retrieve information about the maps available in Rainbow Six Siege. You can get a list of all maps or filter the maps based on specific criteria. Here's an example of how to use the `getMaps()` function:
|
|
241
|
+
|
|
242
|
+
```javascript
|
|
243
|
+
const r6Info = require('r6-data.js');
|
|
244
|
+
|
|
245
|
+
async function main() {
|
|
246
|
+
|
|
247
|
+
try {
|
|
248
|
+
|
|
249
|
+
// Get all maps
|
|
250
|
+
const maps = await r6Info.getMaps();
|
|
251
|
+
console.log('All maps:', maps);
|
|
252
|
+
|
|
253
|
+
// Filter maps by name
|
|
254
|
+
const filteredMapsByName = await r6Info.getMaps({ name: 'Bank' });
|
|
255
|
+
console.log('Maps filtered by name:', filteredMapsByName);
|
|
256
|
+
|
|
257
|
+
// Filter maps by location
|
|
258
|
+
const filteredMapsByLocation = await r6Info.getMaps({ location: 'USA' });
|
|
259
|
+
console.log('Maps filtered by location:', filteredMapsByLocation);
|
|
260
|
+
|
|
261
|
+
// Filter maps by release date
|
|
262
|
+
const filteredMapsByReleaseDate = await r6Info.getMaps({ releaseDate: '2015-12-01' });
|
|
263
|
+
console.log('Maps filtered by release date:', filteredMapsByReleaseDate);
|
|
264
|
+
|
|
265
|
+
// Filter maps by playlists
|
|
266
|
+
const filteredMapsByPlaylists = await r6Info.getMaps({ playlists: 'ranked' });
|
|
267
|
+
console.log('Maps filtered by playlists:', filteredMapsByPlaylists);
|
|
268
|
+
|
|
269
|
+
// Filter maps by rework status
|
|
270
|
+
const filteredMapsByRework = await r6Info.getMaps({ mapReworked: true });
|
|
271
|
+
console.log('Maps filtered by rework status:', filteredMapsByRework);
|
|
272
|
+
|
|
273
|
+
} catch (error) {
|
|
274
|
+
console.error('Error while requesting maps:', error.message);
|
|
275
|
+
}
|
|
276
|
+
}
|
|
277
|
+
|
|
278
|
+
main();
|
|
279
|
+
```
|
|
280
|
+
|
|
281
|
+
Retrieving all maps by calling `getMaps()` without any parameters.
|
|
282
|
+
Filtering maps by name using the `name` parameter.
|
|
283
|
+
Filtering maps by location using the `location` parameter.
|
|
284
|
+
Filtering maps by release date using the `releaseDate` parameter.
|
|
285
|
+
Filtering maps by playlists using the `playlists` parameter.
|
|
286
|
+
Filtering maps by rework status using the `mapReworked` parameter.
|
|
287
|
+
You can use these filtering options individually or combine them to retrieve specific subsets of maps based on your requirements.
|
|
288
|
+
|
|
289
|
+
## Getting Operator Information
|
|
290
|
+
|
|
291
|
+
The `getOperators()` function allows you to retrieve information about the operators available in Rainbow Six Siege. You can get a list of all operators or filter the operators based on specific criteria. Here's an example of how to use the `getOperators()` function:
|
|
292
|
+
|
|
293
|
+
```javascript
|
|
294
|
+
const r6Info = require('r6-data.js');
|
|
295
|
+
|
|
296
|
+
async function main() {
|
|
297
|
+
|
|
298
|
+
try {
|
|
299
|
+
|
|
300
|
+
// Get all operators
|
|
301
|
+
const operators = await r6Info.getOperators();
|
|
302
|
+
console.log('All operators:', operators);
|
|
303
|
+
|
|
304
|
+
// Filter operators by name
|
|
305
|
+
const filteredOperatorsByName = await r6Info.getOperators({ name: 'Ash' });
|
|
306
|
+
console.log('Operators filtered by name:', filteredOperatorsByName);
|
|
307
|
+
|
|
308
|
+
// Filter operators by safe name
|
|
309
|
+
const filteredOperatorsBySafeName = await r6Info.getOperators({ safename: 'recruit' });
|
|
310
|
+
console.log('Operators filtered by safe name:', filteredOperatorsBySafeName);
|
|
311
|
+
|
|
312
|
+
// Filter operators by real name
|
|
313
|
+
const filteredOperatorsByRealName = await r6Info.getOperators({ realname: 'Eliza Cohen' });
|
|
314
|
+
console.log('Operators filtered by real name:', filteredOperatorsByRealName);
|
|
315
|
+
|
|
316
|
+
// Filter operators by birthplace
|
|
317
|
+
const filteredOperatorsByBirthplace = await r6Info.getOperators({ birthplace: 'Jerusalem, Israel' });
|
|
318
|
+
console.log('Operators filtered by birthplace:', filteredOperatorsByBirthplace);
|
|
319
|
+
|
|
320
|
+
// Filter operators by age
|
|
321
|
+
const filteredOperatorsByAge = await r6Info.getOperators({ age: 33 });
|
|
322
|
+
console.log('Operators filtered by age:', filteredOperatorsByAge);
|
|
323
|
+
|
|
324
|
+
// Filter operators by date of birth
|
|
325
|
+
const filteredOperatorsByDateOfBirth = await r6Info.getOperators({ date_of_birth: '1984-12-24' });
|
|
326
|
+
console.log('Operators filtered by date of birth:', filteredOperatorsByDateOfBirth);
|
|
327
|
+
|
|
328
|
+
// Filter operators by season introduced
|
|
329
|
+
const filteredOperatorsBySeasonIntroduced = await r6Info.getOperators({ season_introduced: 'Y1S1' });
|
|
330
|
+
console.log('Operators filtered by season introduced:', filteredOperatorsBySeasonIntroduced);
|
|
331
|
+
|
|
332
|
+
} catch (error) {
|
|
333
|
+
console.error('Error while requesting operators:', error.message);
|
|
334
|
+
}
|
|
335
|
+
}
|
|
336
|
+
|
|
337
|
+
main();
|
|
338
|
+
```
|
|
339
|
+
|
|
340
|
+
1. Retrieving all operators by calling `getOperators()` without any parameters.
|
|
341
|
+
2. Filtering operators by name using the `name` parameter.
|
|
342
|
+
3. Filtering operators by safe name using the `safename` parameter.
|
|
343
|
+
4. Filtering operators by real name using the `realname` parameter.
|
|
344
|
+
5. Filtering operators by birthplace using the `birthplace` parameter.
|
|
345
|
+
6. Filtering operators by age using the `age` parameter.
|
|
346
|
+
7. Filtering operators by date of birth using the `date_of_birth` parameter.
|
|
347
|
+
8. Filtering operators by season introduced using the `season_introduced` parameter.
|
|
348
|
+
|
|
349
|
+
## Getting Season Information
|
|
350
|
+
|
|
351
|
+
The `getSeasons()` function allows you to retrieve information about the seasons in Rainbow Six Siege. You can get a list of all seasons or filter the seasons based on specific criteria. Here's an example of how to use the `getSeasons()` function:
|
|
352
|
+
|
|
353
|
+
```javascript
|
|
354
|
+
const r6Info = require('r6-data.js');
|
|
355
|
+
|
|
356
|
+
async function main() {
|
|
357
|
+
|
|
358
|
+
try {
|
|
359
|
+
|
|
360
|
+
// Get all seasons
|
|
361
|
+
const seasons = await r6Info.getSeasons();
|
|
362
|
+
console.log('All seasons:', seasons);
|
|
363
|
+
|
|
364
|
+
// Filter seasons by name
|
|
365
|
+
const filteredSeasonsByName = await r6Info.getSeasons({ name: 'Black Ice' });
|
|
366
|
+
console.log('Seasons filtered by name:', filteredSeasonsByName);
|
|
367
|
+
|
|
368
|
+
// Filter seasons by map
|
|
369
|
+
const filteredSeasonsByMap = await r6Info.getSeasons({ map: 'Yacht' });
|
|
370
|
+
console.log('Seasons filtered by map:', filteredSeasonsByMap);
|
|
371
|
+
|
|
372
|
+
// Filter seasons by operators
|
|
373
|
+
const filteredSeasonsByOperators = await r6Info.getSeasons({ operators: 'Buck, Frost' });
|
|
374
|
+
console.log('Seasons filtered by operators:', filteredSeasonsByOperators);
|
|
375
|
+
|
|
376
|
+
// Filter seasons by weapons
|
|
377
|
+
const filteredSeasonsByWeapons = await r6Info.getSeasons({ weapons: 'C8-SFW, Super 90' });
|
|
378
|
+
console.log('Seasons filtered by weapons:', filteredSeasonsByWeapons);
|
|
379
|
+
|
|
380
|
+
} catch (error) {
|
|
381
|
+
console.error('Error while requesting seasons:', error.message);
|
|
382
|
+
}
|
|
383
|
+
}
|
|
384
|
+
|
|
385
|
+
main();
|
|
386
|
+
```
|
|
387
|
+
|
|
388
|
+
Retrieving all seasons by calling `getSeasons()` without any parameters.
|
|
389
|
+
- Filtering seasons by name using the `name` parameter.
|
|
390
|
+
- Filtering seasons by map using the `map` parameter.
|
|
391
|
+
- Filtering seasons by operators using the `operators` parameter.
|
|
392
|
+
- Filtering seasons by weapons using the `weapons` parameter.
|
|
393
|
+
|
|
394
|
+
## Getting Attachment Information
|
|
395
|
+
|
|
396
|
+
The `getAttachment()` function allows you to retrieve information about the attachments available in Rainbow Six Siege. You can get a list of all attachments or filter the attachments based on specific criteria. Here's an example of how to use the `getAttachment()` function:
|
|
397
|
+
|
|
398
|
+
```javascript
|
|
399
|
+
const r6Info = require('r6-data.js');
|
|
400
|
+
|
|
401
|
+
async function main() {
|
|
402
|
+
|
|
403
|
+
try {
|
|
404
|
+
|
|
405
|
+
// Get all attachments
|
|
406
|
+
const attachments = await r6Info.getAttachment();
|
|
407
|
+
console.log('All attachments:', attachments);
|
|
408
|
+
|
|
409
|
+
// Filter attachments by name
|
|
410
|
+
const filteredAttachmentsByName = await r6Info.getAttachment({ name: 'Red Dot Sight' });
|
|
411
|
+
console.log('Attachments filtered by name:', filteredAttachmentsByName);
|
|
412
|
+
|
|
413
|
+
// Filter attachments by style
|
|
414
|
+
const filteredAttachmentsByStyle = await r6Info.getAttachment({ style: 'colour' });
|
|
415
|
+
console.log('Attachments filtered by style:', filteredAttachmentsByStyle);
|
|
416
|
+
|
|
417
|
+
// Filter attachments by rarity
|
|
418
|
+
const filteredAttachmentsByRarity = await r6Info.getAttachment({ rarity: 'common' });
|
|
419
|
+
console.log('Attachments filtered by rarity:', filteredAttachmentsByRarity);
|
|
420
|
+
|
|
421
|
+
// Filter attachments by availability
|
|
422
|
+
const filteredAttachmentsByAvailability = await r6Info.getAttachment({ availability: 'removed' });
|
|
423
|
+
console.log('Attachments filtered by availability:', filteredAttachmentsByAvailability);
|
|
424
|
+
|
|
425
|
+
} catch (error) {
|
|
426
|
+
console.error('Error while requesting attachments:', error.message);
|
|
427
|
+
}
|
|
428
|
+
}
|
|
429
|
+
|
|
430
|
+
main();
|
|
431
|
+
```
|
|
432
|
+
|
|
433
|
+
Retrieving all attachments by calling `getAttachment()` without any parameters.
|
|
434
|
+
- Filtering attachments by name using the `name` parameter.
|
|
435
|
+
- Filtering attachments by style using the `style` parameter.
|
|
436
|
+
- Filtering attachments by rarity using the `rarity` parameter.
|
|
437
|
+
- Filtering attachments by availability using the `availability` parameter.
|
|
438
|
+
|
|
439
|
+
## Getting Charm Information
|
|
440
|
+
|
|
441
|
+
```javascript
|
|
442
|
+
const r6Info = require('r6-data.js');
|
|
443
|
+
|
|
444
|
+
// Get all charms
|
|
445
|
+
const charms = await r6Info.getCharms();
|
|
446
|
+
console.log('All charms:', charms);
|
|
447
|
+
|
|
448
|
+
// Filter charms by specific criteria
|
|
449
|
+
const filteredCharms = await r6Info.getCharms({
|
|
450
|
+
name: 'Chibi',
|
|
451
|
+
collection: 'Year 1',
|
|
452
|
+
rarity: 'legendary',
|
|
453
|
+
availability: 'available',
|
|
454
|
+
bundle: 'Pro League Set',
|
|
455
|
+
season: 'Burnt Horizon'
|
|
456
|
+
});
|
|
457
|
+
```
|
|
458
|
+
|
|
459
|
+
The `getCharms()` function allows you to retrieve information about the charms available in Rainbow Six Siege. You can get all charms or filter them based on specific criteria:
|
|
460
|
+
|
|
461
|
+
- `name`: Filter by charm name
|
|
462
|
+
- `collection`: Filter by charm collection
|
|
463
|
+
- `rarity`: Filter by rarity level (common, uncommon, rare, epic, legendary)
|
|
464
|
+
- `availability`: Filter by availability status
|
|
465
|
+
- `bundle`: Filter by bundle name
|
|
466
|
+
- `season`: Filter by season released
|
|
467
|
+
|
|
468
|
+
## Getting Weapon Information
|
|
469
|
+
|
|
470
|
+
The `getWeapons()` function allows you to retrieve information about the weapons available in Rainbow Six Siege. You can get a list of all weapons or filter them by name. Here's an example of how to use the `getWeapons()` function:
|
|
471
|
+
|
|
472
|
+
```javascript
|
|
473
|
+
const r6Info = require('r6-data.js');
|
|
474
|
+
|
|
475
|
+
async function main() {
|
|
476
|
+
|
|
477
|
+
try {
|
|
478
|
+
|
|
479
|
+
// Get all weapons
|
|
480
|
+
const weapons = await r6Info.getWeapons();
|
|
481
|
+
console.log('All weapons:', weapons);
|
|
482
|
+
|
|
483
|
+
// Filter weapons by name
|
|
484
|
+
const filteredWeaponsByName = await r6Info.getWeapons({ name: 'F2' });
|
|
485
|
+
console.log('Weapons filtered by name:', filteredWeaponsByName);
|
|
486
|
+
|
|
487
|
+
} catch (error) {
|
|
488
|
+
console.error('Error while requesting weapons:', error.message);
|
|
489
|
+
}
|
|
490
|
+
}
|
|
491
|
+
|
|
492
|
+
main();
|
|
493
|
+
```
|
|
494
|
+
|
|
495
|
+
The `getWeapons()` function retrieves information about the weapons in Rainbow Six Siege. You can:
|
|
496
|
+
|
|
497
|
+
- Retrieve all weapons by calling `getWeapons()` without any parameters
|
|
498
|
+
- Filter weapons by name using the `name` parameter
|
|
499
|
+
|
|
500
|
+
## Getting Universal Skin Information
|
|
501
|
+
|
|
502
|
+
The `getUniversalSkins()` function allows you to retrieve information about the universal skins available in Rainbow Six Siege. You can get a list of all universal skins or filter them by name. Here's an example of how to use the `getUniversalSkins()` function:
|
|
503
|
+
|
|
504
|
+
```javascript
|
|
505
|
+
const r6Info = require('r6-data.js');
|
|
506
|
+
|
|
507
|
+
async function main() {
|
|
508
|
+
|
|
509
|
+
try {
|
|
510
|
+
|
|
511
|
+
// Get all universal skins
|
|
512
|
+
const universalSkins = await r6Info.getUniversalSkins();
|
|
513
|
+
console.log('All universal skins:', universalSkins);
|
|
514
|
+
|
|
515
|
+
// Filter universal skins by name
|
|
516
|
+
const filteredSkinsByName = await r6Info.getUniversalSkins({ name: 'Black Ice' });
|
|
517
|
+
console.log('Universal skins filtered by name:', filteredSkinsByName);
|
|
518
|
+
|
|
519
|
+
} catch (error) {
|
|
520
|
+
console.error('Error while requesting universal skins:', error.message);
|
|
521
|
+
}
|
|
522
|
+
}
|
|
523
|
+
|
|
524
|
+
main();
|
|
525
|
+
```
|
|
526
|
+
|
|
527
|
+
The `getUniversalSkins()` function retrieves information about universal weapon skins in Rainbow Six Siege. You can:
|
|
528
|
+
|
|
529
|
+
- Retrieve all universal skins by calling `getUniversalSkins()` without any parameters
|
|
530
|
+
- Filter universal skins by name using the name parameter
|
|
531
|
+
|
|
532
|
+
## Error Handling
|
|
533
|
+
The package functions throw an exception if an error occurs during API requests. Make sure to handle errors appropriately using try-catch blocks.
|
|
534
|
+
|
|
535
|
+
If the access token has expired or is invalid, an exception will be thrown with the message "Token expired or invalid". In this case, you need to obtain a new token using the getToken() function.
|
|
536
|
+
|
|
537
|
+
## License
|
|
538
|
+
This package is fan made, so it has been created for only informational purposes
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
const axios = require('axios');
|
|
2
|
+
|
|
3
|
+
const axiosInstance = axios.create({
|
|
4
|
+
baseURL: 'https://r6-api.vercel.app/api',
|
|
5
|
+
headers: {
|
|
6
|
+
'Content-Type': 'application/json',
|
|
7
|
+
'Accept': 'application/json',
|
|
8
|
+
'Cache-Control': 'no-cache',
|
|
9
|
+
},
|
|
10
|
+
});
|
|
11
|
+
|
|
12
|
+
module.exports = axiosInstance;
|
package/index.js
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
const getMaps = require('./methods/getMaps');
|
|
2
|
+
const getOperators = require('./methods/getOperators');
|
|
3
|
+
const getRanks = require('./methods/getRanks');
|
|
4
|
+
const getSeasons = require('./methods/getSeasons');
|
|
5
|
+
const getServiceStatus = require('./methods/getServiceStatus');
|
|
6
|
+
const getAttachment = require('./methods/getAttachment');
|
|
7
|
+
const getCharms = require('./methods/getCharms');
|
|
8
|
+
const getWeapons = require('./methods/getWeapons');
|
|
9
|
+
const getUniversalSkins = require('./methods/getUniversalSkins');
|
|
10
|
+
const getSearchAll = require('./methods/getSearchAll');
|
|
11
|
+
const getStats = require('./methods/getStats');
|
|
12
|
+
|
|
13
|
+
const r6Data = {
|
|
14
|
+
getMaps,
|
|
15
|
+
getOperators,
|
|
16
|
+
getRanks,
|
|
17
|
+
getSeasons,
|
|
18
|
+
getServiceStatus,
|
|
19
|
+
getAttachment,
|
|
20
|
+
getCharms,
|
|
21
|
+
getWeapons,
|
|
22
|
+
getUniversalSkins,
|
|
23
|
+
getSearchAll,
|
|
24
|
+
getStats,
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
module.exports = r6Data;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
const axiosInstance = require('../axiosInstance/axiosInstance');
|
|
2
|
+
const buildUrlAndParams = require('./util');
|
|
3
|
+
|
|
4
|
+
async function getAttachment({ name, style, rarity, availability, bundle, season } = {}) {
|
|
5
|
+
try {
|
|
6
|
+
|
|
7
|
+
const url = buildUrlAndParams('/attachment', { name, style, rarity, availability, bundle, season });
|
|
8
|
+
|
|
9
|
+
const response = await axiosInstance.get(url);
|
|
10
|
+
|
|
11
|
+
return response.data;
|
|
12
|
+
} catch (error) {
|
|
13
|
+
console.error('Error during the getAttachment request:', error.message);
|
|
14
|
+
if (error.response && error.response.status === 401) {
|
|
15
|
+
throw new Error('request error');
|
|
16
|
+
}
|
|
17
|
+
throw error;
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
module.exports = getAttachment;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
const axiosInstance = require('../axiosInstance/axiosInstance');
|
|
2
|
+
const buildUrlAndParams = require('./util');
|
|
3
|
+
|
|
4
|
+
async function getCharms({ name, collection, rarity, availability, bundle, season } = {}) {
|
|
5
|
+
try {
|
|
6
|
+
|
|
7
|
+
const url = buildUrlAndParams('/charms', { name, collection, rarity, availability, bundle, season });
|
|
8
|
+
|
|
9
|
+
const response = await axiosInstance.get(url);
|
|
10
|
+
|
|
11
|
+
return response.data;
|
|
12
|
+
} catch (error) {
|
|
13
|
+
console.error('Errore during the getCharms request:', error.message);
|
|
14
|
+
if (error.response && error.response.status === 401) {
|
|
15
|
+
throw new Error('request error');
|
|
16
|
+
}
|
|
17
|
+
throw error;
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
module.exports = getCharms;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
const axiosInstance = require('../axiosInstance/axiosInstance');
|
|
2
|
+
const buildUrlAndParams = require('./util');
|
|
3
|
+
|
|
4
|
+
async function getMaps({ name, location, releaseDate, playlists, mapReworked } = {}) {
|
|
5
|
+
try {
|
|
6
|
+
|
|
7
|
+
const url = buildUrlAndParams('/maps', { name, location, releaseDate, playlists, mapReworked });
|
|
8
|
+
|
|
9
|
+
const response = await axiosInstance.get(url);
|
|
10
|
+
|
|
11
|
+
return response.data;
|
|
12
|
+
} catch (error) {
|
|
13
|
+
console.error('Error during the getMaps request:', error.message);
|
|
14
|
+
if (error.response && error.response.status === 401) {
|
|
15
|
+
throw new Error('request error');
|
|
16
|
+
}
|
|
17
|
+
throw error;
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
module.exports = getMaps;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
const axiosInstance = require('../axiosInstance/axiosInstance');
|
|
2
|
+
const buildUrlAndParams = require('./util');
|
|
3
|
+
|
|
4
|
+
async function getOperators({ name, safename, realname, birthplace, age, date_of_birth, season_introduced, health, speed, unit, country_code, roles, side } = {}) {
|
|
5
|
+
try {
|
|
6
|
+
|
|
7
|
+
const url = buildUrlAndParams('/operators', { name, safename, realname, birthplace, age, date_of_birth, season_introduced, health, speed, unit, country_code, roles, side });
|
|
8
|
+
|
|
9
|
+
const response = await axiosInstance.get(url);
|
|
10
|
+
|
|
11
|
+
return response.data;
|
|
12
|
+
} catch (error) {
|
|
13
|
+
console.error('Error during the getOperators request:', error.message);
|
|
14
|
+
if (error.response && error.response.status === 401) {
|
|
15
|
+
throw new Error('request error');
|
|
16
|
+
}
|
|
17
|
+
throw error;
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
module.exports = getOperators;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
const axiosInstance = require('../axiosInstance/axiosInstance');
|
|
2
|
+
const buildUrlAndParams = require('./util');
|
|
3
|
+
|
|
4
|
+
async function getRanks({ name, min_mmr, max_mmr, version } = {}) {
|
|
5
|
+
try {
|
|
6
|
+
|
|
7
|
+
if (!['v1', 'v2', 'v3', 'v4', 'v5', 'v6'].includes(version)) {
|
|
8
|
+
throw new Error('Version not valid. Choose between v1, v2, v3, v4, v5, and v6.');
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
const url = buildUrlAndParams('/ranks', { name, min_mmr, max_mmr, version });
|
|
12
|
+
|
|
13
|
+
const response = await axiosInstance.get(url);
|
|
14
|
+
|
|
15
|
+
return response.data;
|
|
16
|
+
} catch (error) {
|
|
17
|
+
console.error('Error during the getRanks request:', error.message);
|
|
18
|
+
if (error.response && error.response.status === 401) {
|
|
19
|
+
throw new Error('request error');
|
|
20
|
+
}
|
|
21
|
+
throw error;
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
module.exports = getRanks;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
const axiosInstance = require('../axiosInstance/axiosInstance');
|
|
2
|
+
const buildUrlAndParams = require('./util');
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Search across all R6 entities (operators, weapons, maps, etc.)
|
|
6
|
+
* @param {string} query - The search term to query across all entities
|
|
7
|
+
* @returns {Promise<Object>} - Search results organized by entity type
|
|
8
|
+
*/
|
|
9
|
+
async function getSearchAll(query) {
|
|
10
|
+
if (!query || typeof query !== 'string') {
|
|
11
|
+
throw new Error('Search query is required and must be a string');
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
try {
|
|
15
|
+
const url = buildUrlAndParams('/searchAll', { q: query });
|
|
16
|
+
const response = await axiosInstance.get(url);
|
|
17
|
+
return response.data;
|
|
18
|
+
} catch (error) {
|
|
19
|
+
console.error('Error during the getSearchAll request:', error.message);
|
|
20
|
+
if (error.response && error.response.status === 401) {
|
|
21
|
+
throw new Error('Authentication error');
|
|
22
|
+
}
|
|
23
|
+
throw error;
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
module.exports = getSearchAll;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
const axiosInstance = require('../axiosInstance/axiosInstance');
|
|
2
|
+
const buildUrlAndParams = require('./util');
|
|
3
|
+
|
|
4
|
+
async function getSeasons({ name, map, operators, weapons, description, code, startDate } = {}) {
|
|
5
|
+
try {
|
|
6
|
+
|
|
7
|
+
const url = buildUrlAndParams('/seasons', { name, map, operators, weapons, description, code, startDate });
|
|
8
|
+
|
|
9
|
+
const response = await axiosInstance.get(url);
|
|
10
|
+
|
|
11
|
+
return response.data;
|
|
12
|
+
} catch (error) {
|
|
13
|
+
console.error('Error during the getSeasons request:', error.message);
|
|
14
|
+
if (error.response && error.response.status === 401) {
|
|
15
|
+
throw new Error('request error');
|
|
16
|
+
}
|
|
17
|
+
throw error;
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
module.exports = getSeasons;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
const axiosInstance = require('../axiosInstance/axiosInstance');
|
|
2
|
+
|
|
3
|
+
async function getServiceStatus() {
|
|
4
|
+
try {
|
|
5
|
+
|
|
6
|
+
let url = '/serviceStatus';
|
|
7
|
+
const response = await axiosInstance.get(url);
|
|
8
|
+
|
|
9
|
+
return response.data;
|
|
10
|
+
} catch (error) {
|
|
11
|
+
console.error('Error during the service status request:', error.message);
|
|
12
|
+
if (error.response && error.response.status === 401) {
|
|
13
|
+
throw new Error('request error');
|
|
14
|
+
}
|
|
15
|
+
throw error;
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
module.exports = getServiceStatus;
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
const axiosInstance = require('../axiosInstance/axiosInstance');
|
|
2
|
+
const buildUrlAndParams = require('./util');
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Get Rainbow Six Siege player stats or account information
|
|
6
|
+
* @param {Object} params - Parameters for the request
|
|
7
|
+
* @param {string} params.type - Type of request: "accountInfo" or "stats"
|
|
8
|
+
* @param {string} params.nameOnPlatform - Player name on the platform
|
|
9
|
+
* @param {string} params.platformType - Platform type (uplay, psn, xbl)
|
|
10
|
+
* @param {string} [params.platform_families] - Platform families (required for stats type): "pc" or "console"
|
|
11
|
+
* @param {string} [params.board_id] - Game mode to filter stats (casual, event, warmup, standard, ranked)
|
|
12
|
+
* @returns {Promise<Object>} - Player stats or account information
|
|
13
|
+
*/
|
|
14
|
+
async function getStats({ type, nameOnPlatform, platformType, platform_families, board_id } = {}) {
|
|
15
|
+
try {
|
|
16
|
+
// Validate required parameters
|
|
17
|
+
if (!type || !nameOnPlatform || !platformType) {
|
|
18
|
+
throw new Error('Missing required parameters: type, nameOnPlatform, platformType');
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
// Validate type parameter
|
|
22
|
+
if (type !== 'accountInfo' && type !== 'stats') {
|
|
23
|
+
throw new Error('Invalid type parameter. Must be "accountInfo" or "stats"');
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
// If type is stats, platform_families is required
|
|
27
|
+
if (type === 'stats' && !platform_families) {
|
|
28
|
+
throw new Error('platform_families parameter is required for stats type');
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
// Validate board_id if provided
|
|
32
|
+
if (board_id && !['casual', 'event', 'warmup', 'standard', 'ranked'].includes(board_id)) {
|
|
33
|
+
throw new Error('Invalid board_id. Must be one of: casual, event, warmup, standard, ranked');
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
// Build the URL with parameters
|
|
37
|
+
const params = {
|
|
38
|
+
type,
|
|
39
|
+
nameOnPlatform,
|
|
40
|
+
platformType
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
// Add platform_families for stats type
|
|
44
|
+
if (type === 'stats') {
|
|
45
|
+
params.platform_families = platform_families;
|
|
46
|
+
|
|
47
|
+
// Add board_id if provided
|
|
48
|
+
if (board_id) {
|
|
49
|
+
params.board_id = board_id;
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
const url = buildUrlAndParams('/stats', params);
|
|
54
|
+
|
|
55
|
+
const response = await axiosInstance.get(url);
|
|
56
|
+
|
|
57
|
+
if (response.data &&
|
|
58
|
+
response.data.platform_families_full_profiles &&
|
|
59
|
+
response.data.platform_families_full_profiles.length > 0) {
|
|
60
|
+
|
|
61
|
+
// If board_id is specified, filter the response data
|
|
62
|
+
if (type === 'stats' && board_id && response.data.platform_families_full_profiles) {
|
|
63
|
+
response.data.platform_families_full_profiles.forEach(profile => {
|
|
64
|
+
if (profile.board_ids_full_profiles) {
|
|
65
|
+
// Filter to only include the specified board_id
|
|
66
|
+
profile.board_ids_full_profiles = profile.board_ids_full_profiles.filter(
|
|
67
|
+
board => board.board_id === board_id
|
|
68
|
+
);
|
|
69
|
+
}
|
|
70
|
+
});
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
response.data.platform_families_full_profiles.forEach(profile => {
|
|
74
|
+
if (profile.board_ids_full_profiles) {
|
|
75
|
+
console.log(JSON.stringify(profile.board_ids_full_profiles, null, 2));
|
|
76
|
+
}
|
|
77
|
+
});
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
return response.data;
|
|
81
|
+
} catch (error) {
|
|
82
|
+
console.error(`Error during the getStats (${type}) request:`, error.message);
|
|
83
|
+
if (error.response && error.response.status === 401) {
|
|
84
|
+
throw new Error('Authentication error');
|
|
85
|
+
}
|
|
86
|
+
throw error;
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
module.exports = getStats;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
const axiosInstance = require('../axiosInstance/axiosInstance');
|
|
2
|
+
const buildUrlAndParams = require('./util');
|
|
3
|
+
|
|
4
|
+
async function getUniversalSkins({ name } = {}) {
|
|
5
|
+
try {
|
|
6
|
+
|
|
7
|
+
const url = buildUrlAndParams('/universalSkins', { name });
|
|
8
|
+
|
|
9
|
+
const response = await axiosInstance.get(url);
|
|
10
|
+
|
|
11
|
+
return response.data;
|
|
12
|
+
} catch (error) {
|
|
13
|
+
console.error('Error during the getUniversalSkins request:', error.message);
|
|
14
|
+
if (error.response && error.response.status === 401) {
|
|
15
|
+
throw new Error('request error');
|
|
16
|
+
}
|
|
17
|
+
throw error;
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
module.exports = getUniversalSkins;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
const axiosInstance = require('../axiosInstance/axiosInstance');
|
|
2
|
+
const buildUrlAndParams = require('./util');
|
|
3
|
+
|
|
4
|
+
async function getWeapons({ name } = {}) {
|
|
5
|
+
try {
|
|
6
|
+
|
|
7
|
+
const url = buildUrlAndParams('/weapons', { name });
|
|
8
|
+
|
|
9
|
+
const response = await axiosInstance.get(url);
|
|
10
|
+
|
|
11
|
+
return response.data;
|
|
12
|
+
} catch (error) {
|
|
13
|
+
console.error('Error during the getWeapons request:', error.message);
|
|
14
|
+
if (error.response && error.response.status === 401) {
|
|
15
|
+
throw new Error('request error');
|
|
16
|
+
}
|
|
17
|
+
throw error;
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
module.exports = getWeapons;
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
const axiosInstance = require('../axiosInstance/axiosInstance');
|
|
2
|
+
|
|
3
|
+
async function generateToken(userId) {
|
|
4
|
+
try {
|
|
5
|
+
const response = await axiosInstance.post('/token', { userId });
|
|
6
|
+
console.log('Token generated with success');
|
|
7
|
+
return response.data.token;
|
|
8
|
+
} catch (error) {
|
|
9
|
+
console.error('Error during the token request:', error.message);
|
|
10
|
+
throw error;
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
async function isValidToken(token, userId) {
|
|
15
|
+
try {
|
|
16
|
+
const response = await axiosInstance.post('/tokenManagement', { action: 'verify', userId }, {
|
|
17
|
+
headers: {
|
|
18
|
+
'Authorization': `Bearer ${token}`
|
|
19
|
+
}
|
|
20
|
+
});
|
|
21
|
+
return response.data.isValid;
|
|
22
|
+
} catch (error) {
|
|
23
|
+
console.error('Error during token validation:', error.message);
|
|
24
|
+
throw error;
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
async function getToken(userId) {
|
|
29
|
+
try {
|
|
30
|
+
const response = await axiosInstance.get('/tokenManagement', { params: { action: 'getToken', userId } });
|
|
31
|
+
return response.data.token;
|
|
32
|
+
} catch (error) {
|
|
33
|
+
console.error('Error while getting token:', error.message);
|
|
34
|
+
throw error;
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
module.exports = {
|
|
39
|
+
generateToken,
|
|
40
|
+
isValidToken,
|
|
41
|
+
getToken,
|
|
42
|
+
};
|
package/methods/util.js
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
function buildUrlAndParams(basePath, paramsObj) {
|
|
2
|
+
const params = new URLSearchParams();
|
|
3
|
+
for (const [key, value] of Object.entries(paramsObj)) {
|
|
4
|
+
if (value) {
|
|
5
|
+
params.append(key, value);
|
|
6
|
+
}
|
|
7
|
+
}
|
|
8
|
+
return `${basePath}${params.toString() ? `?${params.toString()}` : ''}`;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
module.exports = buildUrlAndParams;
|
package/package.json
ADDED
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "r6-data.js",
|
|
3
|
+
"version": "1.0.1",
|
|
4
|
+
"description": "A wrapper for the Rainbow Six Siege API that gives you information about player's stats, maps, operators, ranks, seasons, charms etc",
|
|
5
|
+
"main": "index.js",
|
|
6
|
+
"scripts": {
|
|
7
|
+
"test": "echo \"Error: no test specified\" && exit 1"
|
|
8
|
+
},
|
|
9
|
+
"repository": {
|
|
10
|
+
"type": "git",
|
|
11
|
+
"url": "git+https://github.com/mazeor9/r6-data.js"
|
|
12
|
+
},
|
|
13
|
+
"keywords": [
|
|
14
|
+
"r6",
|
|
15
|
+
"rainbow six",
|
|
16
|
+
"rainbow six siege",
|
|
17
|
+
"r6 siege",
|
|
18
|
+
"siege",
|
|
19
|
+
"R6",
|
|
20
|
+
"Rainbow",
|
|
21
|
+
"Rainbow six",
|
|
22
|
+
"Rainbow Six Siege",
|
|
23
|
+
"Siege",
|
|
24
|
+
"R6 siege",
|
|
25
|
+
"r6 siege x",
|
|
26
|
+
"R6 siege x",
|
|
27
|
+
"siege x",
|
|
28
|
+
"r6 operators",
|
|
29
|
+
"r6 maps",
|
|
30
|
+
"r6 skins",
|
|
31
|
+
"r6 stats",
|
|
32
|
+
"r6stats",
|
|
33
|
+
"r6api",
|
|
34
|
+
"r6-api",
|
|
35
|
+
"r6apijs",
|
|
36
|
+
"r6-api-js",
|
|
37
|
+
"r6statsapi",
|
|
38
|
+
"r6statapi",
|
|
39
|
+
"r6stats-api",
|
|
40
|
+
"siegeapi",
|
|
41
|
+
"siege-api",
|
|
42
|
+
"siege x api"
|
|
43
|
+
],
|
|
44
|
+
"author": "mazeor",
|
|
45
|
+
"license": "ISC",
|
|
46
|
+
"dependencies": {
|
|
47
|
+
"axios": "^1.9.0",
|
|
48
|
+
"ms": "^2.1.3"
|
|
49
|
+
},
|
|
50
|
+
"devDependencies": {
|
|
51
|
+
"@types/node": "^22.15.3"
|
|
52
|
+
}
|
|
53
|
+
}
|