r6-data.js 2.0.1 → 2.1.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 CHANGED
@@ -301,6 +301,50 @@ The `getSeasonalStats()` function accepts the API Key and an object with the fol
301
301
  }
302
302
  ```
303
303
 
304
+ ## Getting Operator Statistics
305
+
306
+ The `getOperatorStats()` function allows you to get detailed operator statistics for a specific player.
307
+
308
+ ```javascript
309
+ const r6Info = require('r6-data.js');
310
+
311
+ async function main() {
312
+ try {
313
+ const apiKey = 'YOUR_API_KEY';
314
+
315
+ // Get operator statistics for a player
316
+ const operatorStats = await r6Info.getOperatorStats(apiKey, {
317
+ nameOnPlatform: 'PlayerName',
318
+ platformType: 'uplay',
319
+ // seasonYear: 'Y9S4', // Optional
320
+ // modes: 'ranked' // Optional, default is 'ranked'
321
+ });
322
+
323
+ console.log('Operator statistics:', operatorStats);
324
+ return operatorStats;
325
+
326
+ } catch (error) {
327
+ console.error('Error retrieving operator statistics:', error.message);
328
+ }
329
+ }
330
+
331
+ main();
332
+ ```
333
+
334
+ ### Parameters
335
+
336
+ The `getOperatorStats()` function accepts the API Key and an object with the following parameters:
337
+
338
+ - `apiKey`: (Required) Your API Key from r6data.eu
339
+ - `nameOnPlatform`: (Required) The player's name on the platform
340
+ - `platformType`: (Required) The platform type - "uplay", "psn", or "xbl"
341
+ - `seasonYear`: (Optional) Season year (e.g., Y9S4, Y10S4)
342
+ - `modes`: (Optional) Game mode (ranked, casual, unranked). Default is 'ranked'.
343
+
344
+ ### Operator Statistics Response
345
+
346
+ The response contains detailed statistics for each operator played by the user.
347
+
304
348
  ## Getting Game Statistics
305
349
 
306
350
  The `getGameStats()` function allows you to get real-time player count statistics across all platforms including Steam, Ubisoft Connect, PlayStation, Xbox, and total player counts
package/index.js CHANGED
@@ -13,6 +13,7 @@ const getPlayerStats = require('./methods/getPlayerStats');
13
13
  const createDiscordR6Webhook = require('./methods/createDiscordR6Webhook');
14
14
  const getGameStats = require('./methods/getGameStats');
15
15
  const getSeasonalStats = require('./methods/getSeasonalStats');
16
+ const getOperatorStats = require('./methods/getOperatorStats');
16
17
  const getPlayerComparisons = require('./methods/getPlayerComparisons');
17
18
  const getIsBanned = require('./methods/getIsBanned');
18
19
 
@@ -33,6 +34,7 @@ module.exports = {
33
34
  createDiscordR6Webhook,
34
35
  getGameStats,
35
36
  getSeasonalStats,
37
+ getOperatorStats,
36
38
  getPlayerComparisons,
37
39
  getIsBanned,
38
40
  };
@@ -53,5 +55,6 @@ module.exports.getPlayerStats = getPlayerStats;
53
55
  module.exports.createDiscordR6Webhook = createDiscordR6Webhook;
54
56
  module.exports.getGameStats = getGameStats;
55
57
  module.exports.getSeasonalStats = getSeasonalStats;
58
+ module.exports.getOperatorStats = getOperatorStats;
56
59
  module.exports.getPlayerComparisons = getPlayerComparisons;
57
60
  module.exports.getIsBanned = getIsBanned;
@@ -0,0 +1,54 @@
1
+ const axiosInstance = require('../axiosInstance/axiosInstance');
2
+ const buildUrlAndParams = require('./util');
3
+
4
+ /**
5
+ * Get Rainbow Six Siege operator stats
6
+ * @param {string} apiKey - Your API Key from r6data.eu
7
+ * @param {Object} params - Parameters for the request
8
+ * @param {string} params.nameOnPlatform - Player name on the platform
9
+ * @param {string} params.platformType - Platform type (uplay, psn, xbl)
10
+ * @param {string} [params.seasonYear] - Season year (e.g., Y9S4, Y10S4)
11
+ * @param {string} [params.modes] - Game mode (ranked, casual, unranked). Default is 'ranked'.
12
+ * @returns {Promise<Object>} - Operator stats
13
+ */
14
+ async function getOperatorStats(apiKey, { nameOnPlatform, platformType, seasonYear, modes } = {}) {
15
+ try {
16
+ // Validate required parameters
17
+ if (!apiKey) {
18
+ throw new Error('Missing required parameter: apiKey');
19
+ }
20
+ if (!nameOnPlatform || !platformType) {
21
+ throw new Error('Missing required parameters: nameOnPlatform, platformType');
22
+ }
23
+
24
+ // Build the URL with parameters
25
+ const params = {
26
+ type: 'operatorStats',
27
+ nameOnPlatform,
28
+ platformType,
29
+ modes
30
+ };
31
+
32
+ if (seasonYear) {
33
+ params.seasonYear = seasonYear;
34
+ }
35
+
36
+ const url = buildUrlAndParams('/stats', params);
37
+
38
+ const response = await axiosInstance.get(url, {
39
+ headers: {
40
+ 'api-key': apiKey
41
+ }
42
+ });
43
+
44
+ return response.data;
45
+ } catch (error) {
46
+ console.error('Error during the getOperatorStats request:', error.message);
47
+ if (error.response && error.response.status === 401) {
48
+ throw new Error('Authentication error');
49
+ }
50
+ throw error;
51
+ }
52
+ }
53
+
54
+ module.exports = getOperatorStats;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "r6-data.js",
3
- "version": "2.0.1",
3
+ "version": "2.1.0",
4
4
  "description": "R6 (Rainbow Six Siege) API wrapper for player stats, operators, maps, ranks, seasons, charms, skins and game datas. Last Updated Y10S4",
5
5
  "main": "index.js",
6
6
  "module": "index.js",
@@ -5,6 +5,7 @@ import {
5
5
  GetIsBannedParams,
6
6
  PlayerStatsParams,
7
7
  SeasonalStatsParams,
8
+ OperatorStatsParams,
8
9
  PlayerComparisonsParams,
9
10
  GetMapsParams,
10
11
  GetOperatorsParams,
@@ -27,6 +28,7 @@ export function getAccountInfo(apiKey: string, params: AccountInfoParams): Promi
27
28
  export function getIsBanned(apiKey: string, params: GetIsBannedParams): Promise<any>;
28
29
  export function getPlayerStats(apiKey: string, params: PlayerStatsParams): Promise<any>;
29
30
  export function getSeasonalStats(apiKey: string, params: SeasonalStatsParams): Promise<any>;
31
+ export function getOperatorStats(apiKey: string, params: OperatorStatsParams): Promise<any>;
30
32
  export function getServiceStatus(apiKey: string): Promise<any>;
31
33
  export function getGameStats(apiKey: string): Promise<GameStats>;
32
34
  export function getMaps(apiKey: string, params?: GetMapsParams): Promise<any[]>;
@@ -16,6 +16,11 @@ export interface PlayerStatsParams extends AccountInfoParams {
16
16
 
17
17
  export interface SeasonalStatsParams extends AccountInfoParams {}
18
18
 
19
+ export interface OperatorStatsParams extends AccountInfoParams {
20
+ seasonYear?: string;
21
+ modes?: 'ranked' | 'casual' | 'unranked';
22
+ }
23
+
19
24
  export interface PlayerComparisonsParams {
20
25
  players: Array<{
21
26
  nameOnPlatform: string;