r6-data.js 2.1.0 → 2.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 +1 -1
- package/axiosInstance/axiosInstance.js +2 -0
- package/methods/createDiscordR6Webhook.js +2 -1
- package/methods/getAccountInfo.js +47 -47
- package/methods/getAttachment.js +28 -28
- package/methods/getCharms.js +28 -28
- package/methods/getGameStats.js +38 -38
- package/methods/getIsBanned.js +47 -47
- package/methods/getMaps.js +28 -28
- package/methods/getOperatorStats.js +54 -54
- package/methods/getOperators.js +28 -28
- package/methods/getPlayerComparisons.js +121 -121
- package/methods/getPlayerStats.js +77 -83
- package/methods/getRanks.js +32 -32
- package/methods/getSearchAll.js +35 -35
- package/methods/getSeasonalStats.js +47 -47
- package/methods/getSeasons.js +28 -28
- package/methods/getServiceStatus.js +26 -26
- package/methods/getStats.js +92 -98
- package/methods/getUniversalSkins.js +28 -28
- package/methods/getWeapons.js +28 -28
- package/methods/tokenManager.js +0 -1
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# r6-data.js — R6 Rainbow Six Siege API Wrapper
|
|
2
2
|
|
|
3
|
-
**Rainbow Six Siege (R6) API wrapper** - Get player stats, operators, maps, ranks, seasons, charms and more. Full TypeScript support included. Last updated
|
|
3
|
+
**Rainbow Six Siege (R6) API wrapper** - Get player stats, operators, maps, ranks, seasons, charms and more. Full TypeScript support included. Last updated Y11S1
|
|
4
4
|
|
|
5
5
|
<div align="center">
|
|
6
6
|
<p>
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
const axios = require('axios');
|
|
2
|
+
const pkg = require('../package.json');
|
|
2
3
|
|
|
3
4
|
const axiosInstance = axios.create({
|
|
4
5
|
baseURL: 'https://api.r6data.eu/api',
|
|
@@ -6,6 +7,7 @@ const axiosInstance = axios.create({
|
|
|
6
7
|
'Content-Type': 'application/json',
|
|
7
8
|
'Accept': 'application/json',
|
|
8
9
|
'Cache-Control': 'no-cache',
|
|
10
|
+
'User-Agent': `r6-data.js/${pkg.version}`,
|
|
9
11
|
},
|
|
10
12
|
});
|
|
11
13
|
|
|
@@ -11,7 +11,8 @@ async function createDiscordR6Webhook(webhookUrl, playerData, options = {}) {
|
|
|
11
11
|
}
|
|
12
12
|
|
|
13
13
|
// Validate webhook URL format
|
|
14
|
-
|
|
14
|
+
const discordWebhookRegex = /^https:\/\/(?:ptb\.|canary\.)?discord\.com\/api\/webhooks\/\d+\/[A-Za-z0-9-_]+$/;
|
|
15
|
+
if (!discordWebhookRegex.test(webhookUrl)) {
|
|
15
16
|
throw new Error('Invalid Discord webhook URL format');
|
|
16
17
|
}
|
|
17
18
|
|
|
@@ -1,47 +1,47 @@
|
|
|
1
|
-
const axiosInstance = require('../axiosInstance/axiosInstance');
|
|
2
|
-
const buildUrlAndParams = require('./util');
|
|
3
|
-
|
|
4
|
-
/**
|
|
5
|
-
* Get Rainbow Six Siege player account information
|
|
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
|
-
* @returns {Promise<Object>} - Player account information
|
|
11
|
-
*/
|
|
12
|
-
async function getAccountInfo(apiKey, { nameOnPlatform, platformType } = {}) {
|
|
13
|
-
try {
|
|
14
|
-
// Validate required parameters
|
|
15
|
-
if (!apiKey) {
|
|
16
|
-
throw new Error('Missing required parameter: apiKey');
|
|
17
|
-
}
|
|
18
|
-
if (!nameOnPlatform || !platformType) {
|
|
19
|
-
throw new Error('Missing required parameters: nameOnPlatform, platformType');
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
// Build the URL with parameters
|
|
23
|
-
const params = {
|
|
24
|
-
type: 'accountInfo',
|
|
25
|
-
nameOnPlatform,
|
|
26
|
-
platformType
|
|
27
|
-
};
|
|
28
|
-
|
|
29
|
-
const url = buildUrlAndParams('/stats', params);
|
|
30
|
-
|
|
31
|
-
const response = await axiosInstance.get(url, {
|
|
32
|
-
headers: {
|
|
33
|
-
'api-key': apiKey
|
|
34
|
-
}
|
|
35
|
-
});
|
|
36
|
-
|
|
37
|
-
return response.data;
|
|
38
|
-
} catch (error) {
|
|
39
|
-
console.error('Error during the getAccountInfo request:', error.message);
|
|
40
|
-
if (error.response && error.response.status === 401) {
|
|
41
|
-
throw new Error('Authentication error');
|
|
42
|
-
}
|
|
43
|
-
throw error;
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
module.exports = getAccountInfo;
|
|
1
|
+
const axiosInstance = require('../axiosInstance/axiosInstance');
|
|
2
|
+
const buildUrlAndParams = require('./util');
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Get Rainbow Six Siege player account information
|
|
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
|
+
* @returns {Promise<Object>} - Player account information
|
|
11
|
+
*/
|
|
12
|
+
async function getAccountInfo(apiKey, { nameOnPlatform, platformType } = {}) {
|
|
13
|
+
try {
|
|
14
|
+
// Validate required parameters
|
|
15
|
+
if (!apiKey) {
|
|
16
|
+
throw new Error('Missing required parameter: apiKey');
|
|
17
|
+
}
|
|
18
|
+
if (!nameOnPlatform || !platformType) {
|
|
19
|
+
throw new Error('Missing required parameters: nameOnPlatform, platformType');
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
// Build the URL with parameters
|
|
23
|
+
const params = {
|
|
24
|
+
type: 'accountInfo',
|
|
25
|
+
nameOnPlatform,
|
|
26
|
+
platformType
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
const url = buildUrlAndParams('/stats', params);
|
|
30
|
+
|
|
31
|
+
const response = await axiosInstance.get(url, {
|
|
32
|
+
headers: {
|
|
33
|
+
'api-key': apiKey
|
|
34
|
+
}
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
return response.data;
|
|
38
|
+
} catch (error) {
|
|
39
|
+
console.error('Error during the getAccountInfo request:', error.message);
|
|
40
|
+
if (error.response && error.response.status === 401) {
|
|
41
|
+
throw new Error('Authentication error');
|
|
42
|
+
}
|
|
43
|
+
throw error;
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
module.exports = getAccountInfo;
|
package/methods/getAttachment.js
CHANGED
|
@@ -1,28 +1,28 @@
|
|
|
1
|
-
const axiosInstance = require('../axiosInstance/axiosInstance');
|
|
2
|
-
const buildUrlAndParams = require('./util');
|
|
3
|
-
|
|
4
|
-
async function getAttachment(apiKey, { name, style, rarity, availability, bundle, season } = {}) {
|
|
5
|
-
try {
|
|
6
|
-
if (!apiKey) {
|
|
7
|
-
throw new Error('Missing required parameter: apiKey');
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
const url = buildUrlAndParams('/attachment', { name, style, rarity, availability, bundle, season });
|
|
11
|
-
|
|
12
|
-
const response = await axiosInstance.get(url, {
|
|
13
|
-
headers: {
|
|
14
|
-
'api-key': apiKey
|
|
15
|
-
}
|
|
16
|
-
});
|
|
17
|
-
|
|
18
|
-
return response.data;
|
|
19
|
-
} catch (error) {
|
|
20
|
-
console.error('Error during the getAttachment request:', error.message);
|
|
21
|
-
if (error.response && error.response.status === 401) {
|
|
22
|
-
throw new Error('request error');
|
|
23
|
-
}
|
|
24
|
-
throw error;
|
|
25
|
-
}
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
module.exports = getAttachment;
|
|
1
|
+
const axiosInstance = require('../axiosInstance/axiosInstance');
|
|
2
|
+
const buildUrlAndParams = require('./util');
|
|
3
|
+
|
|
4
|
+
async function getAttachment(apiKey, { name, style, rarity, availability, bundle, season } = {}) {
|
|
5
|
+
try {
|
|
6
|
+
if (!apiKey) {
|
|
7
|
+
throw new Error('Missing required parameter: apiKey');
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
const url = buildUrlAndParams('/attachment', { name, style, rarity, availability, bundle, season });
|
|
11
|
+
|
|
12
|
+
const response = await axiosInstance.get(url, {
|
|
13
|
+
headers: {
|
|
14
|
+
'api-key': apiKey
|
|
15
|
+
}
|
|
16
|
+
});
|
|
17
|
+
|
|
18
|
+
return response.data;
|
|
19
|
+
} catch (error) {
|
|
20
|
+
console.error('Error during the getAttachment request:', error.message);
|
|
21
|
+
if (error.response && error.response.status === 401) {
|
|
22
|
+
throw new Error('request error');
|
|
23
|
+
}
|
|
24
|
+
throw error;
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
module.exports = getAttachment;
|
package/methods/getCharms.js
CHANGED
|
@@ -1,28 +1,28 @@
|
|
|
1
|
-
const axiosInstance = require('../axiosInstance/axiosInstance');
|
|
2
|
-
const buildUrlAndParams = require('./util');
|
|
3
|
-
|
|
4
|
-
async function getCharms(apiKey, { name, collection, rarity, availability, bundle, season } = {}) {
|
|
5
|
-
try {
|
|
6
|
-
if (!apiKey) {
|
|
7
|
-
throw new Error('Missing required parameter: apiKey');
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
const url = buildUrlAndParams('/charms', { name, collection, rarity, availability, bundle, season });
|
|
11
|
-
|
|
12
|
-
const response = await axiosInstance.get(url, {
|
|
13
|
-
headers: {
|
|
14
|
-
'api-key': apiKey
|
|
15
|
-
}
|
|
16
|
-
});
|
|
17
|
-
|
|
18
|
-
return response.data;
|
|
19
|
-
} catch (error) {
|
|
20
|
-
console.error('Errore during the getCharms request:', error.message);
|
|
21
|
-
if (error.response && error.response.status === 401) {
|
|
22
|
-
throw new Error('request error');
|
|
23
|
-
}
|
|
24
|
-
throw error;
|
|
25
|
-
}
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
module.exports = getCharms;
|
|
1
|
+
const axiosInstance = require('../axiosInstance/axiosInstance');
|
|
2
|
+
const buildUrlAndParams = require('./util');
|
|
3
|
+
|
|
4
|
+
async function getCharms(apiKey, { name, collection, rarity, availability, bundle, season } = {}) {
|
|
5
|
+
try {
|
|
6
|
+
if (!apiKey) {
|
|
7
|
+
throw new Error('Missing required parameter: apiKey');
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
const url = buildUrlAndParams('/charms', { name, collection, rarity, availability, bundle, season });
|
|
11
|
+
|
|
12
|
+
const response = await axiosInstance.get(url, {
|
|
13
|
+
headers: {
|
|
14
|
+
'api-key': apiKey
|
|
15
|
+
}
|
|
16
|
+
});
|
|
17
|
+
|
|
18
|
+
return response.data;
|
|
19
|
+
} catch (error) {
|
|
20
|
+
console.error('Errore during the getCharms request:', error.message);
|
|
21
|
+
if (error.response && error.response.status === 401) {
|
|
22
|
+
throw new Error('request error');
|
|
23
|
+
}
|
|
24
|
+
throw error;
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
module.exports = getCharms;
|
package/methods/getGameStats.js
CHANGED
|
@@ -1,38 +1,38 @@
|
|
|
1
|
-
const axiosInstance = require('../axiosInstance/axiosInstance');
|
|
2
|
-
const buildUrlAndParams = require('./util');
|
|
3
|
-
|
|
4
|
-
/**
|
|
5
|
-
* Get Rainbow Six Siege game stats for all platform
|
|
6
|
-
* @param {string} apiKey - Your API Key from r6data.eu
|
|
7
|
-
* @returns {Promise<Object>} - Game stats for all platform
|
|
8
|
-
*/
|
|
9
|
-
async function getGameStats(apiKey) {
|
|
10
|
-
try {
|
|
11
|
-
if (!apiKey) {
|
|
12
|
-
throw new Error('Missing required parameter: apiKey');
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
// Build the URL with parameters
|
|
16
|
-
const params = {
|
|
17
|
-
type: 'gameStats'
|
|
18
|
-
};
|
|
19
|
-
|
|
20
|
-
const url = buildUrlAndParams('/stats', params);
|
|
21
|
-
|
|
22
|
-
const response = await axiosInstance.get(url, {
|
|
23
|
-
headers: {
|
|
24
|
-
'api-key': apiKey
|
|
25
|
-
}
|
|
26
|
-
});
|
|
27
|
-
|
|
28
|
-
return response.data;
|
|
29
|
-
} catch (error) {
|
|
30
|
-
console.error('Error during the game stats request:', error.message);
|
|
31
|
-
if (error.response && error.response.status === 401) {
|
|
32
|
-
throw new Error('request error');
|
|
33
|
-
}
|
|
34
|
-
throw error;
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
module.exports = getGameStats;
|
|
1
|
+
const axiosInstance = require('../axiosInstance/axiosInstance');
|
|
2
|
+
const buildUrlAndParams = require('./util');
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Get Rainbow Six Siege game stats for all platform
|
|
6
|
+
* @param {string} apiKey - Your API Key from r6data.eu
|
|
7
|
+
* @returns {Promise<Object>} - Game stats for all platform
|
|
8
|
+
*/
|
|
9
|
+
async function getGameStats(apiKey) {
|
|
10
|
+
try {
|
|
11
|
+
if (!apiKey) {
|
|
12
|
+
throw new Error('Missing required parameter: apiKey');
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
// Build the URL with parameters
|
|
16
|
+
const params = {
|
|
17
|
+
type: 'gameStats'
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
const url = buildUrlAndParams('/stats', params);
|
|
21
|
+
|
|
22
|
+
const response = await axiosInstance.get(url, {
|
|
23
|
+
headers: {
|
|
24
|
+
'api-key': apiKey
|
|
25
|
+
}
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
return response.data;
|
|
29
|
+
} catch (error) {
|
|
30
|
+
console.error('Error during the game stats request:', error.message);
|
|
31
|
+
if (error.response && error.response.status === 401) {
|
|
32
|
+
throw new Error('request error');
|
|
33
|
+
}
|
|
34
|
+
throw error;
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
module.exports = getGameStats;
|
package/methods/getIsBanned.js
CHANGED
|
@@ -1,47 +1,47 @@
|
|
|
1
|
-
const axiosInstance = require('../axiosInstance/axiosInstance');
|
|
2
|
-
const buildUrlAndParams = require('./util');
|
|
3
|
-
|
|
4
|
-
/**
|
|
5
|
-
* Get Rainbow Six Siege player ban status
|
|
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
|
-
* @returns {Promise<Object>} - Player ban status
|
|
11
|
-
*/
|
|
12
|
-
async function getIsBanned(apiKey, { nameOnPlatform, platformType } = {}) {
|
|
13
|
-
try {
|
|
14
|
-
// Validate required parameters
|
|
15
|
-
if (!apiKey) {
|
|
16
|
-
throw new Error('Missing required parameter: apiKey');
|
|
17
|
-
}
|
|
18
|
-
if (!nameOnPlatform || !platformType) {
|
|
19
|
-
throw new Error('Missing required parameters: nameOnPlatform, platformType');
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
// Build the URL with parameters
|
|
23
|
-
const params = {
|
|
24
|
-
type: 'isBanned',
|
|
25
|
-
nameOnPlatform,
|
|
26
|
-
platformType
|
|
27
|
-
};
|
|
28
|
-
|
|
29
|
-
const url = buildUrlAndParams('/stats', params);
|
|
30
|
-
|
|
31
|
-
const response = await axiosInstance.get(url, {
|
|
32
|
-
headers: {
|
|
33
|
-
'api-key': apiKey
|
|
34
|
-
}
|
|
35
|
-
});
|
|
36
|
-
|
|
37
|
-
return response.data;
|
|
38
|
-
} catch (error) {
|
|
39
|
-
console.error('Error during the getIsBanned request:', error.message);
|
|
40
|
-
if (error.response && error.response.status === 401) {
|
|
41
|
-
throw new Error('Authentication error');
|
|
42
|
-
}
|
|
43
|
-
throw error;
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
module.exports = getIsBanned;
|
|
1
|
+
const axiosInstance = require('../axiosInstance/axiosInstance');
|
|
2
|
+
const buildUrlAndParams = require('./util');
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Get Rainbow Six Siege player ban status
|
|
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
|
+
* @returns {Promise<Object>} - Player ban status
|
|
11
|
+
*/
|
|
12
|
+
async function getIsBanned(apiKey, { nameOnPlatform, platformType } = {}) {
|
|
13
|
+
try {
|
|
14
|
+
// Validate required parameters
|
|
15
|
+
if (!apiKey) {
|
|
16
|
+
throw new Error('Missing required parameter: apiKey');
|
|
17
|
+
}
|
|
18
|
+
if (!nameOnPlatform || !platformType) {
|
|
19
|
+
throw new Error('Missing required parameters: nameOnPlatform, platformType');
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
// Build the URL with parameters
|
|
23
|
+
const params = {
|
|
24
|
+
type: 'isBanned',
|
|
25
|
+
nameOnPlatform,
|
|
26
|
+
platformType
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
const url = buildUrlAndParams('/stats', params);
|
|
30
|
+
|
|
31
|
+
const response = await axiosInstance.get(url, {
|
|
32
|
+
headers: {
|
|
33
|
+
'api-key': apiKey
|
|
34
|
+
}
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
return response.data;
|
|
38
|
+
} catch (error) {
|
|
39
|
+
console.error('Error during the getIsBanned request:', error.message);
|
|
40
|
+
if (error.response && error.response.status === 401) {
|
|
41
|
+
throw new Error('Authentication error');
|
|
42
|
+
}
|
|
43
|
+
throw error;
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
module.exports = getIsBanned;
|
package/methods/getMaps.js
CHANGED
|
@@ -1,28 +1,28 @@
|
|
|
1
|
-
const axiosInstance = require('../axiosInstance/axiosInstance');
|
|
2
|
-
const buildUrlAndParams = require('./util');
|
|
3
|
-
|
|
4
|
-
async function getMaps(apiKey, { name, location, releaseDate, playlists, mapReworked } = {}) {
|
|
5
|
-
try {
|
|
6
|
-
if (!apiKey) {
|
|
7
|
-
throw new Error('Missing required parameter: apiKey');
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
const url = buildUrlAndParams('/maps', { name, location, releaseDate, playlists, mapReworked });
|
|
11
|
-
|
|
12
|
-
const response = await axiosInstance.get(url, {
|
|
13
|
-
headers: {
|
|
14
|
-
'api-key': apiKey
|
|
15
|
-
}
|
|
16
|
-
});
|
|
17
|
-
|
|
18
|
-
return response.data;
|
|
19
|
-
} catch (error) {
|
|
20
|
-
console.error('Error during the getMaps request:', error.message);
|
|
21
|
-
if (error.response && error.response.status === 401) {
|
|
22
|
-
throw new Error('request error');
|
|
23
|
-
}
|
|
24
|
-
throw error;
|
|
25
|
-
}
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
module.exports = getMaps;
|
|
1
|
+
const axiosInstance = require('../axiosInstance/axiosInstance');
|
|
2
|
+
const buildUrlAndParams = require('./util');
|
|
3
|
+
|
|
4
|
+
async function getMaps(apiKey, { name, location, releaseDate, playlists, mapReworked } = {}) {
|
|
5
|
+
try {
|
|
6
|
+
if (!apiKey) {
|
|
7
|
+
throw new Error('Missing required parameter: apiKey');
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
const url = buildUrlAndParams('/maps', { name, location, releaseDate, playlists, mapReworked });
|
|
11
|
+
|
|
12
|
+
const response = await axiosInstance.get(url, {
|
|
13
|
+
headers: {
|
|
14
|
+
'api-key': apiKey
|
|
15
|
+
}
|
|
16
|
+
});
|
|
17
|
+
|
|
18
|
+
return response.data;
|
|
19
|
+
} catch (error) {
|
|
20
|
+
console.error('Error during the getMaps request:', error.message);
|
|
21
|
+
if (error.response && error.response.status === 401) {
|
|
22
|
+
throw new Error('request error');
|
|
23
|
+
}
|
|
24
|
+
throw error;
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
module.exports = getMaps;
|
|
@@ -1,54 +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;
|
|
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/methods/getOperators.js
CHANGED
|
@@ -1,28 +1,28 @@
|
|
|
1
|
-
const axiosInstance = require('../axiosInstance/axiosInstance');
|
|
2
|
-
const buildUrlAndParams = require('./util');
|
|
3
|
-
|
|
4
|
-
async function getOperators(apiKey, { name, safename, realname, birthplace, age, date_of_birth, season_introduced, health, speed, unit, country_code, roles, side } = {}) {
|
|
5
|
-
try {
|
|
6
|
-
if (!apiKey) {
|
|
7
|
-
throw new Error('Missing required parameter: apiKey');
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
const url = buildUrlAndParams('/operators', { name, safename, realname, birthplace, age, date_of_birth, season_introduced, health, speed, unit, country_code, roles, side });
|
|
11
|
-
|
|
12
|
-
const response = await axiosInstance.get(url, {
|
|
13
|
-
headers: {
|
|
14
|
-
'api-key': apiKey
|
|
15
|
-
}
|
|
16
|
-
});
|
|
17
|
-
|
|
18
|
-
return response.data;
|
|
19
|
-
} catch (error) {
|
|
20
|
-
console.error('Error during the getOperators request:', error.message);
|
|
21
|
-
if (error.response && error.response.status === 401) {
|
|
22
|
-
throw new Error('request error');
|
|
23
|
-
}
|
|
24
|
-
throw error;
|
|
25
|
-
}
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
module.exports = getOperators;
|
|
1
|
+
const axiosInstance = require('../axiosInstance/axiosInstance');
|
|
2
|
+
const buildUrlAndParams = require('./util');
|
|
3
|
+
|
|
4
|
+
async function getOperators(apiKey, { name, safename, realname, birthplace, age, date_of_birth, season_introduced, health, speed, unit, country_code, roles, side } = {}) {
|
|
5
|
+
try {
|
|
6
|
+
if (!apiKey) {
|
|
7
|
+
throw new Error('Missing required parameter: apiKey');
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
const url = buildUrlAndParams('/operators', { name, safename, realname, birthplace, age, date_of_birth, season_introduced, health, speed, unit, country_code, roles, side });
|
|
11
|
+
|
|
12
|
+
const response = await axiosInstance.get(url, {
|
|
13
|
+
headers: {
|
|
14
|
+
'api-key': apiKey
|
|
15
|
+
}
|
|
16
|
+
});
|
|
17
|
+
|
|
18
|
+
return response.data;
|
|
19
|
+
} catch (error) {
|
|
20
|
+
console.error('Error during the getOperators request:', error.message);
|
|
21
|
+
if (error.response && error.response.status === 401) {
|
|
22
|
+
throw new Error('request error');
|
|
23
|
+
}
|
|
24
|
+
throw error;
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
module.exports = getOperators;
|