osrs-json-hiscores
Version:
The Old School Runescape API wrapper that does more!
65 lines (64 loc) • 2.79 kB
TypeScript
import { AxiosRequestConfig } from 'axios';
import { Player, Stats, PlayerSkillRow, PlayerActivityRow, GetStatsOptions, HiscoresResponse } from './types';
import { Gamemode, SkillName, ActivityName } from './utils';
/**
* Gets a player's stats from the official OSRS JSON endpoint.
*
* @param rsn Username of the player.
* @param mode Gamemode to fetch ranks for.
* @param config Optional axios request config object.
* @returns Official JSON stats object.
*/
export declare function getOfficialStats(rsn: string, mode?: Gamemode, config?: AxiosRequestConfig): Promise<HiscoresResponse>;
/**
* Screen scrapes the hiscores to get the formatted rsn of a player.
*
* @param rsn Username of the player.
* @param config Optional axios request config object.
* @returns Formatted version of the rsn.
*/
export declare function getRSNFormat(rsn: string, config?: AxiosRequestConfig, mode?: Gamemode): Promise<string>;
/**
* Parses official JSON object of raw stats and returns a stats object.
*
* @param csv Raw JSON from the official OSRS API.
* @returns Parsed stats object.
*/
export declare function parseJsonStats(json: HiscoresResponse): Stats;
/**
* Parses CSV string of raw stats and returns a stats object.
*
* @param csv Raw CSV from the official OSRS API.
* @returns Parsed stats object.
*/
export declare function parseStats(csv: string): Stats;
/**
* Fetches stats from the OSRS API and consolidates the info into a player object.
*
* **Note:** This function will make up to 5 separate network requests.
* As such, it is highly subject to the performance of the official OSRS API.
*
* @param rsn Username of the player.
* @returns Player object.
*/
export declare function getStats(rsn: string, options?: GetStatsOptions): Promise<Player>;
/**
* Fetches stats from the OSRS API and returns them as an object.
*
* @param rsn Username of the player.
* @param mode Gamemode to fetch ranks for.
* @param config Optional axios request config object.
* @returns Stats object.
*/
export declare function getStatsByGamemode(rsn: string, mode?: Gamemode, config?: AxiosRequestConfig): Promise<Stats>;
export declare function getSkillPage(skill: SkillName, mode?: Gamemode, page?: number, config?: AxiosRequestConfig): Promise<PlayerSkillRow[]>;
/**
* Screen scrapes a hiscores page of an activity or boss and returns an array of up to 25 players.
*
* @param activity Name of the activity or boss to fetch hiscores for.
* @param mode Gamemode to fetch ranks for.
* @param page Page number.
* @param config Optional axios request config object.
* @returns Array of `PlayerActivityRow` objects.
*/
export declare function getActivityPage(activity: ActivityName, mode?: Gamemode, page?: number, config?: AxiosRequestConfig): Promise<PlayerActivityRow[]>;