The Old School Runescape API wrapper that does more!
npm install osrs-json-hiscores



The Old School RuneScape API wrapper that does more!
The official hiscores API for Old School RuneScape (OSRS) can return CSV or a simple JSON array.
This wrapper converts the hiscores data into a more usable JSON object and provides extra information about the given player. By comparing player info it infers the player's game mode, as well as any previous modes (de-ultimated, de-ironed and/or died as a hardcore ironman).
Additional functions are provided that screen-scrape the OSRS leaderboards and return a list of players as json. Also simple utility functions are provided to fetch the raw responses from Jagex's APIs, if desired.
osrs-json-hiscores has TypeScript support, with full definitions for all functions and custom data types.
---
Jagex does not provide Access-Control-Allow-Origin headers in their responses. This means that CORS will block all browser requests to their hiscores API. In order to get around this, osrs-json-hiscores needs to be installed on the server side and exposed to the front end via a simple API. Here is an example of this in use: codesandbox.io/s/osrs-json-hiscores-demo
TLDR: You cannot use this library directly in your client side app e.g. React or Vue, you must set up a server which uses this lib internally and have your client fetch data from your server.
---
With npm:
```
$ npm install osrs-json-hiscores
With Yarn:
``
$ yarn add osrs-json-hiscores
Install the package and then import it into your project:
`typescript`
import { getStatsByGamemode, getSkillPage } from 'osrs-json-hiscores';
Once you import it you can call the functions asynchronously:
`typescript`
const stats = await getStatsByGamemode('Lynx Titan');
const topPage = await getSkillPage('overall');
getStats will return a full player object with gamemode. getStatsByGameMode will return a stats object and accepts a gamemode parameter:
| Game mode | Param |
| ---------------- | :----------: |
| Regular | main |ironman
| Ironman | |hardcore
| Hardcore Ironman | |ultimate
| Ultimate Ironman | |deadman
| Deadman Mode | |tournament
| Tournament | |seasonal
| Leagues | |
getSkillPage and getActivityPage require a skill / activity and optionally a gamemode and page:
`typescript`
getSkillPage('attack', 'main', 1)
.then((res) => console.log(res))
.catch((err) => console.error(err));
Activities consist of all levels of clue scrolls as well as minigames and bosses:
| Type | Param |
| -------- | :-------------: |
| All | allClues |beginnerClues
| Beginner | |easyClues
| Easy | |mediumClues
| Medium | |hardClues
| Hard | |eliteClues
| Elite | |masterClues
| Master | |
| Minigame | Param |
| ------------------------------- | :-----------------: |
| Bounty Hunter (Legacy - Rogue) | rogueBH |hunterBH
| Bounty Hunter (Legacy - Hunter) | |rogueBHV2
| Bounty Hunter (Rogue) | |hunterBHV2
| Bounty Hunter (Hunter) | |lastManStanding
| LMS - Rank | |pvpArena
| PvP Arena - Rank | |soulWarsZeal
| Soul Wars Zeal | |riftsClosed
| Rifts closed | |colosseumGlory
| Colosseum Glory | |collectionsLogged
| Collections Logged | |
| Activity | Param |
| -------------- | :-------------: |
| League Points | leaguePoints |deadmanPoints
| Deadman Points | |
| Boss Name | Param |
| --------------------------------- | :----------------------------: |
| Abyssal Sire | abyssalSire |alchemicalHydra
| Alchemical Hydra | |amoxliatl
| Amoxliatl | |araxxor
| Araxxor | |artio
| Artio | |barrows
| Barrows Chests | |bryophyta
| Bryophyta | |callisto
| Callisto | |calvarion
| Calvar'ion | |cerberus
| Cerberus | |chambersOfXeric
| Chambers Of Xeric | |chambersOfXericChallengeMode
| Chambers Of Xeric: Challenge Mode | |chaosElemental
| Chaos Elemental | |chaosFanatic
| Chaos Fanatic | |commanderZilyana
| Commander Zilyana | |corporealBeast
| Corporeal Beast | |crazyArchaeologist
| Crazy Archaeologist | |dagannothPrime
| Dagannoth Prime | |dagannothRex
| Dagannoth Rex | |dagannothSupreme
| Dagannoth Supreme | |derangedArchaeologist
| Deranged Archaeologist | |doomOfMokhaiotl
| Doom of Mokhaiotl | |dukeSucellus
| Duke Sucellus | |generalGraardor
| General Graardor | |giantMole
| Giant Mole | |grotesqueGuardians
| Grotesque Guardians | |hespori
| Hespori | |kalphiteQueen
| Kalphite Queen | |kingBlackDragon
| King Black Dragon | |kraken
| Kraken | |kreeArra
| Kreearra | |krilTsutsaroth
| K'ril Tsutsaroth | |lunarChests
| Lunar Chests | |mimic
| Mimic | |nex
| Nex | |nightmare
| Nightmare | |phosanisNightmare
| Phosani's Nightmare | |obor
| Obor | |phantomMuspah
| Phantom Muspah | |sarachnis
| Sarachnis | |scorpia
| Scorpia | |scurrius
| Scurrius | |skotizo
| Skotizo | |solHeredit
| Sol Heredit | |spindel
| Spindel | |tempoross
| Tempoross | |gauntlet
| The Gauntlet | |corruptedGauntlet
| The Corrupted Gauntlet | |hueycoatl
| The Hueycoatl | |leviathan
| The Leviathan | |royalTitans
| The Royal Titans | |whisperer
| The Whisperer | |theatreOfBlood
| Theatre Of Blood | |theatreOfBloodHardMode
| Theatre Of Blood: Hard Mode | |thermonuclearSmokeDevil
| Thermonuclear Smoke Devil | |tombsOfAmascut
| Tombs of Amascut | |tombsOfAmascutExpertMode
| Tombs of Amascut: Expert Mode | |tzKalZuk
| TzKal-Zuk | |tzTokJad
| TzTok-Jad | |vardorvis
| Vardorvis | |venenatis
| Venenatis | |vetion
| Vetion | |vorkath
| Vorkath | |wintertodt
| Wintertodt | |yama
| Yama | |zalcano
| Zalcano | |zulrah
| Zulrah | |
getStats returns a player object that looks like this:
`typescript`
{
name: 'Lynx Titan',
mode: 'main',
dead: false,
deulted: false,
deironed: false,
main: {
skills: {
overall: {rank: 1, level: 2277, xp: 4600000000},
attack: {},
defence: {},
// ...
},
clues: {},
leaguePoints: {},
bountyHunter: {},
lastManStanding: {},
pvpArena: {},
soulWarsZeal: {},
riftsClosed: {},
colosseumGlory: {},
collectionsLogged: {},
bosses: {}
}
}
getSkillPage returns and array of 25 players (This represents a page on the hiscores):
`typescript`
[
{ rank: 1, name: 'Lynx Titan', level: 2277, xp: 4600000000, dead: false },
{},
{}
// ...
];
Get the properly formatted name of any skill, boss, clue or other activity:
`typescript``
// kril === "K'ril Tsutsaroth"
const kril = FORMATTED_BOSS_NAMES['krilTsutsaroth'];