r6-data.js 1.1.0 → 1.2.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 +54 -88
- package/index.js +4 -4
- package/methods/getAccountInfo.js +39 -0
- package/methods/getPlayerStats.js +75 -0
- package/package.json +2 -3
- package/methods/getLatestSiegeNews.js +0 -60
package/README.md
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
## r6-data.js
|
|
2
|
-
|
|
2
|
+
Rainbow Six Siege API wrapper that gives infos about player's stats, maps, operators, ranks, seasons, charms etc. Last updated Y10S3
|
|
3
3
|
|
|
4
4
|
<div align="center">
|
|
5
5
|
<p>
|
|
@@ -21,11 +21,9 @@ npm install r6-data.js
|
|
|
21
21
|
npm i r6-data.js
|
|
22
22
|
```
|
|
23
23
|
|
|
24
|
-
|
|
24
|
+
## Getting Player Account Information
|
|
25
25
|
|
|
26
|
-
|
|
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.
|
|
26
|
+
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
27
|
|
|
30
28
|
```javascript
|
|
31
29
|
const r6Info = require('r6-data.js');
|
|
@@ -33,37 +31,16 @@ const r6Info = require('r6-data.js');
|
|
|
33
31
|
async function main() {
|
|
34
32
|
try {
|
|
35
33
|
// Get player account information
|
|
36
|
-
const accountInfo = await r6Info.
|
|
37
|
-
type: 'accountInfo',
|
|
34
|
+
const accountInfo = await r6Info.getAccountInfo({
|
|
38
35
|
nameOnPlatform: 'PlayerName',
|
|
39
36
|
platformType: 'uplay'
|
|
40
37
|
});
|
|
41
38
|
|
|
42
|
-
|
|
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;
|
|
39
|
+
console.log('Account information:', accountInfo);
|
|
40
|
+
return accountInfo;
|
|
64
41
|
|
|
65
42
|
} catch (error) {
|
|
66
|
-
console.error('Error retrieving
|
|
43
|
+
console.error('Error retrieving account information:', error.message);
|
|
67
44
|
}
|
|
68
45
|
}
|
|
69
46
|
|
|
@@ -72,20 +49,13 @@ main();
|
|
|
72
49
|
|
|
73
50
|
### Parameters
|
|
74
51
|
|
|
75
|
-
The `
|
|
76
|
-
For both request types:
|
|
52
|
+
The `getAccountInfo()` function accepts an object with the following parameters:
|
|
77
53
|
|
|
78
|
-
- `type`: (Required) The type of request - must be either "accountInfo" or "stats"
|
|
79
54
|
- `nameOnPlatform`: (Required) The player's name on the platform
|
|
80
55
|
- `platformType`: (Required) The platform type - "uplay", "psn", or "xbl"
|
|
81
56
|
|
|
82
|
-
|
|
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:
|
|
57
|
+
### Account Information Response
|
|
58
|
+
When using `getAccountInfo()`, you'll receive data about the player's profile, including:
|
|
89
59
|
|
|
90
60
|
- Player level and experience
|
|
91
61
|
- Clearance level
|
|
@@ -93,73 +63,69 @@ When using the `accountInfo` type, you'll receive data about the player's profil
|
|
|
93
63
|
- Play time statistics
|
|
94
64
|
- Player profile settings and customization
|
|
95
65
|
|
|
96
|
-
|
|
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:
|
|
66
|
+
## Getting Player Statistics
|
|
106
67
|
|
|
107
|
-
|
|
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
|
-
## Getting Latest Siege News
|
|
114
|
-
The `getLatestSiegeNews()` function allows you to retrieve the latest news and articles from Rainbow Six Siege.
|
|
68
|
+
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
69
|
|
|
116
70
|
```javascript
|
|
117
71
|
const r6Info = require('r6-data.js');
|
|
118
72
|
|
|
119
73
|
async function main() {
|
|
120
74
|
try {
|
|
121
|
-
// Get
|
|
122
|
-
const
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
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('---');
|
|
75
|
+
// Get player statistics
|
|
76
|
+
const playerStats = await r6Info.getPlayerStats({
|
|
77
|
+
nameOnPlatform: 'PlayerName',
|
|
78
|
+
platformType: 'uplay',
|
|
79
|
+
platform_families: 'pc'
|
|
138
80
|
});
|
|
81
|
+
|
|
82
|
+
console.log('Player statistics:', playerStats);
|
|
83
|
+
return playerStats;
|
|
84
|
+
|
|
85
|
+
// Get player statistics for ranked mode only
|
|
86
|
+
const rankedStats = await r6Info.getPlayerStats({
|
|
87
|
+
nameOnPlatform: 'PlayerName',
|
|
88
|
+
platformType: 'uplay',
|
|
89
|
+
platform_families: 'pc',
|
|
90
|
+
board_id: 'ranked'
|
|
91
|
+
});
|
|
92
|
+
|
|
93
|
+
console.log('Ranked statistics:', rankedStats);
|
|
94
|
+
return rankedStats;
|
|
139
95
|
|
|
140
96
|
} catch (error) {
|
|
141
|
-
console.error('Error
|
|
97
|
+
console.error('Error retrieving player statistics:', error.message);
|
|
142
98
|
}
|
|
143
99
|
}
|
|
144
100
|
|
|
145
101
|
main();
|
|
146
102
|
```
|
|
147
103
|
|
|
148
|
-
###
|
|
149
|
-
|
|
104
|
+
### Parameters
|
|
105
|
+
|
|
106
|
+
The `getPlayerStats()` function accepts an object with the following parameters:
|
|
107
|
+
|
|
108
|
+
- `nameOnPlatform`: (Required) The player's name on the platform
|
|
109
|
+
- `platformType`: (Required) The platform type - "uplay", "psn", or "xbl"
|
|
110
|
+
- `platform_families`: (Required) The platform family - "pc" or "console"
|
|
111
|
+
- `board_id`: (Optional) The game mode to filter statistics - "casual", "event", "warmup", "standard", or "ranked"
|
|
112
|
+
|
|
113
|
+
### Player Statistics Response
|
|
114
|
+
When using `getPlayerStats()`, you'll receive detailed gameplay statistics, including:
|
|
150
115
|
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
116
|
+
- Rank information
|
|
117
|
+
- MMR (Matchmaking Rating)
|
|
118
|
+
- Win/loss records
|
|
119
|
+
- Seasonal performance data
|
|
120
|
+
- Skill metrics across different gameplay modes
|
|
154
121
|
|
|
155
|
-
|
|
122
|
+
You can filter these statistics by game mode using the `board_id` parameter:
|
|
156
123
|
|
|
157
|
-
`
|
|
158
|
-
`
|
|
159
|
-
`
|
|
160
|
-
`
|
|
161
|
-
`
|
|
162
|
-
`scrapedAt`: Timestamp of when the article was scraped
|
|
124
|
+
- `casual`: Statistics for casual matches
|
|
125
|
+
- `event`: Statistics for limited-time events
|
|
126
|
+
- `warmup`: Statistics for warmup matches
|
|
127
|
+
- `standard`: Statistics for standard matches
|
|
128
|
+
- `ranked`: Statistics for ranked competitive matches
|
|
163
129
|
|
|
164
130
|
## Searching Across All Entities
|
|
165
131
|
|
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
|
|
12
|
-
const
|
|
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
|
-
|
|
26
|
-
|
|
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,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "r6-data.js",
|
|
3
|
-
"version": "1.1
|
|
4
|
-
"description": "
|
|
3
|
+
"version": "1.2.1",
|
|
4
|
+
"description": "Rainbow Six Siege API wrapper that gives infos about player's stats, maps, operators, ranks, seasons, charms etc. Last updated Y10S3",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"scripts": {
|
|
7
7
|
"test": "echo \"Error: no test specified\" && exit 1"
|
|
@@ -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;
|