osrs-json-hiscores 2.16.3 → 2.17.0

Sign up to get free protection for your applications and to get access to all the features.
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 Runescape API wrapper that does more!**
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 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).
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 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)
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
- ```javascript
46
- const hiscores = require('osrs-json-hiscores');
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
- ```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');
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
- ```javascript
85
- hiscores
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
  ```
@@ -163,6 +151,7 @@ Activities consist of all levels of clue scrolls as well as minigames and bosses
163
151
  | Phantom Muspah | `phantomMuspah` |
164
152
  | Sarachnis | `sarachnis` |
165
153
  | Scorpia | `scorpia` |
154
+ | Scurrius | `scurrius` |
166
155
  | Skotizo | `skotizo` |
167
156
  | Spindel | `spindel` |
168
157
  | Tempoross | `tempoross` |
@@ -189,7 +178,7 @@ Activities consist of all levels of clue scrolls as well as minigames and bosses
189
178
 
190
179
  `getStats` returns a player object that looks like this:
191
180
 
192
- ```javascript
181
+ ```typescript
193
182
  {
194
183
  name: 'Lynx Titan',
195
184
  mode: 'main',
@@ -217,7 +206,7 @@ Activities consist of all levels of clue scrolls as well as minigames and bosses
217
206
 
218
207
  `getSkillPage` returns and array of 25 players (This represents a page on the hiscores):
219
208
 
220
- ```javascript
209
+ ```typescript
221
210
  [
222
211
  { rank: 1, name: 'Lynx Titan', level: 2277, xp: 4600000000, dead: false },
223
212
  {},
@@ -230,7 +219,7 @@ Activities consist of all levels of clue scrolls as well as minigames and bosses
230
219
 
231
220
  Get the properly formatted name of any skill, boss, clue or other activity:
232
221
 
233
- ```javascript
222
+ ```typescript
234
223
  // kril === "K'ril Tsutsaroth"
235
224
  const kril = FORMATTED_BOSS_NAMES['krilTsutsaroth'];
236
225
  ```
package/lib/types.d.ts CHANGED
@@ -21,7 +21,7 @@ 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' | 'mimic' | 'nex' | 'nightmare' | 'phosanisNightmare' | 'obor' | 'phantomMuspah' | 'sarachnis' | 'scorpia' | 'scurrius' | 'skotizo' | '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
  };
@@ -124,6 +124,7 @@ exports.BOSSES = [
124
124
  'phantomMuspah',
125
125
  'sarachnis',
126
126
  'scorpia',
127
+ 'scurrius',
127
128
  'skotizo',
128
129
  'spindel',
129
130
  'tempoross',
@@ -203,6 +204,7 @@ exports.FORMATTED_BOSS_NAMES = {
203
204
  phantomMuspah: 'Phantom Muspah',
204
205
  sarachnis: 'Sarachnis',
205
206
  scorpia: 'Scorpia',
207
+ scurrius: 'Scurrius',
206
208
  skotizo: 'Skotizo',
207
209
  spindel: 'Spindel',
208
210
  tempoross: 'Tempoross',
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "osrs-json-hiscores",
3
- "version": "2.16.3",
3
+ "version": "2.17.0",
4
4
  "description": "The Old School Runescape API wrapper that does more!",
5
5
  "main": "lib/index.js",
6
6
  "types": "lib/index.d.ts",