UNPKG

@blizzard-api/sc2

Version:

A series of helpers to interact with the Starcraft II Blizzard API

393 lines (380 loc) 12.5 kB
import { Resource } from '@blizzard-api/core'; /** * Returns the player information for the specified account ID. * @param accountId The account ID * @returns The player resource. See {@link Resource}. */ declare function player(accountId: string): Resource<Array<unknown>>; /** * Base interface for Blizzard API responses. */ interface ResponseBase { _links: { self: { href: string; }; }; } type StarcraftRegion = 'cn' | 'eu' | 'kr' | 'tw' | 'us'; interface GrandmasterLeaderboardResponse { ladderTeams: Array<LadderTeam>; } interface SeasonResponse { endDate: string; number: number; seasonId: number; startDate: string; year: number; } interface LadderTeam { joinTimestamp: number; losses: number; mmr: number; points: number; previousRank: number; teamMembers: Array<TeamMember>; wins: number; } interface TeamMember { clanTag?: string; displayName: string; favoriteRace: 'protoss' | 'random' | 'terran' | 'zerg'; id: string; realm: number; region: number; } /** * Returns the grandmaster leaderboard for the specified region. * @param regionId The region ID * @returns The grandmaster leaderboard resource. See {@link GrandmasterLeaderboardResponse}. */ declare function grandmasterLeaderboard(regionId: StarcraftRegion): Resource<GrandmasterLeaderboardResponse>; /** * Returns the season information for the specified region. * @param regionId The region ID * @returns The season resource. See {@link SeasonResponse}. */ declare function season(regionId: StarcraftRegion): Resource<SeasonResponse>; interface LeagueDataResponse extends ResponseBase { key: Key; tier: Array<Tier>; } type StarcraftLeagueId = 'bronze' | 'diamond' | 'gold' | 'grandmaster' | 'master' | 'platinum' | 'silver'; type StarcraftLeagueQueue = 'hots-1v1' | 'hots-2v2' | 'hots-3v3' | 'hots-4v4' | 'lotv-1v1' | 'lotv-2v2' | 'lotv-3v3' | 'lotv-4v4' | 'lotv-archon' | 'wol-1v1' | 'wol-2v2' | 'wol-3v3' | 'wol-4v4'; type StarcraftLeagueTeamType = 'arranged' | 'random'; interface Division { id: number; ladder_id: number; member_count: number; } interface Key { league_id: number; queue_id: number; season_id: number; team_type: number; } interface Tier { division: Array<Division>; id: number; } /** * Returns the league data for the specified season, queue, team type, and league. * @param seasonId The season ID * @param queueId The queue ID * @param teamType The team type * @param leagueId The league ID * @returns The league data resource. See {@link LeagueDataResponse}. */ declare function getLeagueData(seasonId: string, queueId: StarcraftLeagueQueue, teamType: StarcraftLeagueTeamType, leagueId: StarcraftLeagueId): Resource<LeagueDataResponse>; interface LegacyAchievementsResponse { achievements: Array<Achievement$1>; categories: Array<Category$1>; } interface LegacyLaddersResponse { currentSeason: Array<unknown>; previousSeason: Array<unknown>; showcasePlacement: Array<unknown>; } interface LegacyMatchHistoryResponse { matches: Array<Match>; } interface LegacyProfileResponse { achievements: Achievements; campaign: Campaign; career: Career; clanName: string; clanTag: string; displayName: string; id: string; portrait: Icon; profilePath: string; realm: number; rewards: Rewards; season: Season; swarmLevels: SwarmLevels; } interface LegacyRewardsResponse { animations: Array<Animation>; portraits: Array<Animation>; protossDecals: Array<Animation>; skins: Array<Animation>; terranDecals: Array<Animation>; zergDecals: Array<Animation>; } interface Achievement$1 { achievementId: string; categoryId: string; description: string; icon: Icon; points: number; title: string; } interface Achievements { achievements: Array<{ achievementId: string; completionDate: number; }>; points: Points; } interface Animation { achievementId: string; command?: '/dance'; icon: Icon; id: string; name?: string; title: string; } interface Campaign { hots: string; wol: string; } interface Career { careerTotalGames: number; highest1v1Rank: string; highestTeamRank: string; primaryRace: string; protossWins: number; seasonTotalGames: number; terranWins: number; zergWins: number; } interface Category$1 { categoryId: string; children?: Array<Category$1>; featuredAchievementId: string; title: string; } interface Icon { h: number; offset: number; url: string; w: number; x: number; y: number; } interface Match { date: number; decision: 'Left' | 'Loss' | 'Win'; map: string; speed: 'Fast' | 'Faster'; type: '2v2' | '3v3' | 'Co-Op' | 'Custom'; } interface Points { categoryPoints: Record<string, number>; totalPoints: number; } interface Rewards { earned: Array<string>; selected: Array<string>; } interface Season { seasonId: number; seasonNumber: number; seasonYear: number; stats: Array<Stat>; totalGamesThisSeason: number; } interface Stat { games: number; type: string; wins: number; } interface SwarmLevels { level: number; protoss: SwarmLevelsByRace; terran: SwarmLevelsByRace; zerg: SwarmLevelsByRace; } interface SwarmLevelsByRace { currentLevelXP: number; level: number; totalLevelXP: number; } /** * Returns the legacy achievements for the specified region. * @param regionId The region ID for Starcraft. * @returns A resource representing the legacy achievements. See {@link LegacyAchievementsResponse} */ declare function legacyAchievements(regionId: StarcraftRegion): Resource<LegacyAchievementsResponse>; /** * Returns the ladder information for the specified ladder. * @param regionId The region ID for Starcraft. * @param ladderId The ID of the ladder. * @returns A resource representing the ladder. See {@link LadderResponse} */ declare function legacyLadder(regionId: StarcraftRegion, ladderId: number): Resource<unknown>; /** * Returns the ladders for the specified profile. * @param regionId The region ID for Starcraft. * @param realmId 1 or 2 * @param profileId The ID of the profile. * @returns A resource representing the ladders for the given profile. See {@link LegacyLaddersResponse} */ declare function legacyLadders(regionId: StarcraftRegion, realmId: 1 | 2, profileId: number): Resource<LegacyLaddersResponse>; /** * Returns the match history for the specified profile. * @param regionId The region ID for Starcraft. * @param realmId 1 or 2 * @param profileId The ID of the profile. * @returns A resource representing the match history for the given profile. See {@link LegacyMatchHistoryResponse} */ declare function legacyMatchHistory(regionId: StarcraftRegion, realmId: 1 | 2, profileId: number): Resource<LegacyMatchHistoryResponse>; /** * Returns the profile for the specified profile. * @param regionId The region ID for Starcraft. * @param realmId 1 or 2 * @param profileId The ID of the profile. * @returns A resource representing the profile for the given ID. See {@link LegacyProfileResponse} */ declare function legacyProfile(regionId: StarcraftRegion, realmId: 1 | 2, profileId: number): Resource<LegacyProfileResponse>; /** * Returns the rewards for the specified region. * @param regionId The region ID for Starcraft. * @returns A resource representing the rewards for the given region. See {@link LegacyRewardsResponse} */ declare function legacyRewards(regionId: StarcraftRegion): Resource<LegacyRewardsResponse>; interface LadderResponse { allLadderMemberships: Array<unknown>; ladderTeams: Array<unknown>; ranksAndPools: Array<unknown>; } interface LadderSummaryResponse { allLadderMemberships: Array<unknown>; placementMatches: Array<unknown>; showCaseEntries: Array<unknown>; } interface MetadataResponse { avatarUrl: string; name: string; profileId: string; profileUrl: string; realmId: number; regionId: number; } interface StaticProfileResponse { achievements: Array<Achievement>; categories: Array<Category>; criteria: Array<Criterion>; rewards: Array<Reward>; } interface Achievement { categoryId: string; chainAchievementIds: Array<string>; chainRewardSize: number; criteriaIds?: Array<string>; description: string; flags: number; id: string; imageUrl: string; isChained: boolean; points: number; title: string; uiOrderHint: number; } interface Category { childrenCategoryIds: Array<string>; featuredAchievementId: string; id: string; medalTiers?: Array<number>; name: string; parentCategoryId: null | string; points: number; uiOrderHint: number; } interface Criterion { achievementId: string; description: string; evaluationClass: 'Achv' | 'Clnt' | 'S2Gm' | 'Sunk' | 'Trny'; flags: number; id: string; necessaryQuantity: number; uiOrderHint: number; } interface Reward { achievementId?: string; command?: '/dance'; flags: number; id: string; imageUrl: string; isSkin: boolean; name: string; uiOrderHint: number; unlockableType: string; } /** * Returns the ladder information for the specified profile and ladder. * @param regionId The region ID for Starcraft. * @param realmId 1 or 2 * @param profileId The ID of the profile. * @param ladderId The ID of the ladder. * @returns A resource representing the ladder. See {@link LadderResponse} */ declare function ladder(regionId: StarcraftRegion, realmId: 1 | 2, profileId: number, ladderId: number): Resource<LadderResponse>; /** * Returns the ladder summary information for the specified profile. * @param regionId The region ID for Starcraft. * @param realmId 1 or 2 * @param profileId The ID of the profile. * @returns A resource representing the ladder summary. See {@link LadderSummaryResponse} */ declare function ladderSummary(regionId: StarcraftRegion, realmId: 1 | 2, profileId: number): Resource<LadderSummaryResponse>; /** * Returns the metadata information for the specified profile. * @param regionId The region ID for Starcraft. * @param realmId 1 or 2 * @param profileId The ID of the profile. * @returns A resource representing the metadata. See {@link MetadataResponse} */ declare function metadata(regionId: StarcraftRegion, realmId: 1 | 2, profileId: number): Resource<MetadataResponse>; /** * Returns the profile information for the specified profile. * @param regionId The region ID for Starcraft. * @param realmId 1 or 2 * @param profileId The ID of the profile. * @returns A resource representing the profile. See {@link MetadataResponse} */ declare function profile(regionId: StarcraftRegion, realmId: 1 | 2, profileId: number): Resource<MetadataResponse>; /** * * @param regionId The region ID for Starcraft. * @returns A resource representing the static profile. See {@link StaticProfileResponse} */ declare function staticProfile(regionId: StarcraftRegion): Resource<StaticProfileResponse>; declare const sc2: { player: typeof player; grandmasterLeaderboard: typeof grandmasterLeaderboard; season: typeof season; getLeagueData: typeof getLeagueData; legacyAchievements: typeof legacyAchievements; legacyLadder: typeof legacyLadder; legacyLadders: typeof legacyLadders; legacyMatchHistory: typeof legacyMatchHistory; legacyProfile: typeof legacyProfile; legacyRewards: typeof legacyRewards; ladder: typeof ladder; ladderSummary: typeof ladderSummary; metadata: typeof metadata; profile: typeof profile; staticProfile: typeof staticProfile; }; export { type GrandmasterLeaderboardResponse, type LadderResponse, type LadderSummaryResponse, type LeagueDataResponse, type LegacyAchievementsResponse, type LegacyLaddersResponse, type LegacyMatchHistoryResponse, type LegacyProfileResponse, type LegacyRewardsResponse, type MetadataResponse, type SeasonResponse, type StarcraftLeagueId, type StarcraftLeagueQueue, type StarcraftLeagueTeamType, type StaticProfileResponse, sc2 as default, getLeagueData, grandmasterLeaderboard, ladder, ladderSummary, legacyAchievements, legacyLadder, legacyLadders, legacyMatchHistory, legacyProfile, legacyRewards, metadata, player, profile, sc2, season, staticProfile };