2.18.0 • Published 1 month ago

osrs-json-hiscores v2.18.0

Weekly downloads
41
License
ISC
Repository
github
Last release
1 month ago

OSRS .json Hiscores

npm downloads types build

The Old School RuneScape API wrapper that does more!

What it does

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.


⚠ Disclaimer ⚠

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.


Installation

With npm:

$ npm install osrs-json-hiscores

With Yarn:

$ yarn add osrs-json-hiscores

How to use

Install the package and then import it into your project:

import { getStatsByGamemode, getSkillPage } from 'osrs-json-hiscores';

Once you import it you can call the functions asynchronously:

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 modeParam
Regularmain
Ironmanironman
Hardcore Ironmanhardcore
Ultimate Ironmanultimate
Deadman Modedeadman
Tournamenttournament
Leaguesseasonal

getSkillPage and getActivityPage require a skill / activity and optionally a gamemode and page:

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:

Clue Scrolls

TypeParam
AllallClues
BeginnerbeginnerClues
EasyeasyClues
MediummediumClues
HardhardClues
EliteeliteClues
MastermasterClues

Minigames

MinigameParam
Bounty Hunter (Legacy - Rogue)rogueBH
Bounty Hunter (Legacy - Hunter)hunterBH
Bounty Hunter (Rogue)rogueBHV2
Bounty Hunter (Hunter)hunterBHV2
LMS - RanklastManStanding
PvP Arena - RankpvpArena
Soul Wars ZealsoulWarsZeal
Rifts closedriftsClosed
Colosseum GlorycolosseumGlory

Points

ActivityParam
League PointsleaguePoints
Deadman PointsdeadmanPoints

Bosses

Boss NameParam
Abyssal SireabyssalSire
Alchemical HydraalchemicalHydra
Artioartio
Barrows Chestsbarrows
Bryophytabryophyta
Callistocallisto
Calvar'ioncalvarion
Cerberuscerberus
Chambers Of XericchambersOfXeric
Chambers Of Xeric: Challenge ModechambersOfXericChallengeMode
Chaos ElementalchaosElemental
Chaos FanaticchaosFanatic
Commander ZilyanacommanderZilyana
Corporeal BeastcorporealBeast
Crazy ArchaeologistcrazyArchaeologist
Dagannoth PrimedagannothPrime
Dagannoth RexdagannothRex
Dagannoth SupremedagannothSupreme
Deranged ArchaeologistderangedArchaeologist
Duke SucellusdukeSucellus
General GraardorgeneralGraardor
Giant MolegiantMole
Grotesque GuardiansgrotesqueGuardians
Hesporihespori
Kalphite QueenkalphiteQueen
King Black DragonkingBlackDragon
Krakenkraken
KreearrakreeArra
K'ril TsutsarothkrilTsutsaroth
Lunar ChestslunarChests
Mimicmimic
Nexnex
Nightmarenightmare
Phosani's NightmarephosanisNightmare
Oborobor
Phantom MuspahphantomMuspah
Sarachnissarachnis
Scorpiascorpia
Scurriusscurrius
Skotizoskotizo
Sol HereditsolHeredit
Spindelspindel
Temporosstempoross
The Gauntletgauntlet
The Corrupted GauntletcorruptedGauntlet
The Leviathanleviathan
The Whispererwhisperer
Theatre Of BloodtheatreOfBlood
Theatre Of Blood: Hard ModetheatreOfBloodHardMode
Thermonuclear Smoke DevilthermonuclearSmokeDevil
Tombs of AmascuttombsOfAmascut
Tombs of Amascut: Expert ModetombsOfAmascutExpertMode
TzKal-ZuktzKalZuk
TzTok-JadtzTokJad
Vardorvisvardorvis
Venenatisvenenatis
Vetionvetion
Vorkathvorkath
Wintertodtwintertodt
Zalcanozalcano
Zulrahzulrah

What you'll get

getStats returns a player object that looks like this:

{
  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: {},
    bosses: {}
  }
}

getSkillPage returns and array of 25 players (This represents a page on the hiscores):

[
  { rank: 1, name: 'Lynx Titan', level: 2277, xp: 4600000000, dead: false },
  {},
  {}
  // ...
];

Helpful Extras

Get the properly formatted name of any skill, boss, clue or other activity:

// kril === "K'ril Tsutsaroth"
const kril = FORMATTED_BOSS_NAMES['krilTsutsaroth'];
2.18.0

1 month ago

2.17.0

3 months ago

2.16.3

4 months ago

2.16.1

5 months ago

2.16.2

5 months ago

2.15.0

9 months ago

2.14.1

11 months ago

2.16.0

9 months ago

2.14.2

10 months ago

2.14.0

11 months ago

2.13.0

1 year ago

2.13.1

1 year ago

2.11.0

1 year ago

2.12.0

1 year ago

2.12.1

1 year ago

2.10.1

1 year ago

2.10.2

1 year ago

2.10.0

2 years ago

2.9.0

2 years ago

2.8.0

2 years ago

2.7.0

2 years ago

2.6.0

3 years ago

2.5.0

3 years ago

2.5.2

3 years ago

2.5.1

3 years ago

2.4.1

3 years ago

2.4.2

3 years ago

2.4.0

3 years ago

2.3.2

3 years ago

2.3.1

3 years ago

2.3.0

3 years ago

2.2.0

4 years ago

2.1.0

4 years ago

2.0.2

4 years ago

2.0.1

4 years ago

2.0.0

4 years ago

1.2.2

5 years ago

1.2.1

5 years ago

1.2.0

5 years ago

1.1.3

5 years ago

1.1.2

5 years ago

1.1.1

6 years ago

1.1.0

6 years ago

1.0.9

6 years ago

1.0.8

6 years ago

1.0.7

6 years ago

1.0.6

6 years ago

1.0.5

6 years ago

1.0.4

6 years ago

1.0.3

6 years ago

1.0.2

6 years ago

1.0.1

6 years ago

1.0.0

6 years ago