osrs-json-hiscores 2.12.0 → 2.12.1

Sign up to get free protection for your applications and to get access to all the features.
package/LICENSE CHANGED
@@ -1,5 +1,5 @@
1
- Copyright 2021 maxswa
2
-
3
- Permission to use, copy, modify, and/or distribute this software for any purpose with or without fee is hereby granted, provided that the above copyright notice and this permission notice appear in all copies.
4
-
1
+ Copyright 2021 maxswa
2
+
3
+ Permission to use, copy, modify, and/or distribute this software for any purpose with or without fee is hereby granted, provided that the above copyright notice and this permission notice appear in all copies.
4
+
5
5
  THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
package/README.md CHANGED
@@ -1,226 +1,226 @@
1
- # OSRS .json Hiscores
2
-
3
- [![npm](https://img.shields.io/npm/v/osrs-json-hiscores.svg?style=flat-square)](https://www.npmjs.com/package/osrs-json-hiscores)
4
- [![downloads](https://img.shields.io/npm/dm/osrs-json-hiscores.svg?style=flat-square)](https://npm-stat.com/charts.html?package=osrs-json-hiscores)
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
- [![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
-
8
- **The Old School Runescape API wrapper that does more!**
9
-
10
- ## What it does
11
-
12
- The official hiscores API for Old School Runescape (OSRS) returns CSV.
13
- This wrapper converts it to json 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
-
15
- Additional functions are provided that screen-scrape the OSRS leaderboards and return a list of players as json.
16
-
17
- `osrs-json-hiscores` has TypeScript support, with full definitions for all functions and custom data types.
18
-
19
- ---
20
-
21
- ### Disclaimer
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 should 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
- ---
26
-
27
- ## Installation
28
-
29
- With npm:
30
-
31
- ```
32
- $ npm install osrs-json-hiscores
33
- ```
34
-
35
- With Yarn:
36
-
37
- ```
38
- $ yarn add osrs-json-hiscores
39
- ```
40
-
41
- ## How to use
42
-
43
- Install the package and then import it into your project:
44
-
45
- ```javascript
46
- const hiscores = require('osrs-json-hiscores');
47
- ```
48
-
49
- Once you import it you can call the functions asynchronously:
50
-
51
- ```javascript
52
- hiscores
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');
66
- const topPage = await getSkillPage('overall');
67
- ```
68
-
69
- `getStats` will return a full player object with gamemode.
70
- `getStatsByGameMode` will return a stats object and accepts a gamemode parameter:
71
-
72
- | Game mode | Param |
73
- | ---------------- | :----------: |
74
- | Regular | `main` |
75
- | Ironman | `ironman` |
76
- | Hardcore Ironman | `hardcore` |
77
- | Ultimate Ironman | `ultimate` |
78
- | Deadman Mode | `deadman` |
79
- | Tournament | `tournament` |
80
- | Leagues | `seasonal` |
81
-
82
- `getSkillPage` and `getActivityPage` require a skill / activity and optionally a gamemode and page:
83
-
84
- ```javascript
85
- hiscores
86
- .getSkillPage('attack', 'main', 1)
87
- .then((res) => console.log(res))
88
- .catch((err) => console.error(err));
89
- ```
90
-
91
- Activities consist of all levels of clue scrolls as well as minigames and bosses:
92
-
93
- ### Clue Scrolls
94
-
95
- | Type | Param |
96
- | -------- | :-------------: |
97
- | All | `allClues` |
98
- | Beginner | `beginnerClues` |
99
- | Easy | `easyClues` |
100
- | Medium | `mediumClues` |
101
- | Hard | `hardClues` |
102
- | Elite | `eliteClues` |
103
- | Master | `masterClues` |
104
-
105
- ### Minigames
106
-
107
- | Minigame | Param |
108
- | ---------------------- | :---------------: |
109
- | Bounty Hunter (Rogue) | `rogueBH` |
110
- | Bounty Hunter (Hunter) | `hunterBH` |
111
- | Last Man Standing | `lastManStanding` |
112
- | PvP Arena | `pvpArena` |
113
- | Soul Wars Zeal | `soulWarsZeal` |
114
- | Rifts Closed | `riftsClosed` |
115
-
116
- ### Leagues
117
-
118
- | Activity | Param |
119
- | ------------- | :------------: |
120
- | League Points | `leaguePoints` |
121
-
122
- ### Bosses
123
-
124
- | Boss Name | Param |
125
- | --------------------------------- | :----------------------------: |
126
- | Abyssal Sire | `abyssalSire` |
127
- | Alchemical Hydra | `alchemicalHydra` |
128
- | Barrows Chests | `barrows` |
129
- | Bryophyta | `bryophyta` |
130
- | Callisto | `callisto` |
131
- | Cerberus | `cerberus` |
132
- | Chambers Of Xeric | `chambersOfXeric` |
133
- | Chambers Of Xeric: Challenge Mode | `chambersOfXericChallengeMode` |
134
- | Chaos Elemental | `chaosElemental` |
135
- | Chaos Fanatic | `chaosFanatic` |
136
- | Commander Zilyana | `commanderZilyana` |
137
- | Corporeal Beast | `corporealBeast` |
138
- | Crazy Archaeologist | `crazyArchaeologist` |
139
- | Dagannoth Prime | `dagannothPrime` |
140
- | Dagannoth Rex | `dagannothRex` |
141
- | Dagannoth Supreme | `dagannothSupreme` |
142
- | Deranged Archaeologist | `derangedArchaeologist` |
143
- | General Graardor | `generalGraardor` |
144
- | Giant Mole | `giantMole` |
145
- | Grotesque Guardians | `grotesqueGuardians` |
146
- | Hespori | `hespori` |
147
- | Kalphite Queen | `kalphiteQueen` |
148
- | King Black Dragon | `kingBlackDragon` |
149
- | Kraken | `kraken` |
150
- | Kreearra | `kreeArra` |
151
- | K'ril Tsutsaroth | `krilTsutsaroth` |
152
- | Mimic | `mimic` |
153
- | Nex | `nex` |
154
- | The Nightmare of Ashihama | `nightmare` |
155
- | Phosani's Nightmare | `phosanisNightmare` |
156
- | Obor | `obor` |
157
- | Phantom Muspah | `phantomMuspah` |
158
- | Sarachnis | `sarachnis` |
159
- | Scorpia | `scorpia` |
160
- | Skotizo | `skotizo` |
161
- | Tempoross | `tempoross` |
162
- | The Gauntlet | `gauntlet` |
163
- | The Corrupted Gauntlet | `corruptedGauntlet` |
164
- | Theatre Of Blood | `theatreOfBlood` |
165
- | Theatre Of Blood: Hard Mode | `theatreOfBloodHardMode` |
166
- | Thermonuclear Smoke Devil | `thermonuclearSmokeDevil` |
167
- | Tombs of Amascut | `tombsOfAmascut` |
168
- | Tombs of Amascut: Expert Mode | `tombsOfAmascutExpertMode` |
169
- | TzKal-Zuk | `tzKalZuk` |
170
- | TzTok-Jad | `tzTokJad` |
171
- | Venenatis | `venenatis` |
172
- | Vetion | `vetion` |
173
- | Vorkath | `vorkath` |
174
- | Wintertodt | `wintertodt` |
175
- | Zalcano | `zalcano` |
176
- | Zulrah | `zulrah` |
177
-
178
- ## What you'll get
179
-
180
- `getStats` returns a player object that looks like this:
181
-
182
- ```javascript
183
- {
184
- name: 'Lynx Titan',
185
- mode: 'main',
186
- dead: false,
187
- deulted: false,
188
- deironed: false,
189
- main: {
190
- skills: {
191
- overall: {rank: 1, level: 2277, xp: 4600000000},
192
- attack: {},
193
- defence: {},
194
- // ...
195
- },
196
- clues: {},
197
- leaguePoints: {},
198
- bountyHunter: {},
199
- lastManStanding: {},
200
- pvpArena: {},
201
- soulWarsZeal: {},
202
- riftsClosed: {},
203
- bosses: {}
204
- }
205
- }
206
- ```
207
-
208
- `getSkillPage` returns and array of 25 players (This represents a page on the hiscores):
209
-
210
- ```javascript
211
- [
212
- { rank: 1, name: 'Lynx Titan', level: 2277, xp: 4600000000, dead: false },
213
- {},
214
- {}
215
- // ...
216
- ];
217
- ```
218
-
219
- ## Helpful Extras
220
-
221
- Get the properly formatted name of any skill, boss, clue or other activity:
222
-
223
- ```javascript
224
- // kril === "K'ril Tsutsaroth"
225
- const kril = FORMATTED_BOSS_NAMES['krilTsutsaroth'];
226
- ```
1
+ # OSRS .json Hiscores
2
+
3
+ [![npm](https://img.shields.io/npm/v/osrs-json-hiscores.svg?style=flat-square)](https://www.npmjs.com/package/osrs-json-hiscores)
4
+ [![downloads](https://img.shields.io/npm/dm/osrs-json-hiscores.svg?style=flat-square)](https://npm-stat.com/charts.html?package=osrs-json-hiscores)
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
+ [![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
+
8
+ **The Old School Runescape API wrapper that does more!**
9
+
10
+ ## What it does
11
+
12
+ The official hiscores API for Old School Runescape (OSRS) returns CSV.
13
+ This wrapper converts it to json 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
+
15
+ Additional functions are provided that screen-scrape the OSRS leaderboards and return a list of players as json.
16
+
17
+ `osrs-json-hiscores` has TypeScript support, with full definitions for all functions and custom data types.
18
+
19
+ ---
20
+
21
+ ### Disclaimer
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 should 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
+ ---
26
+
27
+ ## Installation
28
+
29
+ With npm:
30
+
31
+ ```
32
+ $ npm install osrs-json-hiscores
33
+ ```
34
+
35
+ With Yarn:
36
+
37
+ ```
38
+ $ yarn add osrs-json-hiscores
39
+ ```
40
+
41
+ ## How to use
42
+
43
+ Install the package and then import it into your project:
44
+
45
+ ```javascript
46
+ const hiscores = require('osrs-json-hiscores');
47
+ ```
48
+
49
+ Once you import it you can call the functions asynchronously:
50
+
51
+ ```javascript
52
+ hiscores
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');
66
+ const topPage = await getSkillPage('overall');
67
+ ```
68
+
69
+ `getStats` will return a full player object with gamemode.
70
+ `getStatsByGameMode` will return a stats object and accepts a gamemode parameter:
71
+
72
+ | Game mode | Param |
73
+ | ---------------- | :----------: |
74
+ | Regular | `main` |
75
+ | Ironman | `ironman` |
76
+ | Hardcore Ironman | `hardcore` |
77
+ | Ultimate Ironman | `ultimate` |
78
+ | Deadman Mode | `deadman` |
79
+ | Tournament | `tournament` |
80
+ | Leagues | `seasonal` |
81
+
82
+ `getSkillPage` and `getActivityPage` require a skill / activity and optionally a gamemode and page:
83
+
84
+ ```javascript
85
+ hiscores
86
+ .getSkillPage('attack', 'main', 1)
87
+ .then((res) => console.log(res))
88
+ .catch((err) => console.error(err));
89
+ ```
90
+
91
+ Activities consist of all levels of clue scrolls as well as minigames and bosses:
92
+
93
+ ### Clue Scrolls
94
+
95
+ | Type | Param |
96
+ | -------- | :-------------: |
97
+ | All | `allClues` |
98
+ | Beginner | `beginnerClues` |
99
+ | Easy | `easyClues` |
100
+ | Medium | `mediumClues` |
101
+ | Hard | `hardClues` |
102
+ | Elite | `eliteClues` |
103
+ | Master | `masterClues` |
104
+
105
+ ### Minigames
106
+
107
+ | Minigame | Param |
108
+ | ---------------------- | :---------------: |
109
+ | Bounty Hunter (Rogue) | `rogueBH` |
110
+ | Bounty Hunter (Hunter) | `hunterBH` |
111
+ | Last Man Standing | `lastManStanding` |
112
+ | PvP Arena | `pvpArena` |
113
+ | Soul Wars Zeal | `soulWarsZeal` |
114
+ | Rifts Closed | `riftsClosed` |
115
+
116
+ ### Leagues
117
+
118
+ | Activity | Param |
119
+ | ------------- | :------------: |
120
+ | League Points | `leaguePoints` |
121
+
122
+ ### Bosses
123
+
124
+ | Boss Name | Param |
125
+ | --------------------------------- | :----------------------------: |
126
+ | Abyssal Sire | `abyssalSire` |
127
+ | Alchemical Hydra | `alchemicalHydra` |
128
+ | Barrows Chests | `barrows` |
129
+ | Bryophyta | `bryophyta` |
130
+ | Callisto | `callisto` |
131
+ | Cerberus | `cerberus` |
132
+ | Chambers Of Xeric | `chambersOfXeric` |
133
+ | Chambers Of Xeric: Challenge Mode | `chambersOfXericChallengeMode` |
134
+ | Chaos Elemental | `chaosElemental` |
135
+ | Chaos Fanatic | `chaosFanatic` |
136
+ | Commander Zilyana | `commanderZilyana` |
137
+ | Corporeal Beast | `corporealBeast` |
138
+ | Crazy Archaeologist | `crazyArchaeologist` |
139
+ | Dagannoth Prime | `dagannothPrime` |
140
+ | Dagannoth Rex | `dagannothRex` |
141
+ | Dagannoth Supreme | `dagannothSupreme` |
142
+ | Deranged Archaeologist | `derangedArchaeologist` |
143
+ | General Graardor | `generalGraardor` |
144
+ | Giant Mole | `giantMole` |
145
+ | Grotesque Guardians | `grotesqueGuardians` |
146
+ | Hespori | `hespori` |
147
+ | Kalphite Queen | `kalphiteQueen` |
148
+ | King Black Dragon | `kingBlackDragon` |
149
+ | Kraken | `kraken` |
150
+ | Kreearra | `kreeArra` |
151
+ | K'ril Tsutsaroth | `krilTsutsaroth` |
152
+ | Mimic | `mimic` |
153
+ | Nex | `nex` |
154
+ | The Nightmare of Ashihama | `nightmare` |
155
+ | Phosani's Nightmare | `phosanisNightmare` |
156
+ | Obor | `obor` |
157
+ | Phantom Muspah | `phantomMuspah` |
158
+ | Sarachnis | `sarachnis` |
159
+ | Scorpia | `scorpia` |
160
+ | Skotizo | `skotizo` |
161
+ | Tempoross | `tempoross` |
162
+ | The Gauntlet | `gauntlet` |
163
+ | The Corrupted Gauntlet | `corruptedGauntlet` |
164
+ | Theatre Of Blood | `theatreOfBlood` |
165
+ | Theatre Of Blood: Hard Mode | `theatreOfBloodHardMode` |
166
+ | Thermonuclear Smoke Devil | `thermonuclearSmokeDevil` |
167
+ | Tombs of Amascut | `tombsOfAmascut` |
168
+ | Tombs of Amascut: Expert Mode | `tombsOfAmascutExpertMode` |
169
+ | TzKal-Zuk | `tzKalZuk` |
170
+ | TzTok-Jad | `tzTokJad` |
171
+ | Venenatis | `venenatis` |
172
+ | Vetion | `vetion` |
173
+ | Vorkath | `vorkath` |
174
+ | Wintertodt | `wintertodt` |
175
+ | Zalcano | `zalcano` |
176
+ | Zulrah | `zulrah` |
177
+
178
+ ## What you'll get
179
+
180
+ `getStats` returns a player object that looks like this:
181
+
182
+ ```javascript
183
+ {
184
+ name: 'Lynx Titan',
185
+ mode: 'main',
186
+ dead: false,
187
+ deulted: false,
188
+ deironed: false,
189
+ main: {
190
+ skills: {
191
+ overall: {rank: 1, level: 2277, xp: 4600000000},
192
+ attack: {},
193
+ defence: {},
194
+ // ...
195
+ },
196
+ clues: {},
197
+ leaguePoints: {},
198
+ bountyHunter: {},
199
+ lastManStanding: {},
200
+ pvpArena: {},
201
+ soulWarsZeal: {},
202
+ riftsClosed: {},
203
+ bosses: {}
204
+ }
205
+ }
206
+ ```
207
+
208
+ `getSkillPage` returns and array of 25 players (This represents a page on the hiscores):
209
+
210
+ ```javascript
211
+ [
212
+ { rank: 1, name: 'Lynx Titan', level: 2277, xp: 4600000000, dead: false },
213
+ {},
214
+ {}
215
+ // ...
216
+ ];
217
+ ```
218
+
219
+ ## Helpful Extras
220
+
221
+ Get the properly formatted name of any skill, boss, clue or other activity:
222
+
223
+ ```javascript
224
+ // kril === "K'ril Tsutsaroth"
225
+ const kril = FORMATTED_BOSS_NAMES['krilTsutsaroth'];
226
+ ```
package/lib/hiscores.d.ts CHANGED
@@ -1,43 +1,43 @@
1
- import { Player, Stats, Gamemode, SkillName, PlayerSkillRow, ActivityName, PlayerActivityRow } from './types';
2
- /**
3
- * Screen scrapes the hiscores to get the formatted rsn of a player.
4
- *
5
- * @param rsn Username of the player.
6
- * @returns Formatted version of the rsn.
7
- */
8
- export declare function getRSNFormat(rsn: string): Promise<string>;
9
- /**
10
- * Parses CSV string of raw stats and returns a stats object.
11
- *
12
- * @param csv Raw CSV from the official OSRS API.
13
- * @returns Parsed stats object.
14
- */
15
- export declare function parseStats(csv: string): Stats;
16
- /**
17
- * Fetches stats from the OSRS API and consolidates the info into a player object.
18
- *
19
- * **Note:** This function will make up to 5 separate network requests.
20
- * As such, it is highly subject to the performance of the official OSRS API.
21
- *
22
- * @param rsn Username of the player.
23
- * @returns Player object.
24
- */
25
- export declare function getStats(rsn: string): Promise<Player>;
26
- /**
27
- * Fetches stats from the OSRS API and returns them as an object.
28
- *
29
- * @param rsn Username of the player.
30
- * @param mode Gamemode to fetch ranks for.
31
- * @returns Stats object.
32
- */
33
- export declare function getStatsByGamemode(rsn: string, mode?: Gamemode): Promise<Stats>;
34
- export declare function getSkillPage(skill: SkillName, mode?: Gamemode, page?: number): Promise<PlayerSkillRow[]>;
35
- /**
36
- * Screen scrapes a hiscores page of an activity or boss and returns an array of up to 25 players.
37
- *
38
- * @param activity Name of the activity or boss to fetch hiscores for.
39
- * @param mode Gamemode to fetch ranks for.
40
- * @param page Page number.
41
- * @returns Array of `PlayerActivityRow` objects.
42
- */
43
- export declare function getActivityPage(activity: ActivityName, mode?: Gamemode, page?: number): Promise<PlayerActivityRow[]>;
1
+ import { Player, Stats, Gamemode, SkillName, PlayerSkillRow, ActivityName, PlayerActivityRow, GetStatsOptions } from './types';
2
+ /**
3
+ * Screen scrapes the hiscores to get the formatted rsn of a player.
4
+ *
5
+ * @param rsn Username of the player.
6
+ * @returns Formatted version of the rsn.
7
+ */
8
+ export declare function getRSNFormat(rsn: string): Promise<string>;
9
+ /**
10
+ * Parses CSV string of raw stats and returns a stats object.
11
+ *
12
+ * @param csv Raw CSV from the official OSRS API.
13
+ * @returns Parsed stats object.
14
+ */
15
+ export declare function parseStats(csv: string): Stats;
16
+ /**
17
+ * Fetches stats from the OSRS API and consolidates the info into a player object.
18
+ *
19
+ * **Note:** This function will make up to 5 separate network requests.
20
+ * As such, it is highly subject to the performance of the official OSRS API.
21
+ *
22
+ * @param rsn Username of the player.
23
+ * @returns Player object.
24
+ */
25
+ export declare function getStats(rsn: string, options?: GetStatsOptions): Promise<Player>;
26
+ /**
27
+ * Fetches stats from the OSRS API and returns them as an object.
28
+ *
29
+ * @param rsn Username of the player.
30
+ * @param mode Gamemode to fetch ranks for.
31
+ * @returns Stats object.
32
+ */
33
+ export declare function getStatsByGamemode(rsn: string, mode?: Gamemode): Promise<Stats>;
34
+ export declare function getSkillPage(skill: SkillName, mode?: Gamemode, page?: number): Promise<PlayerSkillRow[]>;
35
+ /**
36
+ * Screen scrapes a hiscores page of an activity or boss and returns an array of up to 25 players.
37
+ *
38
+ * @param activity Name of the activity or boss to fetch hiscores for.
39
+ * @param mode Gamemode to fetch ranks for.
40
+ * @param page Page number.
41
+ * @returns Array of `PlayerActivityRow` objects.
42
+ */
43
+ export declare function getActivityPage(activity: ActivityName, mode?: Gamemode, page?: number): Promise<PlayerActivityRow[]>;