r6-data.js 1.0.3 → 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 +58 -39
- package/index.js +4 -2
- package/methods/getAccountInfo.js +39 -0
- package/methods/getPlayerStats.js +75 -0
- package/package.json +3 -3
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
|
|
26
|
+
## Getting Player Account Information
|
|
27
27
|
|
|
28
|
-
The `
|
|
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,70 @@ 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.
|
|
37
|
-
type: 'accountInfo',
|
|
36
|
+
const accountInfo = await r6Info.getAccountInfo({
|
|
38
37
|
nameOnPlatform: 'PlayerName',
|
|
39
38
|
platformType: 'uplay'
|
|
40
39
|
});
|
|
41
40
|
|
|
42
|
-
|
|
41
|
+
console.log('Account information:', accountInfo);
|
|
42
|
+
return accountInfo;
|
|
43
43
|
|
|
44
|
+
} catch (error) {
|
|
45
|
+
console.error('Error retrieving account information:', error.message);
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
main();
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
### Parameters
|
|
53
|
+
|
|
54
|
+
The `getAccountInfo()` function accepts an object with the following parameters:
|
|
55
|
+
|
|
56
|
+
- `nameOnPlatform`: (Required) The player's name on the platform
|
|
57
|
+
- `platformType`: (Required) The platform type - "uplay", "psn", or "xbl"
|
|
58
|
+
|
|
59
|
+
### Account Information Response
|
|
60
|
+
When using `getAccountInfo()`, you'll receive data about the player's profile, including:
|
|
61
|
+
|
|
62
|
+
- Player level and experience
|
|
63
|
+
- Clearance level
|
|
64
|
+
- Achievement status
|
|
65
|
+
- Play time statistics
|
|
66
|
+
- Player profile settings and customization
|
|
67
|
+
|
|
68
|
+
## Getting Player Statistics
|
|
69
|
+
|
|
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.
|
|
71
|
+
|
|
72
|
+
```javascript
|
|
73
|
+
const r6Info = require('r6-data.js');
|
|
74
|
+
|
|
75
|
+
async function main() {
|
|
76
|
+
try {
|
|
44
77
|
// Get player statistics
|
|
45
|
-
const playerStats = await r6Info.
|
|
46
|
-
type: 'stats',
|
|
78
|
+
const playerStats = await r6Info.getPlayerStats({
|
|
47
79
|
nameOnPlatform: 'PlayerName',
|
|
48
80
|
platformType: 'uplay',
|
|
49
81
|
platform_families: 'pc'
|
|
50
82
|
});
|
|
51
83
|
|
|
52
|
-
|
|
84
|
+
console.log('Player statistics:', playerStats);
|
|
85
|
+
return playerStats;
|
|
53
86
|
|
|
54
87
|
// Get player statistics for ranked mode only
|
|
55
|
-
const rankedStats = await r6Info.
|
|
56
|
-
type: 'stats',
|
|
88
|
+
const rankedStats = await r6Info.getPlayerStats({
|
|
57
89
|
nameOnPlatform: 'PlayerName',
|
|
58
90
|
platformType: 'uplay',
|
|
59
91
|
platform_families: 'pc',
|
|
60
92
|
board_id: 'ranked'
|
|
61
93
|
});
|
|
62
94
|
|
|
95
|
+
console.log('Ranked statistics:', rankedStats);
|
|
63
96
|
return rankedStats;
|
|
64
97
|
|
|
65
98
|
} catch (error) {
|
|
66
|
-
console.error('Error retrieving player
|
|
99
|
+
console.error('Error retrieving player statistics:', error.message);
|
|
67
100
|
}
|
|
68
101
|
}
|
|
69
102
|
|
|
@@ -72,43 +105,29 @@ main();
|
|
|
72
105
|
|
|
73
106
|
### Parameters
|
|
74
107
|
|
|
75
|
-
The `
|
|
76
|
-
For both request types:
|
|
108
|
+
The `getPlayerStats()` function accepts an object with the following parameters:
|
|
77
109
|
|
|
78
|
-
- `type`: (Required) The type of request - must be either "accountInfo" or "stats"
|
|
79
110
|
- `nameOnPlatform`: (Required) The player's name on the platform
|
|
80
111
|
- `platformType`: (Required) The platform type - "uplay", "psn", or "xbl"
|
|
81
|
-
|
|
82
|
-
Additional parameters for stats type:
|
|
83
|
-
|
|
84
112
|
- `platform_families`: (Required) The platform family - "pc" or "console"
|
|
85
113
|
- `board_id`: (Optional) The game mode to filter statistics - "casual", "event", "warmup", "standard", or "ranked"
|
|
86
114
|
|
|
87
|
-
###
|
|
88
|
-
When using
|
|
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:
|
|
115
|
+
### Player Statistics Response
|
|
116
|
+
When using `getPlayerStats()`, you'll receive detailed gameplay statistics, including:
|
|
98
117
|
|
|
99
|
-
- Rank information
|
|
100
|
-
- MMR (Matchmaking Rating)
|
|
101
|
-
- Win/loss records
|
|
102
|
-
- Seasonal performance data
|
|
103
|
-
- Skill metrics across different gameplay modes
|
|
118
|
+
- Rank information
|
|
119
|
+
- MMR (Matchmaking Rating)
|
|
120
|
+
- Win/loss records
|
|
121
|
+
- Seasonal performance data
|
|
122
|
+
- Skill metrics across different gameplay modes
|
|
104
123
|
|
|
105
|
-
You can filter these statistics by game mode using the `board_id` parameter:
|
|
124
|
+
You can filter these statistics by game mode using the `board_id` parameter:
|
|
106
125
|
|
|
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
|
|
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
|
|
112
131
|
|
|
113
132
|
## Searching Across All Entities
|
|
114
133
|
|
package/index.js
CHANGED
|
@@ -8,7 +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
|
|
11
|
+
const getAccountInfo = require('./methods/getAccountInfo');
|
|
12
|
+
const getPlayerStats = require('./methods/getPlayerStats');
|
|
12
13
|
|
|
13
14
|
const r6Data = {
|
|
14
15
|
getMaps,
|
|
@@ -21,7 +22,8 @@ const r6Data = {
|
|
|
21
22
|
getWeapons,
|
|
22
23
|
getUniversalSkins,
|
|
23
24
|
getSearchAll,
|
|
24
|
-
|
|
25
|
+
getAccountInfo,
|
|
26
|
+
getPlayerStats,
|
|
25
27
|
};
|
|
26
28
|
|
|
27
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.0
|
|
4
|
-
"description": "A wrapper for
|
|
3
|
+
"version": "1.2.0",
|
|
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": {
|
|
7
7
|
"test": "echo \"Error: no test specified\" && exit 1"
|
|
@@ -44,7 +44,7 @@
|
|
|
44
44
|
"author": "mazeor",
|
|
45
45
|
"license": "ISC",
|
|
46
46
|
"dependencies": {
|
|
47
|
-
"axios": "^1.
|
|
47
|
+
"axios": "^1.11.0",
|
|
48
48
|
"ms": "^2.1.3"
|
|
49
49
|
},
|
|
50
50
|
"devDependencies": {
|