UNPKG

albion-sdk

Version:
751 lines (746 loc) 25.4 kB
declare const AMERICAS_API_URL = "https://gameinfo.albiononline.com/api/gameinfo"; declare const ASIA_API_URL = "https://gameinfo-sgp.albiononline.com/api/gameinfo"; declare const EUROPE_API_URL = "https://gameinfo-ams.albiononline.com/api/gameinfo"; declare const AMERICAS_STATUS_URL = "https://serverstatus.albiononline.com"; declare const ASIA_STATUS_URL = "https://serverstatus-sgp.albiononline.com"; declare const EUROPE_STATUS_URL = "https://serverstatus-ams.albiononline.com"; declare const RENDER_API_URL = "https://render.albiononline.com/v1"; type Region = "Americas" | "Asia" | "Europe"; type ServerAPIURL = typeof AMERICAS_API_URL | typeof ASIA_API_URL | typeof EUROPE_API_URL; type ServerStatusURL = typeof AMERICAS_STATUS_URL | typeof ASIA_STATUS_URL | typeof EUROPE_STATUS_URL; type AlbionAPIFetchOptions = { signal?: AbortSignal; timeoutMs?: number; }; type StandardTimeRange = "week" | "month" | "lastWeek" | "lastMonth"; type SortOption = "totalfame" | "recent"; type ServerStatus = "online" | "offline" | "starting"; type ServerStatusResponse = { status: ServerStatus; message: string; }; type PaginationParams = { limit?: number; offset?: number; }; type TopAndSoloKillsParams = { range?: StandardTimeRange; } & PaginationParams; type BattleParams = { range?: StandardTimeRange; sort?: SortOption; } & PaginationParams; type RenderItemParams = { enchantment?: Range<0, 4>; quality?: Range<0, 5>; size?: Range<1, 217>; locale?: string; }; type RenderSpellParams = { size?: Range<1, 217>; locale?: string; }; type RenderDestinyBoardParams = { locale?: string; }; type RenderGuildLogoParams = { symbol: `GUILDSYMBOL_${string}`; symbolColor: Range<0, 14>; schema: `SCHEMA_${string}`; primarySchemaColor: Range<0, 14>; secondarySchemaColor: Range<0, 14>; type: `ACTIVE_{string}` | `PASSIVE_{string}`; size?: number; symbolScale?: number; symbolOffsetY?: number; gems?: number; }; type SearchResponse = { guilds: Array<SearchGuild>; players: Array<SearchPlayer>; }; type SearchGuild = { Id: string; Name: string; AllianceId: string; AllianceName: string; KillFame: number | null; DeathFame: number; }; type SearchPlayer = { Id: string; Name: string; GuildId: string; GuildName: string | null; AllianceId: string; AllianceName: string; Avatar: string; AvatarRing: string; KillFame: number; DeathFame: number; FameRatio: number; totalKills: number | null; gvgKills: number | null; gvgWon: number | null; }; type Player = { AverageItemPower: number; Equipment: Equipment; Inventory: Array<Item | null>; Name: string; Id: string; GuildName: string; GuildId: string; AllianceName: string; AllianceId: string; AllianceTag: string; Avatar: string; AvatarRing: string; DeathFame: number; KillFame: number; FameRatio: number; LifetimeStatistics: LifetimeStatistics; }; type Equipment = { MainHand: Item | null; OffHand: Item | null; Head: Item | null; Armor: Item | null; Shoes: Item | null; Bag: Item | null; Cape: Item | null; Mount: Item | null; Potion: Item | null; Food: Item | null; }; type LegendarySoul = { id: string; subtype: number; era: number; name: null; lastEquipped: string; attunedPlayer: string; attunedPlayerName: string; attunement: number; attunementSpentSinceReset: number; attunementSpent: number; quality: number; craftedBy: string; traits: Trait[]; PvPFameGained: number; }; type Trait = { roll: number; pendingRolls: Array<unknown>; pendingTraits: Array<unknown>; value: number; trait: string; minvalue: number; maxvalue: number; }; type Item = { Type: string; Count: number; Quality: number; ActiveSpells: Array<never>; PassiveSpells: Array<never>; LegendarySoul: LegendarySoul | null; }; type LifetimeStatistics = { PvE: PVE; Gathering: Gathering; Crafting: Crafting; CrystalLeague: number; FishingFame: number; FarmingFame: number; Timestamp: string | null; }; type Crafting = { Total: number; Royal: number; Outlands: number; Avalon: number; }; type Gathering = { Fiber: Crafting; Hide: Crafting; Ore: Crafting; Rock: Crafting; Wood: Crafting; All: Crafting; }; type PVE = { Total: number; Royal: number; Outlands: number; Avalon: number; Hellgate: number; CorruptedDungeon: number; Mists: number; }; type EventParticipant = Player & { DamageDone: number; SupportHealingDone: number; }; type Event = { groupMemberCount: number; numberOfParticipants: number; EventId: number; TimeStamp: string; Version: number; Killer: Player; Victim: Player; TotalVictimKillFame: number; Location: null; Participants: Array<EventParticipant>; GroupMembers: Array<Player>; GvGMatch: null; BattleId: number; KillArea: string; Category: null; Type: string; }; type BaseGuildInfo = { Id: string; Name: string; FounderId: string; FounderName: string; Founded: string; AllianceTag: string; AllianceId: string; AllianceName: null; Logo: null; killFame: number; DeathFame: number; AttacksWon: null; DefensesWon: null; }; type GuildInfo = { MemberCount: number; } & BaseGuildInfo; type DetailedGuildInfo = { guild: BaseGuildInfo; overall: GuildOverallStats; topPlayers: Array<SearchPlayer>; basic: BasicGuildInfo; }; type BasicGuildInfo = { founder: string; memberCount: number; founded: string; }; type GuildOverallStats = { kills: number; gvgKills: number; gvg: GvGStats; fame: number; gvgDeaths: number; deaths: number; ratio: string; }; type GvGStats = { defense_lost: number; attacks_won: number; defense_won: number; attacks_lost: number; }; type Battle = { id: number; startTime: string; endTime: string; timeout: string; totalFame: number; totalKills: number; clusterName: null; players: Record<string, BattlePlayer>; guilds: Record<string, BattleGuild>; alliances: Record<string, BattleAlliance>; battle_TIMEOUT: number; }; type BattleAlliance = { name: string; kills: number; deaths: number; killFame: number; id: string; }; type BattleGuild = { name: string; kills: number; deaths: number; killFame: number; alliance: string; allianceId: string; id: string; }; type BattlePlayer = { name: string; kills: number; deaths: number; killFame: number; guildName: string; guildId: string; allianceName: string; allianceId: string; id: string; }; type Alliance = { AllianceId: string; AllianceName: string; AllianceTag: string; FounderId: string; FounderName: string; Founded: string; Guilds: Array<GuildIdentifier>; NumPlayers: number; }; type GuildIdentifier = { Id: string; Name: string; }; type WeaponCategory = { id: string; name: string; }; type ItemCategoryTree = { head: HeadTree; mainhand: MainhandTree; potion: PotionTree; armor: ArmorTree; bag: BagTree; mount: MountTree; shoes: ShoesTree; cape: CapeTree; food: FoodTree; offhand: OffhandTree; }; type ArmorTree = { rockgatherer_armor: string; oregatherer_armor: string; leather_armor: string; fibergatherer_armor: string; hidegatherer_armor: string; plate_armor: string; cloth_armor: string; fishgatherer_armor: string; woodgatherer_armor: string; }; type BagTree = { bag: string; }; type CapeTree = { rockgatherer_backpack: string; oregatherer_backpack: string; fishgatherer_backpack: string; woodgatherer_backpack: string; hidegatherer_backpack: string; cape: string; fibergatherer_backpack: string; }; type FoodTree = { fish: string; cooked: string; vanity: string; }; type HeadTree = { fibergatherer_helmet: string; woodgatherer_helmet: string; leather_helmet: string; plate_helmet: string; hidegatherer_helmet: string; rockgatherer_helmet: string; cloth_helmet: string; oregatherer_helmet: string; fishgatherer_helmet: string; }; type MainhandTree = { firestaff: string; dagger: string; hammer: string; crossbow: string; mace: string; cursestaff: string; bow: string; arcanestaff: string; axe: string; sword: string; spear: string; froststaff: string; naturestaff: string; knuckles: string; quarterstaff: string; holystaff: string; }; type MountTree = { mule: string; giantstag: string; rare_mount: string; swampdragon: string; ridinghorse: string; direbear: string; battle_mount: string; armoredhorse: string; ox: string; direwolf: string; cougar: string; direboar: string; }; type OffhandTree = { shield: string; horn: string; book: string; totem: string; torch: string; orb: string; }; type PotionTree = { potion: string; fishingbait: string; vanity: string; }; type ShoesTree = { unique_shoes: string; fibergatherer_shoes: string; rockgatherer_shoes: string; hidegatherer_shoes: string; plate_shoes: string; cloth_shoes: string; fishgatherer_shoes: string; woodgatherer_shoes: string; leather_shoes: string; oregatherer_shoes: string; }; type GuildMatch = { MatchId: string; MatchType: string; StartTime: string; Status: number; TerritoryChangedOwner: null; Winner: number; Attacker: GuildMatchParticipant; Defender: GuildMatchParticipant; AttackerTickets: number; DefenderTickets: number; AttackerTerritory: null; DefenderTerritory: GuildMatchTerritory; AttackerResults: Record<string, MatchContender>; DefenderResults: Record<string, MatchContender>; AttackerTimeline: Array<MatchTimeline>; DefenderTimeline: Array<MatchTimeline>; AttackerContenders: Array<MatchContender>; DefenderContenders: Array<MatchContender>; }; type CrystalLeagueMatch = { matchType: string; category: string; startTime: string; winner: number; team1Guild: null; team1Tickets: number; team1Territory: null; team1Results: Record<string, MatchContender>; team1Timeline: Array<MatchTimeline>; team1LeaderId: string; team2Guild: null; team2Tickets: number; team2Territory: null; team2Results: Record<string, MatchContender>; team2Timeline: Array<MatchTimeline>; team2LeaderId: string; crystalLeagueLevel: number; ttl: string; MatchId: string; }; type GuildMatchParticipant = { Id: string; Name: string; Alliance: GuildMatchAlliance | null; }; type GuildMatchAlliance = { AllianceId: string; AllianceName: null; AllianceTag: null; }; type MatchContender = { PlayerId: string | null; Name: string; Team: MatchTeam; IsMercenary: boolean | null; Kills: number; Deaths: number; Healing: number | null; Fame: number; }; type MatchTeam = "ATTACKER" | "DEFENDER"; type MatchTimeline = { EventType: string | null; TimeStamp: string; Tickets: number | null; }; type GuildMatchTerritory = { Id: string; Owner: GuildMatchParticipant; Type: string; Name: string; ClusterId: string; ClusterName: string; DefensePoints: null; DefenderBonus: null; }; type Enumerate<N extends number, Acc extends number[] = []> = Acc["length"] extends N ? Acc[number] : Enumerate<N, [...Acc, Acc["length"]]>; type Range<F extends number, T extends number> = Exclude<Enumerate<T>, Enumerate<F>> | T; declare class AlbionAPIError extends Error { readonly statusCode?: number; readonly statusText?: string; readonly url?: string; readonly responseBody?: string; readonly timestamp: Date; constructor(message: string, options?: { statusCode?: number; statusText?: string; url?: string; responseBody?: string; }); } declare class AlbionSDK { #private; constructor(region?: Region); get americas(): AlbionSDK; get asia(): AlbionSDK; get europe(): AlbionSDK; /** * Fetch the current status of the target Albion Online server. * * @param {AlbionAPIFetchOptions} options - the options you wish to use for the request */ getServerStatus(options?: AlbionAPIFetchOptions): Promise<ServerStatusResponse>; /** * Fetch details about guilds and players based on an exact starting match of the specified search term. * * @param {string} searchTerm - The term to search for, between 1 and a yet-to-be-defined maximum length. * @param {AlbionAPIFetchOptions} options - the options you wish to use for the request */ search(searchTerm: string, options?: AlbionAPIFetchOptions): Promise<SearchResponse>; /** * Fetch basic information about a specific player * * @param {string} id - the players id you wish to fetch details about * @param {AlbionAPIFetchOptions} options - the options you wish to use for the request */ getPlayerInfo(id: string, options?: AlbionAPIFetchOptions): Promise<Player>; /** * Fetch the latest 10 kills of a specific player * * @param {string} id - the players id you wish to fetch kills for * @param {AlbionAPIFetchOptions} options - the options you wish to use for the request */ getPlayerLatestKills(id: string, options?: AlbionAPIFetchOptions): Promise<Event[]>; /** * Fetch the latest 10 deaths of a specific player * * @param {string} id - the players id you wish to fetch deaths for * @param {AlbionAPIFetchOptions} options - the options you wish to use for the request */ getPlayerLatestDeaths(id: string, options?: AlbionAPIFetchOptions): Promise<Event[]>; /** * Fetch the top kills of a specific player based on kill fame * * @param {string} id - the players id you wish to fetch kills for * @param {TopAndSoloKillsParams} params - the params you wish to use for the request * @param {AlbionAPIFetchOptions} options - the options you wish to use for the request */ getPlayerTopKills(id: string, params?: TopAndSoloKillsParams, options?: AlbionAPIFetchOptions): Promise<Event[]>; /** * Fetch the top solo kills of a specific player based on kill fame * * @param {string} id - the players id you wish to fetch kills for * @param {TopAndSoloKillsParams} params - the params you wish to use for the request * @param {AlbionAPIFetchOptions} options - the options you wish to use for the request */ getPlayerTopSoloKills(id: string, params?: TopAndSoloKillsParams, options?: AlbionAPIFetchOptions): Promise<Event[]>; /** * Fetch basic information about a specific guild * * @param {string} id - the guilds id you wish to fetch details about * @param {AlbionAPIFetchOptions} options - the options you wish to use for the request */ getGuildInfo(id: string, options?: AlbionAPIFetchOptions): Promise<GuildInfo>; /** * Fetch detailed information about a specific guild * * @param {string} id - the guilds id you wish to fetch details about * @param {AlbionAPIFetchOptions} options - the options you wish to use for the request */ getGuildDetailedInfo(id: string, options?: AlbionAPIFetchOptions): Promise<DetailedGuildInfo>; /** * Fetch guild member information for a specific guild * * @param {string} id - the guilds id you wish to fetch details about * @param {AlbionAPIFetchOptions} options - the options you wish to use for the request */ getGuildMembers(id: string, options?: AlbionAPIFetchOptions): Promise<Player[]>; /** * Fetch GvG statistics for a specific guild * * @param {string} id - the guilds id you wish to fetch details about * @param {AlbionAPIFetchOptions} options - the options you wish to use for the request */ getGuildGvGStats(id: string, options?: AlbionAPIFetchOptions): Promise<GvGStats>; /** * Fetch PvP events between the two specified guilds * * @param {string} firstGuildId - the first guild id you wish to fetch details about * @param {string} secondGuildId - the second guild id you wish to fetch details about * @param {AlbionAPIFetchOptions} options - the options you wish to use for the request */ getGuildFued(firstGuildId: string, secondGuildId: string, options?: AlbionAPIFetchOptions): Promise<Event[]>; /** * Fetch the latest PvP events for a specific guild * * @param {string} id - the guilds id you wish to fetch details about * @param {PaginationParams} params - the params you wish to use for the request * @param {AlbionAPIFetchOptions} options - the options you wish to use for the request */ getGuildRecentEvents(id: string, params?: PaginationParams, options?: AlbionAPIFetchOptions): Promise<Event[]>; /** * Fetch the latest battles for a specific guild * * @param {string} id - the guilds id you wish to fetch details about * @param {BattleParams} params - the params you wish to use for the request * @param {AlbionAPIFetchOptions} options - the options you wish to use for the request */ getGuildRecentBattles(id: string, params?: BattleParams, options?: AlbionAPIFetchOptions): Promise<Battle[]>; /** * Fetch the top kills of a specific guild based on kill fame * * @param {string} id - the guilds id you wish to fetch kills for * @param {TopAndSoloKillsParams} params - the params you wish to use for the request * @param {AlbionAPIFetchOptions} options - the options you wish to use for the request */ getGuildTopKills(id: string, params?: TopAndSoloKillsParams, options?: AlbionAPIFetchOptions): Promise<Event[]>; /** * Fetch the latest GvG matches for a specific guild * * @param {string} id - the guilds id you wish to fetch details about * @param {PaginationParams} params - the params you wish to use for the request * @param {AlbionAPIFetchOptions} options - the options you wish to use for the request */ getGuildRecentMatches(id: string, params?: PaginationParams, options?: AlbionAPIFetchOptions): Promise<GuildMatch[]>; /** * Fetch details about a specific GvG match * * @param {string} id - the match id you wish to fetch details about * @param {AlbionAPIFetchOptions} options - the options you wish to use for the request */ getGuildMatchInfo(id: string, options?: AlbionAPIFetchOptions): Promise<GuildMatch>; /** * Fetch information about a specific alliance * * @param {string} id - the alliance id you wish to fetch details about * @param {AlbionAPIFetchOptions} options - the options you wish to use for the request */ getAllianceInfo(id: string, options?: AlbionAPIFetchOptions): Promise<Alliance>; /** * Fetch all latest battles * * @param {BattleParams} params - the params you wish to use for the request * @param {AlbionAPIFetchOptions} options - the options you wish to use for the request */ getRecentBattles(params?: BattleParams, options?: AlbionAPIFetchOptions): Promise<Battle[]>; /** * Fetch information about a specific battle * * @param {string} id - the battle id you wish to fetch details about * @param {AlbionAPIFetchOptions} options - the options you wish to use for the request */ getBattleInfo(id: string, options?: AlbionAPIFetchOptions): Promise<Battle>; /** * Fetch events related to a specific battle * * @param {string} id - the battle id you wish to fetch details about * @param {PaginationParams} params - the params you wish to use for the request * @param {AlbionAPIFetchOptions} options - the options you wish to use for the request */ getBattleEvents(id: string, params: Required<PaginationParams>, options?: AlbionAPIFetchOptions): Promise<Event[]>; /** * Fetch all latest PvP events * * @param {PaginationParams} params - the params you wish to use for the request * @param {AlbionAPIFetchOptions} options - the options you wish to use for the request */ getRecentEvents(params?: PaginationParams, options?: AlbionAPIFetchOptions): Promise<Event[]>; /** * Fetch the latest top kills based on kill fame * * @param {TopAndSoloKillsParams} params - the params you wish to use for the request * @param {AlbionAPIFetchOptions} options - the options you wish to use for the request */ getRecentTopEvents(params?: TopAndSoloKillsParams, options?: AlbionAPIFetchOptions): Promise<Event[]>; /** * Fetch information about a specific event * * @param {string} id - the event id you wish to fetch details about * @param {AlbionAPIFetchOptions} options - the options you wish to use for the request */ getEventInfo(id: string, options?: AlbionAPIFetchOptions): Promise<Event>; /** * Fetch recent 5v5 Crystal League Matches * * @param {PaginationParams} params - the params you wish to use for the request * @param {AlbionAPIFetchOptions} options - the options you wish to use for the request */ getRecentCrystalLeagueMatches(params?: PaginationParams, options?: AlbionAPIFetchOptions): Promise<CrystalLeagueMatch[]>; /** * Fetch recent 20v20 Crystal League Matches * * @param {PaginationParams} params - the params you wish to use for the request * @param {AlbionAPIFetchOptions} options - the options you wish to use for the request */ getRecentCrystalLeagueCityMatches(params?: PaginationParams, options?: AlbionAPIFetchOptions): Promise<CrystalLeagueMatch[]>; /** * Fetch all weapon categories * * @param {AlbionAPIFetchOptions} options - the options you wish to use for the request */ getWeaponCategories(options?: AlbionAPIFetchOptions): Promise<WeaponCategory[]>; /** * Fetch the item category tree * * @param {AlbionAPIFetchOptions} options - the options you wish to use for the request */ getItemCategoryTree(options?: AlbionAPIFetchOptions): Promise<ItemCategoryTree>; } /** * Generate an item icon url for the Albion Online Render API * * @param {string} item - the item identifier or localized name * @param {RenderItemParams} params - the params you wish to use for the request */ declare function itemIconUrl(item: string, params?: RenderItemParams): string; /** * Generate a spell icon url for the Albion Online Render API * * @param {string} spell - the spell identifier or localized name * @param {RenderSpellParams} params - the params you wish to use for the request */ declare function spellIconUrl(spell: string, params?: RenderSpellParams): string; /** * Generate a wardrobe icon url for the Albion Online Render API * * @param {string} item - the item identifier or localized name */ declare function wardrobeIconUrl(item: string): string; /** * Generate a destiny board icon url for the Albion Online Render API * * @param {string} node - the destiny board node identifier * @param {RenderDestinyBoardParams} params - the params you wish to use for the request */ declare function destinyBoardIconUrl(node: string, params?: RenderDestinyBoardParams): string; /** * Generate a guild logo url for the Albion Online Render API * * @param {RenderGuildLogoParams} params - the params you wish to use for the request */ declare function guildLogoUrl(params: RenderGuildLogoParams): string; export { AMERICAS_API_URL, AMERICAS_STATUS_URL, ASIA_API_URL, ASIA_STATUS_URL, AlbionAPIError, type AlbionAPIFetchOptions, AlbionSDK, type Alliance, type ArmorTree, type BagTree, type BaseGuildInfo, type BasicGuildInfo, type Battle, type BattleAlliance, type BattleGuild, type BattleParams, type BattlePlayer, type CapeTree, type Crafting, type CrystalLeagueMatch, type DetailedGuildInfo, EUROPE_API_URL, EUROPE_STATUS_URL, type Enumerate, type Equipment, type Event, type EventParticipant, type FoodTree, type Gathering, type GuildIdentifier, type GuildInfo, type GuildMatch, type GuildMatchAlliance, type GuildMatchParticipant, type GuildMatchTerritory, type GuildOverallStats, type GvGStats, type HeadTree, type Item, type ItemCategoryTree, type LegendarySoul, type LifetimeStatistics, type MainhandTree, type MatchContender, type MatchTeam, type MatchTimeline, type MountTree, type OffhandTree, type PVE, type PaginationParams, type Player, type PotionTree, RENDER_API_URL, type Range, type Region, type RenderDestinyBoardParams, type RenderGuildLogoParams, type RenderItemParams, type RenderSpellParams, type SearchGuild, type SearchPlayer, type SearchResponse, type ServerAPIURL, type ServerStatus, type ServerStatusResponse, type ServerStatusURL, type ShoesTree, type SortOption, type StandardTimeRange, type TopAndSoloKillsParams, type Trait, type WeaponCategory, destinyBoardIconUrl, guildLogoUrl, itemIconUrl, spellIconUrl, wardrobeIconUrl };