r6-data.js 2.1.0 → 2.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.
@@ -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
- if (!webhookUrl.includes('discord.com/api/webhooks/')) {
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;
@@ -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;
@@ -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;
@@ -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;
@@ -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;
@@ -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;
@@ -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;