r6-data.js 1.8.3 → 2.0.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.
@@ -1,90 +1,98 @@
1
- const axiosInstance = require('../axiosInstance/axiosInstance');
2
- const buildUrlAndParams = require('./util');
3
-
4
- /**
5
- * Get Rainbow Six Siege player stats or account information
6
- * @param {Object} params - Parameters for the request
7
- * @param {string} params.type - Type of request: "accountInfo" or "stats"
8
- * @param {string} params.nameOnPlatform - Player name on the platform
9
- * @param {string} params.platformType - Platform type (uplay, psn, xbl)
10
- * @param {string} [params.platform_families] - Platform families (required for stats type): "pc" or "console"
11
- * @param {string} [params.board_id] - Game mode to filter stats (casual, event, warmup, standard, ranked)
12
- * @returns {Promise<Object>} - Player stats or account information
13
- */
14
- async function getStats({ type, nameOnPlatform, platformType, platform_families, board_id } = {}) {
15
- try {
16
- // Validate required parameters
17
- if (!type || !nameOnPlatform || !platformType) {
18
- throw new Error('Missing required parameters: type, nameOnPlatform, platformType');
19
- }
20
-
21
- // Validate type parameter
22
- if (type !== 'accountInfo' && type !== 'stats') {
23
- throw new Error('Invalid type parameter. Must be "accountInfo" or "stats"');
24
- }
25
-
26
- // If type is stats, platform_families is required
27
- if (type === 'stats' && !platform_families) {
28
- throw new Error('platform_families parameter is required for stats type');
29
- }
30
-
31
- // Validate board_id if provided
32
- if (board_id && !['casual', 'event', 'warmup', 'standard', 'ranked'].includes(board_id)) {
33
- throw new Error('Invalid board_id. Must be one of: casual, event, warmup, standard, ranked');
34
- }
35
-
36
- // Build the URL with parameters
37
- const params = {
38
- type,
39
- nameOnPlatform,
40
- platformType
41
- };
42
-
43
- // Add platform_families for stats type
44
- if (type === 'stats') {
45
- params.platform_families = platform_families;
46
-
47
- // Add board_id if provided
48
- if (board_id) {
49
- params.board_id = board_id;
50
- }
51
- }
52
-
53
- const url = buildUrlAndParams('/stats', params);
54
-
55
- const response = await axiosInstance.get(url);
56
-
57
- if (response.data &&
58
- response.data.platform_families_full_profiles &&
59
- response.data.platform_families_full_profiles.length > 0) {
60
-
61
- // If board_id is specified, filter the response data
62
- if (type === 'stats' && board_id && response.data.platform_families_full_profiles) {
63
- response.data.platform_families_full_profiles.forEach(profile => {
64
- if (profile.board_ids_full_profiles) {
65
- // Filter to only include the specified board_id
66
- profile.board_ids_full_profiles = profile.board_ids_full_profiles.filter(
67
- board => board.board_id === board_id
68
- );
69
- }
70
- });
71
- }
72
-
73
- response.data.platform_families_full_profiles.forEach(profile => {
74
- if (profile.board_ids_full_profiles) {
75
- console.log(JSON.stringify(profile.board_ids_full_profiles, null, 2));
76
- }
77
- });
78
- }
79
-
80
- return response.data;
81
- } catch (error) {
82
- console.error(`Error during the getStats (${type}) request:`, error.message);
83
- if (error.response && error.response.status === 401) {
84
- throw new Error('Authentication error');
85
- }
86
- throw error;
87
- }
88
- }
89
-
90
- module.exports = getStats;
1
+ const axiosInstance = require('../axiosInstance/axiosInstance');
2
+ const buildUrlAndParams = require('./util');
3
+
4
+ /**
5
+ * Get Rainbow Six Siege player stats or account information
6
+ * @param {string} apiKey - Your API Key from r6data.eu
7
+ * @param {Object} params - Parameters for the request
8
+ * @param {string} params.type - Type of request: "accountInfo" or "stats"
9
+ * @param {string} params.nameOnPlatform - Player name on the platform
10
+ * @param {string} params.platformType - Platform type (uplay, psn, xbl)
11
+ * @param {string} [params.platform_families] - Platform families (required for stats type): "pc" or "console"
12
+ * @param {string} [params.board_id] - Game mode to filter stats (casual, event, warmup, standard, ranked)
13
+ * @returns {Promise<Object>} - Player stats or account information
14
+ */
15
+ async function getStats(apiKey, { type, nameOnPlatform, platformType, platform_families, board_id } = {}) {
16
+ try {
17
+ // Validate required parameters
18
+ if (!apiKey) {
19
+ throw new Error('Missing required parameter: apiKey');
20
+ }
21
+ if (!type || !nameOnPlatform || !platformType) {
22
+ throw new Error('Missing required parameters: type, nameOnPlatform, platformType');
23
+ }
24
+
25
+ // Validate type parameter
26
+ if (type !== 'accountInfo' && type !== 'stats') {
27
+ throw new Error('Invalid type parameter. Must be "accountInfo" or "stats"');
28
+ }
29
+
30
+ // If type is stats, platform_families is required
31
+ if (type === 'stats' && !platform_families) {
32
+ throw new Error('platform_families parameter is required for stats type');
33
+ }
34
+
35
+ // Validate board_id if provided
36
+ if (board_id && !['casual', 'event', 'warmup', 'standard', 'ranked'].includes(board_id)) {
37
+ throw new Error('Invalid board_id. Must be one of: casual, event, warmup, standard, ranked');
38
+ }
39
+
40
+ // Build the URL with parameters
41
+ const params = {
42
+ type,
43
+ nameOnPlatform,
44
+ platformType
45
+ };
46
+
47
+ // Add platform_families for stats type
48
+ if (type === 'stats') {
49
+ params.platform_families = platform_families;
50
+
51
+ // Add board_id if provided
52
+ if (board_id) {
53
+ params.board_id = board_id;
54
+ }
55
+ }
56
+
57
+ const url = buildUrlAndParams('/stats', params);
58
+
59
+ const response = await axiosInstance.get(url, {
60
+ headers: {
61
+ 'api-key': apiKey
62
+ }
63
+ });
64
+
65
+ if (response.data &&
66
+ response.data.platform_families_full_profiles &&
67
+ response.data.platform_families_full_profiles.length > 0) {
68
+
69
+ // If board_id is specified, filter the response data
70
+ if (type === 'stats' && board_id && response.data.platform_families_full_profiles) {
71
+ response.data.platform_families_full_profiles.forEach(profile => {
72
+ if (profile.board_ids_full_profiles) {
73
+ // Filter to only include the specified board_id
74
+ profile.board_ids_full_profiles = profile.board_ids_full_profiles.filter(
75
+ board => board.board_id === board_id
76
+ );
77
+ }
78
+ });
79
+ }
80
+
81
+ response.data.platform_families_full_profiles.forEach(profile => {
82
+ if (profile.board_ids_full_profiles) {
83
+ console.log(JSON.stringify(profile.board_ids_full_profiles, null, 2));
84
+ }
85
+ });
86
+ }
87
+
88
+ return response.data;
89
+ } catch (error) {
90
+ console.error(`Error during the getStats (${type}) request:`, error.message);
91
+ if (error.response && error.response.status === 401) {
92
+ throw new Error('Authentication error');
93
+ }
94
+ throw error;
95
+ }
96
+ }
97
+
98
+ module.exports = getStats;
@@ -1,21 +1,28 @@
1
- const axiosInstance = require('../axiosInstance/axiosInstance');
2
- const buildUrlAndParams = require('./util');
3
-
4
- async function getUniversalSkins({ name } = {}) {
5
- try {
6
-
7
- const url = buildUrlAndParams('/universalSkins', { name });
8
-
9
- const response = await axiosInstance.get(url);
10
-
11
- return response.data;
12
- } catch (error) {
13
- console.error('Error during the getUniversalSkins request:', error.message);
14
- if (error.response && error.response.status === 401) {
15
- throw new Error('request error');
16
- }
17
- throw error;
18
- }
19
- }
20
-
21
- module.exports = getUniversalSkins;
1
+ const axiosInstance = require('../axiosInstance/axiosInstance');
2
+ const buildUrlAndParams = require('./util');
3
+
4
+ async function getUniversalSkins(apiKey, { name } = {}) {
5
+ try {
6
+ if (!apiKey) {
7
+ throw new Error('Missing required parameter: apiKey');
8
+ }
9
+
10
+ const url = buildUrlAndParams('/universalSkins', { name });
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 getUniversalSkins 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 = getUniversalSkins;
@@ -1,21 +1,28 @@
1
- const axiosInstance = require('../axiosInstance/axiosInstance');
2
- const buildUrlAndParams = require('./util');
3
-
4
- async function getWeapons({ name } = {}) {
5
- try {
6
-
7
- const url = buildUrlAndParams('/weapons', { name });
8
-
9
- const response = await axiosInstance.get(url);
10
-
11
- return response.data;
12
- } catch (error) {
13
- console.error('Error during the getWeapons request:', error.message);
14
- if (error.response && error.response.status === 401) {
15
- throw new Error('request error');
16
- }
17
- throw error;
18
- }
19
- }
20
-
21
- module.exports = getWeapons;
1
+ const axiosInstance = require('../axiosInstance/axiosInstance');
2
+ const buildUrlAndParams = require('./util');
3
+
4
+ async function getWeapons(apiKey, { name } = {}) {
5
+ try {
6
+ if (!apiKey) {
7
+ throw new Error('Missing required parameter: apiKey');
8
+ }
9
+
10
+ const url = buildUrlAndParams('/weapons', { name });
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 getWeapons 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 = getWeapons;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "r6-data.js",
3
- "version": "1.8.3",
3
+ "version": "2.0.1",
4
4
  "description": "R6 (Rainbow Six Siege) API wrapper for player stats, operators, maps, ranks, seasons, charms, skins and game datas. Last Updated Y10S4",
5
5
  "main": "index.js",
6
6
  "module": "index.js",
@@ -1,42 +1,42 @@
1
- // Function declarations for r6-data.js
2
-
3
- import {
4
- AccountInfoParams,
5
- GetIsBannedParams,
6
- PlayerStatsParams,
7
- SeasonalStatsParams,
8
- PlayerComparisonsParams,
9
- GetMapsParams,
10
- GetOperatorsParams,
11
- GetSeasonsParams,
12
- GetAttachmentParams,
13
- GetCharmsParams,
14
- GetWeaponsParams,
15
- GetUniversalSkinsParams,
16
- GetRanksParams,
17
- DiscordWebhookOptions
18
- } from './params-interfaces';
19
-
20
- import {
21
- SearchAllResult,
22
- GameStats,
23
- PlayerComparisonsResult
24
- } from './result-interfaces';
25
-
26
- export function getAccountInfo(params: AccountInfoParams): Promise<any>;
27
- export function getIsBanned(params: GetIsBannedParams): Promise<any>;
28
- export function getPlayerStats(params: PlayerStatsParams): Promise<any>;
29
- export function getSeasonalStats(params: SeasonalStatsParams): Promise<any>;
30
- export function getServiceStatus(): Promise<any>;
31
- export function getGameStats(): Promise<GameStats>;
32
- export function getMaps(params?: GetMapsParams): Promise<any[]>;
33
- export function getOperators(params?: GetOperatorsParams): Promise<any[]>;
34
- export function getSeasons(params?: GetSeasonsParams): Promise<any[]>;
35
- export function getAttachment(params?: GetAttachmentParams): Promise<any[]>;
36
- export function getCharms(params?: GetCharmsParams): Promise<any[]>;
37
- export function getWeapons(params?: GetWeaponsParams): Promise<any[]>;
38
- export function getUniversalSkins(params?: GetUniversalSkinsParams): Promise<any[]>;
39
- export function getRanks(params?: GetRanksParams): Promise<any[]>;
40
- export function getSearchAll(query: string): Promise<SearchAllResult>;
41
- export function createDiscordR6Webhook(webhookUrl: string, playerData: any, options: DiscordWebhookOptions): Promise<any>;
42
- export function getPlayerComparisons(params: PlayerComparisonsParams): Promise<PlayerComparisonsResult>;
1
+ // Function declarations for r6-data.js
2
+
3
+ import {
4
+ AccountInfoParams,
5
+ GetIsBannedParams,
6
+ PlayerStatsParams,
7
+ SeasonalStatsParams,
8
+ PlayerComparisonsParams,
9
+ GetMapsParams,
10
+ GetOperatorsParams,
11
+ GetSeasonsParams,
12
+ GetAttachmentParams,
13
+ GetCharmsParams,
14
+ GetWeaponsParams,
15
+ GetUniversalSkinsParams,
16
+ GetRanksParams,
17
+ DiscordWebhookOptions
18
+ } from './params-interfaces';
19
+
20
+ import {
21
+ SearchAllResult,
22
+ GameStats,
23
+ PlayerComparisonsResult
24
+ } from './result-interfaces';
25
+
26
+ export function getAccountInfo(apiKey: string, params: AccountInfoParams): Promise<any>;
27
+ export function getIsBanned(apiKey: string, params: GetIsBannedParams): Promise<any>;
28
+ export function getPlayerStats(apiKey: string, params: PlayerStatsParams): Promise<any>;
29
+ export function getSeasonalStats(apiKey: string, params: SeasonalStatsParams): Promise<any>;
30
+ export function getServiceStatus(apiKey: string): Promise<any>;
31
+ export function getGameStats(apiKey: string): Promise<GameStats>;
32
+ export function getMaps(apiKey: string, params?: GetMapsParams): Promise<any[]>;
33
+ export function getOperators(apiKey: string, params?: GetOperatorsParams): Promise<any[]>;
34
+ export function getSeasons(apiKey: string, params?: GetSeasonsParams): Promise<any[]>;
35
+ export function getAttachment(apiKey: string, params?: GetAttachmentParams): Promise<any[]>;
36
+ export function getCharms(apiKey: string, params?: GetCharmsParams): Promise<any[]>;
37
+ export function getWeapons(apiKey: string, params?: GetWeaponsParams): Promise<any[]>;
38
+ export function getUniversalSkins(apiKey: string, params?: GetUniversalSkinsParams): Promise<any[]>;
39
+ export function getRanks(apiKey: string, params?: GetRanksParams): Promise<any[]>;
40
+ export function getSearchAll(apiKey: string, query: string): Promise<SearchAllResult>;
41
+ export function createDiscordR6Webhook(webhookUrl: string, playerData: any, options: DiscordWebhookOptions): Promise<any>;
42
+ export function getPlayerComparisons(apiKey: string, params: PlayerComparisonsParams): Promise<PlayerComparisonsResult>;
@@ -1,90 +1,90 @@
1
- // Parameter interfaces for r6-data.js
2
-
3
- import { PlatformType, PlatformFamily, BoardId, RankVersion } from './base-types';
4
-
5
- export interface AccountInfoParams {
6
- nameOnPlatform: string;
7
- platformType: PlatformType;
8
- }
9
-
10
- export interface GetIsBannedParams extends AccountInfoParams {}
11
-
12
- export interface PlayerStatsParams extends AccountInfoParams {
13
- platform_families: PlatformFamily;
14
- board_id?: BoardId;
15
- }
16
-
17
- export interface SeasonalStatsParams extends AccountInfoParams {}
18
-
19
- export interface PlayerComparisonsParams {
20
- players: Array<{
21
- nameOnPlatform: string;
22
- platformType: PlatformType;
23
- }>;
24
- platform_families: PlatformFamily;
25
- board_id?: BoardId;
26
- compareFields?: string[];
27
- }
28
-
29
- export interface GetMapsParams {
30
- name?: string;
31
- location?: string;
32
- releaseDate?: string;
33
- playlists?: string;
34
- mapReworked?: boolean;
35
- }
36
-
37
- export interface GetOperatorsParams {
38
- name?: string;
39
- safename?: string;
40
- realname?: string;
41
- birthplace?: string;
42
- age?: number;
43
- date_of_birth?: string;
44
- season_introduced?: string;
45
- }
46
-
47
- export interface GetSeasonsParams {
48
- name?: string;
49
- map?: string;
50
- operators?: string;
51
- weapons?: string;
52
- }
53
-
54
- export interface GetAttachmentParams {
55
- name?: string;
56
- style?: string;
57
- rarity?: string;
58
- availability?: string;
59
- }
60
-
61
- export interface GetCharmsParams {
62
- name?: string;
63
- collection?: string;
64
- rarity?: string;
65
- availability?: string;
66
- bundle?: string;
67
- season?: string;
68
- }
69
-
70
- export interface GetWeaponsParams {
71
- name?: string;
72
- }
73
-
74
- export interface GetUniversalSkinsParams {
75
- name?: string;
76
- }
77
-
78
- export interface GetRanksParams {
79
- version?: RankVersion;
80
- min_mmr?: number;
81
- max_mmr?: number;
82
- }
83
-
84
- export interface DiscordWebhookOptions {
85
- playerName: string;
86
- title?: string;
87
- message?: string;
88
- color?: number;
89
- avatarUrl?: string;
1
+ // Parameter interfaces for r6-data.js
2
+
3
+ import { PlatformType, PlatformFamily, BoardId, RankVersion } from './base-types';
4
+
5
+ export interface AccountInfoParams {
6
+ nameOnPlatform: string;
7
+ platformType: PlatformType;
8
+ }
9
+
10
+ export interface GetIsBannedParams extends AccountInfoParams {}
11
+
12
+ export interface PlayerStatsParams extends AccountInfoParams {
13
+ platform_families: PlatformFamily;
14
+ board_id?: BoardId;
15
+ }
16
+
17
+ export interface SeasonalStatsParams extends AccountInfoParams {}
18
+
19
+ export interface PlayerComparisonsParams {
20
+ players: Array<{
21
+ nameOnPlatform: string;
22
+ platformType: PlatformType;
23
+ }>;
24
+ platform_families: PlatformFamily;
25
+ board_id?: BoardId;
26
+ compareFields?: string[];
27
+ }
28
+
29
+ export interface GetMapsParams {
30
+ name?: string;
31
+ location?: string;
32
+ releaseDate?: string;
33
+ playlists?: string;
34
+ mapReworked?: boolean;
35
+ }
36
+
37
+ export interface GetOperatorsParams {
38
+ name?: string;
39
+ safename?: string;
40
+ realname?: string;
41
+ birthplace?: string;
42
+ age?: number;
43
+ date_of_birth?: string;
44
+ season_introduced?: string;
45
+ }
46
+
47
+ export interface GetSeasonsParams {
48
+ name?: string;
49
+ map?: string;
50
+ operators?: string;
51
+ weapons?: string;
52
+ }
53
+
54
+ export interface GetAttachmentParams {
55
+ name?: string;
56
+ style?: string;
57
+ rarity?: string;
58
+ availability?: string;
59
+ }
60
+
61
+ export interface GetCharmsParams {
62
+ name?: string;
63
+ collection?: string;
64
+ rarity?: string;
65
+ availability?: string;
66
+ bundle?: string;
67
+ season?: string;
68
+ }
69
+
70
+ export interface GetWeaponsParams {
71
+ name?: string;
72
+ }
73
+
74
+ export interface GetUniversalSkinsParams {
75
+ name?: string;
76
+ }
77
+
78
+ export interface GetRanksParams {
79
+ version?: RankVersion;
80
+ min_mmr?: number;
81
+ max_mmr?: number;
82
+ }
83
+
84
+ export interface DiscordWebhookOptions {
85
+ playerName: string;
86
+ title?: string;
87
+ message?: string;
88
+ color?: number;
89
+ avatarUrl?: string;
90
90
  }