osrs-json-hiscores 2.16.3 → 2.18.0
Sign up to get free protection for your applications and to get access to all the features.
- package/README.md +21 -29
- package/lib/hiscores.js +4 -1
- package/lib/types.d.ts +3 -2
- package/lib/utils/constants.d.ts +1 -0
- package/lib/utils/constants.js +10 -2
- package/package.json +1 -1
package/README.md
CHANGED
@@ -5,22 +5,24 @@
|
|
5
5
|
[![types](https://img.shields.io/npm/types/osrs-json-hiscores.svg?style=flat-square)](https://github.com/maxswa/osrs-json-hiscores/blob/master/src/types.ts)
|
6
6
|
[![build](https://img.shields.io/github/actions/workflow/status/maxswa/osrs-json-hiscores/main.yml?style=flat-square&branch=main)](https://github.com/maxswa/osrs-json-hiscores/actions/workflows/main.yml?query=branch%3Amain)
|
7
7
|
|
8
|
-
**The Old School
|
8
|
+
**The Old School RuneScape API wrapper that does more!**
|
9
9
|
|
10
10
|
## What it does
|
11
11
|
|
12
|
-
The official hiscores API for Old School
|
13
|
-
This wrapper converts
|
12
|
+
The official hiscores API for Old School RuneScape (OSRS) can return CSV or a simple JSON array.
|
13
|
+
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).
|
14
14
|
|
15
|
-
Additional functions are provided that screen-scrape the OSRS leaderboards and return a list of players as json.
|
15
|
+
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.
|
16
16
|
|
17
17
|
`osrs-json-hiscores` has TypeScript support, with full definitions for all functions and custom data types.
|
18
18
|
|
19
19
|
---
|
20
20
|
|
21
|
-
### Disclaimer
|
21
|
+
### ⚠ Disclaimer ⚠
|
22
22
|
|
23
|
-
Jagex does not provide `Access-Control-Allow-Origin` headers in their responses. This means that [CORS](https://developer.mozilla.org/en-US/docs/Web/HTTP/CORS) will block all browser requests to their hiscores API. In order to get around this, osrs-json-hiscores
|
23
|
+
Jagex does not provide `Access-Control-Allow-Origin` headers in their responses. This means that [CORS](https://developer.mozilla.org/en-US/docs/Web/HTTP/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](https://codesandbox.io/s/osrs-json-hiscores-demo-qz656)
|
24
|
+
|
25
|
+
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.
|
24
26
|
|
25
27
|
---
|
26
28
|
|
@@ -42,27 +44,14 @@ $ yarn add osrs-json-hiscores
|
|
42
44
|
|
43
45
|
Install the package and then import it into your project:
|
44
46
|
|
45
|
-
```
|
46
|
-
|
47
|
+
```typescript
|
48
|
+
import { getStatsByGamemode, getSkillPage } from 'osrs-json-hiscores';
|
47
49
|
```
|
48
50
|
|
49
51
|
Once you import it you can call the functions asynchronously:
|
50
52
|
|
51
|
-
```
|
52
|
-
|
53
|
-
.getStats('Lynx Titan')
|
54
|
-
.then((res) => console.log(res))
|
55
|
-
.catch((err) => console.error(err));
|
56
|
-
```
|
57
|
-
|
58
|
-
If you are using TypeScript or transpiling your JS you can use ES6 syntax:
|
59
|
-
|
60
|
-
```javascript
|
61
|
-
import hiscores, { getSkillPage } from 'osrs-json-hiscores';
|
62
|
-
|
63
|
-
// ...
|
64
|
-
|
65
|
-
const stats = await hiscores.getStats('Lynx Titan');
|
53
|
+
```typescript
|
54
|
+
const stats = await getStatsByGamemode('Lynx Titan');
|
66
55
|
const topPage = await getSkillPage('overall');
|
67
56
|
```
|
68
57
|
|
@@ -81,9 +70,8 @@ const topPage = await getSkillPage('overall');
|
|
81
70
|
|
82
71
|
`getSkillPage` and `getActivityPage` require a skill / activity and optionally a gamemode and page:
|
83
72
|
|
84
|
-
```
|
85
|
-
|
86
|
-
.getSkillPage('attack', 'main', 1)
|
73
|
+
```typescript
|
74
|
+
getSkillPage('attack', 'main', 1)
|
87
75
|
.then((res) => console.log(res))
|
88
76
|
.catch((err) => console.error(err));
|
89
77
|
```
|
@@ -114,6 +102,7 @@ Activities consist of all levels of clue scrolls as well as minigames and bosses
|
|
114
102
|
| PvP Arena - Rank | `pvpArena` |
|
115
103
|
| Soul Wars Zeal | `soulWarsZeal` |
|
116
104
|
| Rifts closed | `riftsClosed` |
|
105
|
+
| Colosseum Glory | `colosseumGlory` |
|
117
106
|
|
118
107
|
### Points
|
119
108
|
|
@@ -155,6 +144,7 @@ Activities consist of all levels of clue scrolls as well as minigames and bosses
|
|
155
144
|
| Kraken | `kraken` |
|
156
145
|
| Kreearra | `kreeArra` |
|
157
146
|
| K'ril Tsutsaroth | `krilTsutsaroth` |
|
147
|
+
| Lunar Chests | `lunarChests` |
|
158
148
|
| Mimic | `mimic` |
|
159
149
|
| Nex | `nex` |
|
160
150
|
| Nightmare | `nightmare` |
|
@@ -163,7 +153,9 @@ Activities consist of all levels of clue scrolls as well as minigames and bosses
|
|
163
153
|
| Phantom Muspah | `phantomMuspah` |
|
164
154
|
| Sarachnis | `sarachnis` |
|
165
155
|
| Scorpia | `scorpia` |
|
156
|
+
| Scurrius | `scurrius` |
|
166
157
|
| Skotizo | `skotizo` |
|
158
|
+
| Sol Heredit | `solHeredit` |
|
167
159
|
| Spindel | `spindel` |
|
168
160
|
| Tempoross | `tempoross` |
|
169
161
|
| The Gauntlet | `gauntlet` |
|
@@ -189,7 +181,7 @@ Activities consist of all levels of clue scrolls as well as minigames and bosses
|
|
189
181
|
|
190
182
|
`getStats` returns a player object that looks like this:
|
191
183
|
|
192
|
-
```
|
184
|
+
```typescript
|
193
185
|
{
|
194
186
|
name: 'Lynx Titan',
|
195
187
|
mode: 'main',
|
@@ -217,7 +209,7 @@ Activities consist of all levels of clue scrolls as well as minigames and bosses
|
|
217
209
|
|
218
210
|
`getSkillPage` returns and array of 25 players (This represents a page on the hiscores):
|
219
211
|
|
220
|
-
```
|
212
|
+
```typescript
|
221
213
|
[
|
222
214
|
{ rank: 1, name: 'Lynx Titan', level: 2277, xp: 4600000000, dead: false },
|
223
215
|
{},
|
@@ -230,7 +222,7 @@ Activities consist of all levels of clue scrolls as well as minigames and bosses
|
|
230
222
|
|
231
223
|
Get the properly formatted name of any skill, boss, clue or other activity:
|
232
224
|
|
233
|
-
```
|
225
|
+
```typescript
|
234
226
|
// kril === "K'ril Tsutsaroth"
|
235
227
|
const kril = FORMATTED_BOSS_NAMES['krilTsutsaroth'];
|
236
228
|
```
|
package/lib/hiscores.js
CHANGED
@@ -175,6 +175,7 @@ function parseJsonStats(json) {
|
|
175
175
|
var pvpArena = getActivity(utils_1.FORMATTED_PVP_ARENA);
|
176
176
|
var soulWarsZeal = getActivity(utils_1.FORMATTED_SOUL_WARS);
|
177
177
|
var riftsClosed = getActivity(utils_1.FORMATTED_RIFTS_CLOSED);
|
178
|
+
var colosseumGlory = getActivity(utils_1.FORMATTED_COLOSSEUM_GLORY);
|
178
179
|
var stats = {
|
179
180
|
skills: skills,
|
180
181
|
leaguePoints: leaguePoints,
|
@@ -184,6 +185,7 @@ function parseJsonStats(json) {
|
|
184
185
|
pvpArena: pvpArena,
|
185
186
|
soulWarsZeal: soulWarsZeal,
|
186
187
|
riftsClosed: riftsClosed,
|
188
|
+
colosseumGlory: colosseumGlory,
|
187
189
|
clues: clues,
|
188
190
|
bosses: bosses
|
189
191
|
};
|
@@ -228,7 +230,7 @@ function parseStats(csv) {
|
|
228
230
|
var _a = activityObjects.splice(0, 2), leaguePoints = _a[0], deadmanPoints = _a[1];
|
229
231
|
var bhObjects = activityObjects.splice(0, utils_1.BH_MODES.length);
|
230
232
|
var clueObjects = activityObjects.splice(0, utils_1.CLUES.length);
|
231
|
-
var _b = activityObjects.splice(0,
|
233
|
+
var _b = activityObjects.splice(0, 5), lastManStanding = _b[0], pvpArena = _b[1], soulWarsZeal = _b[2], riftsClosed = _b[3], colosseumGlory = _b[4];
|
232
234
|
var bossObjects = activityObjects.splice(0, utils_1.BOSSES.length);
|
233
235
|
var skills = skillObjects.reduce(function (prev, curr, index) {
|
234
236
|
var newSkills = __assign({}, prev);
|
@@ -259,6 +261,7 @@ function parseStats(csv) {
|
|
259
261
|
pvpArena: pvpArena,
|
260
262
|
soulWarsZeal: soulWarsZeal,
|
261
263
|
riftsClosed: riftsClosed,
|
264
|
+
colosseumGlory: colosseumGlory,
|
262
265
|
clues: clues,
|
263
266
|
bosses: bosses
|
264
267
|
};
|
package/lib/types.d.ts
CHANGED
@@ -21,11 +21,11 @@ export type BHType = 'rogue' | 'hunter' | 'rogueV2' | 'hunterV2';
|
|
21
21
|
export type BH = {
|
22
22
|
[Type in BHType]: Activity;
|
23
23
|
};
|
24
|
-
export type Boss = 'abyssalSire' | 'alchemicalHydra' | 'artio' | 'barrows' | 'bryophyta' | 'callisto' | 'calvarion' | 'cerberus' | 'chambersOfXeric' | 'chambersOfXericChallengeMode' | 'chaosElemental' | 'chaosFanatic' | 'commanderZilyana' | 'corporealBeast' | 'crazyArchaeologist' | 'dagannothPrime' | 'dagannothRex' | 'dagannothSupreme' | 'derangedArchaeologist' | 'dukeSucellus' | 'generalGraardor' | 'giantMole' | 'grotesqueGuardians' | 'hespori' | 'kalphiteQueen' | 'kingBlackDragon' | 'kraken' | 'kreeArra' | 'krilTsutsaroth' | 'mimic' | 'nex' | 'nightmare' | 'phosanisNightmare' | 'obor' | 'phantomMuspah' | 'sarachnis' | 'scorpia' | 'skotizo' | 'spindel' | 'tempoross' | 'gauntlet' | 'corruptedGauntlet' | 'leviathan' | 'whisperer' | 'theatreOfBlood' | 'theatreOfBloodHardMode' | 'thermonuclearSmokeDevil' | 'tombsOfAmascut' | 'tombsOfAmascutExpertMode' | 'tzKalZuk' | 'tzTokJad' | 'vardorvis' | 'venenatis' | 'vetion' | 'vorkath' | 'wintertodt' | 'zalcano' | 'zulrah';
|
24
|
+
export type Boss = 'abyssalSire' | 'alchemicalHydra' | 'artio' | 'barrows' | 'bryophyta' | 'callisto' | 'calvarion' | 'cerberus' | 'chambersOfXeric' | 'chambersOfXericChallengeMode' | 'chaosElemental' | 'chaosFanatic' | 'commanderZilyana' | 'corporealBeast' | 'crazyArchaeologist' | 'dagannothPrime' | 'dagannothRex' | 'dagannothSupreme' | 'derangedArchaeologist' | 'dukeSucellus' | 'generalGraardor' | 'giantMole' | 'grotesqueGuardians' | 'hespori' | 'kalphiteQueen' | 'kingBlackDragon' | 'kraken' | 'kreeArra' | 'krilTsutsaroth' | 'lunarChests' | 'mimic' | 'nex' | 'nightmare' | 'phosanisNightmare' | 'obor' | 'phantomMuspah' | 'sarachnis' | 'scorpia' | 'scurrius' | 'skotizo' | 'solHeredit' | 'spindel' | 'tempoross' | 'gauntlet' | 'corruptedGauntlet' | 'leviathan' | 'whisperer' | 'theatreOfBlood' | 'theatreOfBloodHardMode' | 'thermonuclearSmokeDevil' | 'tombsOfAmascut' | 'tombsOfAmascutExpertMode' | 'tzKalZuk' | 'tzTokJad' | 'vardorvis' | 'venenatis' | 'vetion' | 'vorkath' | 'wintertodt' | 'zalcano' | 'zulrah';
|
25
25
|
export type Bosses = {
|
26
26
|
[Type in Boss]: Activity;
|
27
27
|
};
|
28
|
-
export type ActivityName = 'leaguePoints' | 'deadmanPoints' | 'hunterBHV2' | 'rogueBHV2' | 'hunterBH' | 'rogueBH' | 'lastManStanding' | 'pvpArena' | 'soulWarsZeal' | 'riftsClosed' | 'allClues' | 'beginnerClues' | 'easyClues' | 'mediumClues' | 'hardClues' | 'eliteClues' | 'masterClues' | Boss;
|
28
|
+
export type ActivityName = 'leaguePoints' | 'deadmanPoints' | 'hunterBHV2' | 'rogueBHV2' | 'hunterBH' | 'rogueBH' | 'lastManStanding' | 'pvpArena' | 'soulWarsZeal' | 'riftsClosed' | 'allClues' | 'beginnerClues' | 'easyClues' | 'mediumClues' | 'hardClues' | 'eliteClues' | 'masterClues' | 'colosseumGlory' | Boss;
|
29
29
|
export interface Stats {
|
30
30
|
skills: Skills;
|
31
31
|
clues: Clues;
|
@@ -42,6 +42,7 @@ export interface Stats {
|
|
42
42
|
pvpArena: Activity;
|
43
43
|
soulWarsZeal: Activity;
|
44
44
|
riftsClosed: Activity;
|
45
|
+
colosseumGlory: Activity;
|
45
46
|
bosses: Bosses;
|
46
47
|
}
|
47
48
|
export type Modes = {
|
package/lib/utils/constants.d.ts
CHANGED
@@ -35,6 +35,7 @@ export declare const FORMATTED_SOUL_WARS = "Soul Wars Zeal";
|
|
35
35
|
export declare const FORMATTED_LEAGUE_POINTS = "League Points";
|
36
36
|
export declare const FORMATTED_DEADMAN_POINTS = "Deadman Points";
|
37
37
|
export declare const FORMATTED_RIFTS_CLOSED = "Rifts closed";
|
38
|
+
export declare const FORMATTED_COLOSSEUM_GLORY = "Colosseum Glory";
|
38
39
|
export declare const INVALID_FORMAT_ERROR = "Invalid hiscores format";
|
39
40
|
export declare const PLAYER_NOT_FOUND_ERROR = "Player not found";
|
40
41
|
export declare const HISCORES_ERROR = "HiScores not responding";
|
package/lib/utils/constants.js
CHANGED
@@ -24,7 +24,7 @@ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
24
24
|
return to.concat(ar || Array.prototype.slice.call(from));
|
25
25
|
};
|
26
26
|
Object.defineProperty(exports, "__esModule", { value: true });
|
27
|
-
exports.HiScoresError = exports.PlayerNotFoundError = exports.InvalidRSNError = exports.InvalidFormatError = exports.HISCORES_ERROR = exports.PLAYER_NOT_FOUND_ERROR = exports.INVALID_FORMAT_ERROR = exports.FORMATTED_RIFTS_CLOSED = exports.FORMATTED_DEADMAN_POINTS = exports.FORMATTED_LEAGUE_POINTS = exports.FORMATTED_SOUL_WARS = exports.FORMATTED_PVP_ARENA = exports.FORMATTED_LMS = exports.FORMATTED_BH_NAMES = exports.FORMATTED_CLUE_NAMES = exports.FORMATTED_SKILL_NAMES = exports.FORMATTED_BOSS_NAMES = exports.ACTIVITIES = exports.BOSSES = exports.GAMEMODES = exports.BH_MODES = exports.CLUES = exports.SKILLS = exports.GAMEMODE_URL = exports.SCORES_URL = exports.JSON_STATS_URL = exports.STATS_URL = exports.BASE_URL = void 0;
|
27
|
+
exports.HiScoresError = exports.PlayerNotFoundError = exports.InvalidRSNError = exports.InvalidFormatError = exports.HISCORES_ERROR = exports.PLAYER_NOT_FOUND_ERROR = exports.INVALID_FORMAT_ERROR = exports.FORMATTED_COLOSSEUM_GLORY = exports.FORMATTED_RIFTS_CLOSED = exports.FORMATTED_DEADMAN_POINTS = exports.FORMATTED_LEAGUE_POINTS = exports.FORMATTED_SOUL_WARS = exports.FORMATTED_PVP_ARENA = exports.FORMATTED_LMS = exports.FORMATTED_BH_NAMES = exports.FORMATTED_CLUE_NAMES = exports.FORMATTED_SKILL_NAMES = exports.FORMATTED_BOSS_NAMES = exports.ACTIVITIES = exports.BOSSES = exports.GAMEMODES = exports.BH_MODES = exports.CLUES = exports.SKILLS = exports.GAMEMODE_URL = exports.SCORES_URL = exports.JSON_STATS_URL = exports.STATS_URL = exports.BASE_URL = void 0;
|
28
28
|
exports.BASE_URL = 'https://secure.runescape.com/m=hiscore_oldschool';
|
29
29
|
exports.STATS_URL = 'index_lite.ws?player=';
|
30
30
|
exports.JSON_STATS_URL = 'index_lite.json?player=';
|
@@ -116,6 +116,7 @@ exports.BOSSES = [
|
|
116
116
|
'kraken',
|
117
117
|
'kreeArra',
|
118
118
|
'krilTsutsaroth',
|
119
|
+
'lunarChests',
|
119
120
|
'mimic',
|
120
121
|
'nex',
|
121
122
|
'nightmare',
|
@@ -124,7 +125,9 @@ exports.BOSSES = [
|
|
124
125
|
'phantomMuspah',
|
125
126
|
'sarachnis',
|
126
127
|
'scorpia',
|
128
|
+
'scurrius',
|
127
129
|
'skotizo',
|
130
|
+
'solHeredit',
|
128
131
|
'spindel',
|
129
132
|
'tempoross',
|
130
133
|
'gauntlet',
|
@@ -163,7 +166,8 @@ exports.ACTIVITIES = __spreadArray([
|
|
163
166
|
'lastManStanding',
|
164
167
|
'pvpArena',
|
165
168
|
'soulWarsZeal',
|
166
|
-
'riftsClosed'
|
169
|
+
'riftsClosed',
|
170
|
+
'colosseumGlory'
|
167
171
|
], exports.BOSSES, true);
|
168
172
|
exports.FORMATTED_BOSS_NAMES = {
|
169
173
|
abyssalSire: 'Abyssal Sire',
|
@@ -195,6 +199,7 @@ exports.FORMATTED_BOSS_NAMES = {
|
|
195
199
|
kraken: 'Kraken',
|
196
200
|
kreeArra: "Kree'Arra",
|
197
201
|
krilTsutsaroth: "K'ril Tsutsaroth",
|
202
|
+
lunarChests: 'Lunar Chests',
|
198
203
|
mimic: 'Mimic',
|
199
204
|
nex: 'Nex',
|
200
205
|
nightmare: 'Nightmare',
|
@@ -203,7 +208,9 @@ exports.FORMATTED_BOSS_NAMES = {
|
|
203
208
|
phantomMuspah: 'Phantom Muspah',
|
204
209
|
sarachnis: 'Sarachnis',
|
205
210
|
scorpia: 'Scorpia',
|
211
|
+
scurrius: 'Scurrius',
|
206
212
|
skotizo: 'Skotizo',
|
213
|
+
solHeredit: 'Sol Heredit',
|
207
214
|
spindel: 'Spindel',
|
208
215
|
tempoross: 'Tempoross',
|
209
216
|
gauntlet: 'The Gauntlet',
|
@@ -272,6 +279,7 @@ exports.FORMATTED_SOUL_WARS = 'Soul Wars Zeal';
|
|
272
279
|
exports.FORMATTED_LEAGUE_POINTS = 'League Points';
|
273
280
|
exports.FORMATTED_DEADMAN_POINTS = 'Deadman Points';
|
274
281
|
exports.FORMATTED_RIFTS_CLOSED = 'Rifts closed';
|
282
|
+
exports.FORMATTED_COLOSSEUM_GLORY = 'Colosseum Glory';
|
275
283
|
exports.INVALID_FORMAT_ERROR = 'Invalid hiscores format';
|
276
284
|
exports.PLAYER_NOT_FOUND_ERROR = 'Player not found';
|
277
285
|
exports.HISCORES_ERROR = 'HiScores not responding';
|