r6-data.js 1.1.0 → 1.2.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
@@ -23,9 +23,9 @@ npm i r6-data.js
23
23
 
24
24
  ### Last updated Y10S3
25
25
 
26
- ## Getting Player Stats and Account Information
26
+ ## Getting Player Account Information
27
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.
28
+ The `getAccountInfo()` function allows you to retrieve player profile data from the official Rainbow Six Siege API. This function is specifically designed for retrieving account information such as player level, experience, clearance level, and profile settings.
29
29
 
30
30
  ```javascript
31
31
  const r6Info = require('r6-data.js');
@@ -33,37 +33,16 @@ const r6Info = require('r6-data.js');
33
33
  async function main() {
34
34
  try {
35
35
  // Get player account information
36
- const accountInfo = await r6Info.getStats({
37
- type: 'accountInfo',
36
+ const accountInfo = await r6Info.getAccountInfo({
38
37
  nameOnPlatform: 'PlayerName',
39
38
  platformType: 'uplay'
40
39
  });
41
40
 
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;
41
+ console.log('Account information:', accountInfo);
42
+ return accountInfo;
64
43
 
65
44
  } catch (error) {
66
- console.error('Error retrieving player data:', error.message);
45
+ console.error('Error retrieving account information:', error.message);
67
46
  }
68
47
  }
69
48
 
@@ -72,20 +51,13 @@ main();
72
51
 
73
52
  ### Parameters
74
53
 
75
- The `getStats()` function accepts an object with the following parameters:
76
- For both request types:
54
+ The `getAccountInfo()` function accepts an object with the following parameters:
77
55
 
78
- - `type`: (Required) The type of request - must be either "accountInfo" or "stats"
79
56
  - `nameOnPlatform`: (Required) The player's name on the platform
80
57
  - `platformType`: (Required) The platform type - "uplay", "psn", or "xbl"
81
58
 
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:
59
+ ### Account Information Response
60
+ When using `getAccountInfo()`, you'll receive data about the player's profile, including:
89
61
 
90
62
  - Player level and experience
91
63
  - Clearance level
@@ -93,73 +65,69 @@ When using the `accountInfo` type, you'll receive data about the player's profil
93
65
  - Play time statistics
94
66
  - Player profile settings and customization
95
67
 
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
68
+ ## Getting Player Statistics
112
69
 
113
- ## Getting Latest Siege News
114
- The `getLatestSiegeNews()` function allows you to retrieve the latest news and articles from Rainbow Six Siege.
70
+ The `getPlayerStats()` function allows you to retrieve detailed gameplay statistics from the official Rainbow Six Siege API. This function is specifically designed for retrieving player performance data across different game modes.
115
71
 
116
72
  ```javascript
117
73
  const r6Info = require('r6-data.js');
118
74
 
119
75
  async function main() {
120
76
  try {
121
- // Get latest Siege news
122
- const siegeNews = await r6Info.getLatestSiegeNews();
123
- console.log('Siege News:', siegeNews);
124
-
125
- // Access featured articles
126
- console.log('Featured Articles:', siegeNews.featuredArticles);
127
-
128
- // Access latest articles
129
- console.log('Latest Articles:', siegeNews.latestArticles);
130
-
131
- // Display individual article information
132
- siegeNews.featuredArticles.forEach(article => {
133
- console.log(`Title: ${article.title}`);
134
- console.log(`Link: ${article.link}`);
135
- console.log(`Type: ${article.type}`);
136
- console.log(`Scraped at: ${article.scrapedAt}`);
137
- console.log('---');
77
+ // Get player statistics
78
+ const playerStats = await r6Info.getPlayerStats({
79
+ nameOnPlatform: 'PlayerName',
80
+ platformType: 'uplay',
81
+ platform_families: 'pc'
82
+ });
83
+
84
+ console.log('Player statistics:', playerStats);
85
+ return playerStats;
86
+
87
+ // Get player statistics for ranked mode only
88
+ const rankedStats = await r6Info.getPlayerStats({
89
+ nameOnPlatform: 'PlayerName',
90
+ platformType: 'uplay',
91
+ platform_families: 'pc',
92
+ board_id: 'ranked'
138
93
  });
139
94
 
95
+ console.log('Ranked statistics:', rankedStats);
96
+ return rankedStats;
97
+
140
98
  } catch (error) {
141
- console.error('Error while fetching Siege news:', error.message);
99
+ console.error('Error retrieving player statistics:', error.message);
142
100
  }
143
101
  }
144
102
 
145
103
  main();
146
104
  ```
147
105
 
148
- ### News Response Structure
149
- The function returns an object containing:
106
+ ### Parameters
107
+
108
+ The `getPlayerStats()` function accepts an object with the following parameters:
109
+
110
+ - `nameOnPlatform`: (Required) The player's name on the platform
111
+ - `platformType`: (Required) The platform type - "uplay", "psn", or "xbl"
112
+ - `platform_families`: (Required) The platform family - "pc" or "console"
113
+ - `board_id`: (Optional) The game mode to filter statistics - "casual", "event", "warmup", "standard", or "ranked"
114
+
115
+ ### Player Statistics Response
116
+ When using `getPlayerStats()`, you'll receive detailed gameplay statistics, including:
150
117
 
151
- `featuredArticles`: Array of up to 5 featured articles from siege.gg
152
- `latestArticles`: Array of up to 10 latest articles from siege.gg
153
- `scrapedAt`: Timestamp indicating when the data was retrieved
118
+ - Rank information
119
+ - MMR (Matchmaking Rating)
120
+ - Win/loss records
121
+ - Seasonal performance data
122
+ - Skill metrics across different gameplay modes
154
123
 
155
- Each article object contains:
124
+ You can filter these statistics by game mode using the `board_id` parameter:
156
125
 
157
- `title`: The article title (cleaned from "Siege" suffix)
158
- `imageUrl`: URL of the article's featured image
159
- `link`: Full URL to the article
160
- `type`: Article type ("featured" or "latest")
161
- `category`: Article category (for latest articles: "news" or "general")
162
- `scrapedAt`: Timestamp of when the article was scraped
126
+ - `casual`: Statistics for casual matches
127
+ - `event`: Statistics for limited-time events
128
+ - `warmup`: Statistics for warmup matches
129
+ - `standard`: Statistics for standard matches
130
+ - `ranked`: Statistics for ranked competitive matches
163
131
 
164
132
  ## Searching Across All Entities
165
133
 
package/index.js CHANGED
@@ -8,8 +8,8 @@ const getCharms = require('./methods/getCharms');
8
8
  const getWeapons = require('./methods/getWeapons');
9
9
  const getUniversalSkins = require('./methods/getUniversalSkins');
10
10
  const getSearchAll = require('./methods/getSearchAll');
11
- const getStats = require('./methods/getStats');
12
- const getLatestSiegeNews = require('./methods/getLatestSiegeNews');
11
+ const getAccountInfo = require('./methods/getAccountInfo');
12
+ const getPlayerStats = require('./methods/getPlayerStats');
13
13
 
14
14
  const r6Data = {
15
15
  getMaps,
@@ -22,8 +22,8 @@ const r6Data = {
22
22
  getWeapons,
23
23
  getUniversalSkins,
24
24
  getSearchAll,
25
- getStats,
26
- getLatestSiegeNews,
25
+ getAccountInfo,
26
+ getPlayerStats,
27
27
  };
28
28
 
29
29
  module.exports = r6Data;
@@ -0,0 +1,39 @@
1
+ const axiosInstance = require('../axiosInstance/axiosInstance');
2
+ const buildUrlAndParams = require('./util');
3
+
4
+ /**
5
+ * Get Rainbow Six Siege player account information
6
+ * @param {Object} params - Parameters for the request
7
+ * @param {string} params.nameOnPlatform - Player name on the platform
8
+ * @param {string} params.platformType - Platform type (uplay, psn, xbl)
9
+ * @returns {Promise<Object>} - Player account information
10
+ */
11
+ async function getAccountInfo({ nameOnPlatform, platformType } = {}) {
12
+ try {
13
+ // Validate required parameters
14
+ if (!nameOnPlatform || !platformType) {
15
+ throw new Error('Missing required parameters: nameOnPlatform, platformType');
16
+ }
17
+
18
+ // Build the URL with parameters
19
+ const params = {
20
+ type: 'accountInfo',
21
+ nameOnPlatform,
22
+ platformType
23
+ };
24
+
25
+ const url = buildUrlAndParams('/stats', params);
26
+
27
+ const response = await axiosInstance.get(url);
28
+
29
+ return response.data;
30
+ } catch (error) {
31
+ console.error('Error during the getAccountInfo request:', error.message);
32
+ if (error.response && error.response.status === 401) {
33
+ throw new Error('Authentication error');
34
+ }
35
+ throw error;
36
+ }
37
+ }
38
+
39
+ module.exports = getAccountInfo;
@@ -0,0 +1,75 @@
1
+ const axiosInstance = require('../axiosInstance/axiosInstance');
2
+ const buildUrlAndParams = require('./util');
3
+
4
+ /**
5
+ * Get Rainbow Six Siege player statistics
6
+ * @param {Object} params - Parameters for the request
7
+ * @param {string} params.nameOnPlatform - Player name on the platform
8
+ * @param {string} params.platformType - Platform type (uplay, psn, xbl)
9
+ * @param {string} params.platform_families - Platform families: "pc" or "console"
10
+ * @param {string} [params.board_id] - Game mode to filter stats (casual, event, warmup, standard, ranked)
11
+ * @returns {Promise<Object>} - Player statistics
12
+ */
13
+ async function getPlayerStats({ nameOnPlatform, platformType, platform_families, board_id } = {}) {
14
+ try {
15
+ // Validate required parameters
16
+ if (!nameOnPlatform || !platformType || !platform_families) {
17
+ throw new Error('Missing required parameters: nameOnPlatform, platformType, platform_families');
18
+ }
19
+
20
+ // Validate board_id if provided
21
+ if (board_id && !['casual', 'event', 'warmup', 'standard', 'ranked'].includes(board_id)) {
22
+ throw new Error('Invalid board_id. Must be one of: casual, event, warmup, standard, ranked');
23
+ }
24
+
25
+ // Build the URL with parameters
26
+ const params = {
27
+ type: 'stats',
28
+ nameOnPlatform,
29
+ platformType,
30
+ platform_families
31
+ };
32
+
33
+ // Add board_id if provided
34
+ if (board_id) {
35
+ params.board_id = board_id;
36
+ }
37
+
38
+ const url = buildUrlAndParams('/stats', params);
39
+
40
+ const response = await axiosInstance.get(url);
41
+
42
+ if (response.data &&
43
+ response.data.platform_families_full_profiles &&
44
+ response.data.platform_families_full_profiles.length > 0) {
45
+
46
+ // If board_id is specified, filter the response data
47
+ if (board_id && response.data.platform_families_full_profiles) {
48
+ response.data.platform_families_full_profiles.forEach(profile => {
49
+ if (profile.board_ids_full_profiles) {
50
+ // Filter to only include the specified board_id
51
+ profile.board_ids_full_profiles = profile.board_ids_full_profiles.filter(
52
+ board => board.board_id === board_id
53
+ );
54
+ }
55
+ });
56
+ }
57
+
58
+ response.data.platform_families_full_profiles.forEach(profile => {
59
+ if (profile.board_ids_full_profiles) {
60
+ console.log(JSON.stringify(profile.board_ids_full_profiles, null, 2));
61
+ }
62
+ });
63
+ }
64
+
65
+ return response.data;
66
+ } catch (error) {
67
+ console.error('Error during the getPlayerStats request:', error.message);
68
+ if (error.response && error.response.status === 401) {
69
+ throw new Error('Authentication error');
70
+ }
71
+ throw error;
72
+ }
73
+ }
74
+
75
+ module.exports = getPlayerStats;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "r6-data.js",
3
- "version": "1.1.0",
3
+ "version": "1.2.0",
4
4
  "description": "A wrapper for Rainbow Six Siege API that gives you information about player's stats, maps, operators, ranks, seasons, charms etc",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -45,7 +45,6 @@
45
45
  "license": "ISC",
46
46
  "dependencies": {
47
47
  "axios": "^1.11.0",
48
- "cheerio": "^1.1.0",
49
48
  "ms": "^2.1.3"
50
49
  },
51
50
  "devDependencies": {
@@ -1,60 +0,0 @@
1
- const cheerio = require('cheerio');
2
-
3
- async function getLatestSiegeNews() {
4
- try {
5
- const response = await fetch('https://siege.gg/');
6
- const html = await response.text();
7
- const $ = cheerio.load(html);
8
-
9
- const featuredArticles = [];
10
- const latestArticles = [];
11
-
12
- // Estrae Featured Articles
13
- $('h2:contains("Featured Articles")').parent().find('a').each((index, article) => {
14
- const title = $(article).find('img').attr('alt') || '';
15
- const imageUrl = $(article).find('img').attr('src') || '';
16
- const link = $(article).attr('href') || '';
17
-
18
- if (title && link) {
19
- featuredArticles.push({
20
- title: title.replace(' Siege', '').trim(),
21
- imageUrl,
22
- link: link.startsWith('http') ? link : `https://siege.gg${link}`,
23
- type: 'featured',
24
- scrapedAt: new Date().toISOString()
25
- });
26
- }
27
- });
28
-
29
- // Estrae Latest Articles
30
- $('h2:contains("Latest Articles")').parent().find('a').each((index, article) => {
31
- const title = $(article).find('img').attr('alt') || '';
32
- const imageUrl = $(article).find('img').attr('src') || '';
33
- const link = $(article).attr('href') || '';
34
- const category = $(article).text().includes('News') ? 'news' : 'general';
35
-
36
- if (title && link) {
37
- latestArticles.push({
38
- title: title.replace(' Siege', '').trim(),
39
- imageUrl,
40
- link: link.startsWith('http') ? link : `https://siege.gg${link}`,
41
- category,
42
- type: 'latest',
43
- scrapedAt: new Date().toISOString()
44
- });
45
- }
46
- });
47
-
48
- return {
49
- featuredArticles: featuredArticles.slice(0, 5),
50
- latestArticles: latestArticles.slice(0, 10),
51
- scrapedAt: new Date().toISOString()
52
- };
53
-
54
- } catch (error) {
55
- console.error('Error fetching siege news:', error.message);
56
- throw new Error(`Error fetching siege news: ${error.message}`);
57
- }
58
- }
59
-
60
- module.exports = getLatestSiegeNews;