UNPKG

rocket-league-stats

Version:
390 lines (386 loc) 12.6 kB
type TrackerPlatformInfo = { platformSlug: string; platformUserId: string; platformUserHandle: string; platformUserIdentifier: string; avatarUrl: string | null; additionalParameters: unknown | null; }; type TrackerUserInfo = { userId: unknown; isPremium: boolean; isVerified: boolean; isInfluencer: boolean; isPartner: boolean; countryCode: string | null; customAvatarUrl: string | null; customHeroUrl: string | null; customAvatarFrame: unknown; customAvatarFrameInfo: unknown; premiumDuration: unknown; socialAccounts: unknown[]; pageviews: number; xpTier: unknown; isSuspicious: boolean | null; }; type TrackerMetadata = { lastUpdated?: { value: string; displayValue: string; }; playerId: number; currentSeason: number; }; type SegmentStatsBase = { rank: number | unknown | null; percentile: unknown | null; displayName: string; displayCategory: string; category: string; description: unknown | null; value: number; displayValue: string; displayType: string; }; type SegmentStatsTier = SegmentStatsBase & { metadata: { iconUrl: string; name: Ranks; }; }; type SegmentStatsDivision = SegmentStatsBase & { metadata: { deltaDown: number | null | undefined; deltaUp: number | null | undefined; name: Divisions; }; }; type SegmentStatsWinStreak = SegmentStatsBase & { metadata: { type: 'win' | 'loss'; }; }; type SegmentStatsRating = SegmentStatsBase & { metadata: { iconUrl: string; tierName: Ranks; }; }; type SegmentStatsPeakRating = SegmentStatsBase & { metadata: { iconUrl: string; tierName: Ranks; }; value: number | null; }; type SegmentOverviewStats = { wins: SegmentStatsBase; goals: SegmentStatsBase; mVPs: SegmentStatsBase; saves: SegmentStatsBase; assists: SegmentStatsBase; shots: SegmentStatsBase; goalShotRatio: SegmentStatsBase; score: SegmentStatsBase; seasonRewardLevel: SegmentStatsBase; seasonRewardWins: SegmentStatsBase; tRNRating: SegmentStatsBase; }; type SegmentPlaylistStats = { tier: SegmentStatsTier; division: SegmentStatsDivision; matchesPlayed: SegmentStatsBase; winStreak: SegmentStatsWinStreak; rating: SegmentStatsRating; peakRating: SegmentStatsPeakRating; }; type Segments = { attributes?: { playlistId: number; season: number; key?: string | null; }; expiryDate: string; } & (SegmentsOverview | SegmentsPlaylist); type SegmentsOverview = { type: 'overview'; stats: SegmentOverviewStats; metadata: { name: 'LifeTime'; }; }; type SegmentsPlaylist = { type: 'playlist'; stats: SegmentPlaylistStats; metadata: { name: TPlaylists; }; }; type TrackerResponse = { data: { platformInfo: TrackerPlatformInfo; userInfo: TrackerUserInfo; metadata: TrackerMetadata; segments: Segments[]; availableSegments: unknown[]; expiryDate: string; }; errors?: { message: string; }[]; }; type Platform = 'steam' | 'epic' | 'psn' | 'xbl'; type TPlaylists = 'Ranked Duel 1v1' | 'Ranked Doubles 2v2' | 'Ranked Standard 3v3' | 'Hoops' | 'Rumble' | 'Dropshot' | 'Snowday' | 'Tournament Matches'; type Ranks = 'Unranked' | 'Bronze I' | 'Bronze II' | 'Bronze III' | 'Silver I' | 'Silver II' | 'Silver III' | 'Gold I' | 'Gold II' | 'Gold III' | 'Platinum I' | 'Platinum II' | 'Platinum III' | 'Diamond I' | 'Diamond II' | 'Diamond III' | 'Champion I' | 'Champion II' | 'Champion III' | 'Grand Champion I' | 'Grand Champion II' | 'Grand Champion III' | 'Supersonic Legend'; type Divisions = 'Division I' | 'Division II' | 'Division III' | 'Division IV'; type InitializeOptions = { expiresAfter?: number; }; type GenericOptions = { fresh?: boolean; }; type OverviewStats = { wins: number; goals: number; mVPs: number; saves: number; assists: number; shots: number; goalShotRatio: number; score: number; seasonRewardLevel: number; seasonRewardWins: number; tRNRating: number; }; type PlaylistStats = { rank: Ranks; tier: number; division: number; deltaUp: number | null; deltaDown: number | null; matchesPlayed: number; winStreak: number; rating: number; peakRating: number | null; }; type GamemodesStats = { [k in TPlaylists]: PlaylistStats; }; type AllStats = { overview: OverviewStats; gamemodes: GamemodesStats; }; type Userinfo = { platform: TrackerPlatformInfo['platformSlug']; uuid: TrackerPlatformInfo['platformUserId']; name: TrackerPlatformInfo['platformUserHandle']; userid: TrackerPlatformInfo['platformUserIdentifier']; avatar: TrackerPlatformInfo['avatarUrl']; }; declare const PLATFORM: { readonly Steam: "steam"; readonly Epic: "epic"; readonly Playstation: "psn"; readonly Xbox: "xbl"; }; /** * Get the roman numeral of the division number * @param num - The number to convert to roman numeral * @returns The roman numeral of the number * @example * getRomanNumeral(1) // 'I' * getRomanNumeral(2) // 'II' */ declare const getRomanNumeral: (num: number) => string; /** * Rocket League Stats API * @param platform - The platform of the user * @param username - The username of the user * @param options - The options for the API * @example * const api = new API(PLATFORM.EPIC, 'lil McNugget') * const data = await api.fetchUser() * console.log(data) * @throws {Error} - If the user is not found * @throws {Error} - If the user data is not found */ declare class API { private platform; private username; private raw; private expiresAfter; private lastFetch; constructor(platform: Platform, username: string, options?: InitializeOptions); /** * Fetch the user data from the tracker network * @returns The user data from the tracker network * @example * const api = new API(PLATFORM.EPIC, 'lil McNugget') * const data = await api.fetchUser() * console.log(data) * @throws {Error} - If the user is not found * @throws {Error} - If the user data is not found * */ fetchUser(): Promise<TrackerResponse>; /** * Get the overview stats of the user * @returns The overview stats of the user * @example * const api = new API(PLATFORM.EPIC, 'lil McNugget') * const data = await api.overview() * console.log(data) * @throws {Error} - If the overview data is not found * @throws {Error} - If the user data is not found */ overview(options?: GenericOptions): Promise<OverviewStats>; /** * Return the stats of the user formatted * @private * @param stats - The stats of the user * @returns The formatted stats of the user */ private returnStats; /** * Get the rank data of the user * @private * @param playlistName - The name of the playlist * @param options - The options for the API * @returns The rank data of the user */ private getRankData; /** * Get the 1v1 rank data of the user * @param options - The options for the API * @returns The 1v1 rank data of the user * @example * const api = new API(PLATFORM.EPIC, 'lil McNugget') * const data = await api.get1v1() * console.log(data) * @throws {Error} - If the 1v1 data is not found * @throws {Error} - If the user data is not found */ get1v1(options?: GenericOptions): Promise<PlaylistStats>; /** * Get the 2v2 rank data of the user * @param options - The options for the API * @returns The 2v2 rank data of the user * @example * const api = new API(PLATFORM.EPIC, 'lil McNugget') * const data = await api.get2v2() * console.log(data) * @throws {Error} - If the 2v2 data is not found * @throws {Error} - If the user data is not found */ get2v2(options?: GenericOptions): Promise<PlaylistStats>; /** * Get the 3v3 rank data of the user * @param options - The options for the API * @returns The 3v3 rank data of the user * @example * const api = new API(PLATFORM.EPIC, 'lil McNugget') * const data = await api.get3v3() * console.log(data) * @throws {Error} - If the 3v3 data is not found * @throws {Error} - If the user data is not found */ get3v3(options?: GenericOptions): Promise<PlaylistStats>; /** * Get the Hoops rank data of the user * @param options - The options for the API * @returns The Hoops rank data of the user * @example * const api = new API(PLATFORM.EPIC, 'lil McNugget') * const data = await api.getHoops() * console.log(data) * @throws {Error} - If the Hoops data is not found * @throws {Error} - If the user data is not found */ getHoops(options?: GenericOptions): Promise<PlaylistStats>; /** * Get the Rumble rank data of the user * @param options - The options for the API * @returns The Rumble rank data of the user * @example * const api = new API(PLATFORM.EPIC, 'lil McNugget') * const data = await api.getRumble() * console.log(data) * @throws {Error} - If the Rumble data is not found * @throws {Error} - If the user data is not found */ getRumble(options?: GenericOptions): Promise<PlaylistStats>; /** * Get the Dropshot rank data of the user * @param options - The options for the API * @returns The Dropshot rank data of the user * @example * const api = new API(PLATFORM.EPIC, 'lil McNugget') * const data = await api.getDropshot() * console.log(data) * @throws {Error} - If the Dropshot data is not found * @throws {Error} - If the user data is not found */ getDropshot(options?: GenericOptions): Promise<PlaylistStats>; /** * Get the Snowday rank data of the user * @param options - The options for the API * @returns The Snowday rank data of the user * @example * const api = new API(PLATFORM.EPIC, 'lil McNugget') * const data = await api.getSnowday() * console.log(data) * @throws {Error} - If the Snowday data is not found * @throws {Error} - If the user data is not found */ getSnowday(options?: GenericOptions): Promise<PlaylistStats>; /** * Get the Tournament rank data of the user * @param options - The options for the API * @returns The Tournament rank data of the user * @example * const api = new API(PLATFORM.EPIC, 'lil McNugget') * const data = await api.getTournament() * console.log(data) * @throws {Error} - If the Tournament data is not found * @throws {Error} - If the user data is not found */ getTournament(options?: GenericOptions): Promise<PlaylistStats>; /** * Get the user data * @description Get all ranks and overview data for the user * @param options - The options for the API * @returns The user data * @example * const api = new API(PLATFORM.EPIC, 'lil McNugget') * const data = await api.getData() * console.log(data) * @throws {Error} - If the user data is not found * @throws {Error} - If the overview data is not found */ getData(options?: GenericOptions): Promise<AllStats>; /** * Get the userinfo of the user * @param options - The options for the API * @returns The userinfo of the user * @example * const api = new API(PLATFORM.EPIC, 'lil McNugget') * const data = await api.getUserinfo() * console.log(data) * @throws {Error} - If the user data is not found * @throws {Error} - If the userinfo data is not found */ getUserinfo(options?: GenericOptions): Promise<Userinfo>; /** * Get the raw data of the user * @param options - The options for the API * @returns The raw data of the user * @example * const api = new API(PLATFORM.EPIC, 'lil McNugget') * const data = await api.getRaw() * console.log(data) * @throws {Error} - If the user data is not found * @throws {Error} - If the raw data is not found */ getRaw(options?: GenericOptions): Promise<TrackerResponse>; } export { API, type AllStats, type GenericOptions, type InitializeOptions, type OverviewStats, PLATFORM, type Platform, type PlaylistStats, type TPlaylists, type Userinfo, getRomanNumeral };