Skip to content

Commit 81d36b2

Browse files
committed
Add TypeScript support and update README
1 parent 2618558 commit 81d36b2

File tree

6 files changed

+1280
-36
lines changed

6 files changed

+1280
-36
lines changed

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
node_modules/
2-
.gitignore
32
test.js
3+
test.ts
4+
dist/
45
.npmignore

README.md

Lines changed: 47 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
## r6-data.js
1+
# r6-data.js — Rainbow Six Siege (R6/R6S) Stats & Metadata API
2+
23
Rainbow Six Siege API wrapper that gives infos about player's stats, maps, operators, ranks, seasons, charms etc. Last updated Y10S3
34

45
<div align="center">
@@ -14,9 +15,6 @@
1415

1516
## Installation
1617

17-
```sh
18-
npm install r6-data.js
19-
```
2018
```sh
2119
npm i r6-data.js
2220
```
@@ -27,6 +25,51 @@ This is the website where you can directly track your stats and also check the a
2725

2826
Visit the official website: **[r6data.eu](https://r6data.eu/)**
2927

28+
## TypeScript Support
29+
30+
r6-data.js now includes full TypeScript support with complete type definitions! You can use it in TypeScript projects with full IntelliSense and type checking.
31+
32+
### TypeScript Import Examples
33+
34+
```typescript
35+
// ES6 import syntax
36+
import * as r6 from 'r6-data.js';
37+
38+
// Or import specific functions
39+
import { getAccountInfo, getPlayerStats, getOperators } from 'r6-data.js';
40+
41+
// Import types for better type safety
42+
import type { AccountInfoParams, PlayerStatsParams, PlatformType } from 'r6-data.js';
43+
44+
// Example usage with types
45+
async function getPlayerData() {
46+
const accountParams: AccountInfoParams = {
47+
nameOnPlatform: 'PlayerName',
48+
platformType: 'uplay' as PlatformType
49+
};
50+
51+
const accountInfo = await r6.getAccountInfo(accountParams);
52+
console.log('Account info:', accountInfo);
53+
}
54+
```
55+
56+
### JavaScript (CommonJS) Import
57+
58+
```javascript
59+
// Traditional require syntax (still supported)
60+
const r6 = require('r6-data.js');
61+
62+
// Example usage
63+
async function getPlayerData() {
64+
const accountInfo = await r6.getAccountInfo({
65+
nameOnPlatform: 'PlayerName',
66+
platformType: 'uplay'
67+
});
68+
69+
console.log('Account info:', accountInfo);
70+
}
71+
```
72+
3073
## Getting Player Account Information
3174

3275
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.

index.d.ts

Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
1+
// TypeScript declarations for r6-data.js (module-style, no ambient wrapper)
2+
3+
// ----- Types -----
4+
export type PlatformType = "uplay" | "psn" | "xbl";
5+
export type PlatformFamily = "pc" | "console";
6+
export type BoardId = "casual" | "event" | "warmup" | "standard" | "ranked";
7+
export type RankVersion = "v1" | "v2" | "v3" | "v4" | "v5" | "v6";
8+
9+
export interface AccountInfoParams {
10+
nameOnPlatform: string;
11+
platformType: PlatformType;
12+
}
13+
export interface PlayerStatsParams extends AccountInfoParams {
14+
platform_families: PlatformFamily;
15+
board_id?: BoardId;
16+
}
17+
export interface SeasonalStatsParams extends AccountInfoParams {}
18+
19+
export interface GetMapsParams {
20+
name?: string; location?: string; releaseDate?: string; playlists?: string; mapReworked?: boolean;
21+
}
22+
export interface GetOperatorsParams {
23+
name?: string; safename?: string; realname?: string; birthplace?: string; age?: number; date_of_birth?: string; season_introduced?: string;
24+
}
25+
export interface GetSeasonsParams {
26+
name?: string; map?: string; operators?: string; weapons?: string;
27+
}
28+
export interface GetAttachmentParams {
29+
name?: string; style?: string; rarity?: string; availability?: string;
30+
}
31+
export interface GetCharmsParams {
32+
name?: string; collection?: string; rarity?: string; availability?: string; bundle?: string; season?: string;
33+
}
34+
export interface GetWeaponsParams { name?: string; }
35+
export interface GetUniversalSkinsParams { name?: string; }
36+
export interface GetRanksParams { version?: RankVersion; min_mmr?: number; max_mmr?: number; }
37+
38+
export interface SearchAllResult {
39+
query: string;
40+
summary: Record<string, number>;
41+
results: {
42+
operators: any[]; weapons: any[]; maps: any[]; seasons: any[]; charms: any[]; attachments: any[];
43+
[k: string]: any;
44+
};
45+
}
46+
export interface GameStats {
47+
steam?: { concurrent?: number; estimate?: number };
48+
crossPlatform?: { totalRegistered?: number; monthlyActive?: number; trendsEstimate?: number; platforms?: { pc?: number; playstation?: number; xbox?: number } };
49+
ubisoft?: { onlineEstimate?: number };
50+
lastUpdated?: string;
51+
[k: string]: any;
52+
}
53+
export interface DiscordWebhookOptions {
54+
playerName: string; title?: string; message?: string; color?: number; avatarUrl?: string;
55+
}
56+
57+
// ----- Functions -----
58+
export function getAccountInfo(params: AccountInfoParams): Promise<any>;
59+
export function getPlayerStats(params: PlayerStatsParams): Promise<any>;
60+
export function getSeasonalStats(params: SeasonalStatsParams): Promise<any>;
61+
export function getServiceStatus(): Promise<any>;
62+
export function getGameStats(): Promise<GameStats>;
63+
export function getMaps(params?: GetMapsParams): Promise<any[]>;
64+
export function getOperators(params?: GetOperatorsParams): Promise<any[]>;
65+
export function getSeasons(params?: GetSeasonsParams): Promise<any[]>;
66+
export function getAttachment(params?: GetAttachmentParams): Promise<any[]>;
67+
export function getCharms(params?: GetCharmsParams): Promise<any[]>;
68+
export function getWeapons(params?: GetWeaponsParams): Promise<any[]>;
69+
export function getUniversalSkins(params?: GetUniversalSkinsParams): Promise<any[]>;
70+
export function getRanks(params?: GetRanksParams): Promise<any[]>;
71+
export function getSearchAll(query: string): Promise<SearchAllResult>;
72+
export function createDiscordR6Webhook(webhookUrl: string, playerData: any, options: DiscordWebhookOptions): Promise<any>;
73+
74+
// ----- Default export -----
75+
declare const r6Data: {
76+
getAccountInfo: typeof getAccountInfo;
77+
getPlayerStats: typeof getPlayerStats;
78+
getSeasonalStats: typeof getSeasonalStats;
79+
getServiceStatus: typeof getServiceStatus;
80+
getGameStats: typeof getGameStats;
81+
getMaps: typeof getMaps;
82+
getOperators: typeof getOperators;
83+
getSeasons: typeof getSeasons;
84+
getAttachment: typeof getAttachment;
85+
getCharms: typeof getCharms;
86+
getWeapons: typeof getWeapons;
87+
getUniversalSkins: typeof getUniversalSkins;
88+
getRanks: typeof getRanks;
89+
getSearchAll: typeof getSearchAll;
90+
createDiscordR6Webhook: typeof createDiscordR6Webhook;
91+
};
92+
export default r6Data;

0 commit comments

Comments
 (0)