Compare commits

...

9 Commits

Author SHA1 Message Date
maxswa
3b502cb7cf v2.17.0 2024-01-24 11:25:48 -05:00
Max Swartwout
b3f81e66eb Merge pull request #88 from maxswa/scurrius
Add Scurrius
2024-01-24 11:24:34 -05:00
Max Swartwout
01150b6234 Merge pull request #93 from maxswa/update-readme-json-api
Add reference to official JSON API in README
2024-01-19 18:43:47 -05:00
maxswa
ca4d75f2c7 Add reference to official JSON API in README. 2024-01-19 18:37:14 -05:00
Max Swartwout
03b2ef42d2 Merge pull request #91 from maxswa/dependabot/npm_and_yarn/follow-redirects-1.15.4
Bump follow-redirects from 1.15.3 to 1.15.4
2024-01-19 18:18:24 -05:00
dependabot[bot]
7e2603b235 Bump follow-redirects from 1.15.3 to 1.15.4
Bumps [follow-redirects](https://github.com/follow-redirects/follow-redirects) from 1.15.3 to 1.15.4.
- [Release notes](https://github.com/follow-redirects/follow-redirects/releases)
- [Commits](https://github.com/follow-redirects/follow-redirects/compare/v1.15.3...v1.15.4)

---
updated-dependencies:
- dependency-name: follow-redirects
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>
2024-01-11 04:36:21 +00:00
maxswa
92452e240c Add Scurrius 2023-12-30 23:25:32 -05:00
maxswa
d01b36422e v2.16.3 2023-12-17 20:17:17 -05:00
Max Swartwout
3bc1352838 Merge pull request #90 from maxswa/deadman-points
Add Deadman Points
2023-12-17 20:16:28 -05:00
8 changed files with 50 additions and 54 deletions

View File

@@ -5,22 +5,24 @@
[![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) [![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)
[![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) [![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)
**The Old School Runescape API wrapper that does more!** **The Old School RuneScape API wrapper that does more!**
## What it does ## What it does
The official hiscores API for Old School Runescape (OSRS) returns CSV. The official hiscores API for Old School RuneScape (OSRS) can return CSV or a simple JSON array.
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). 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. 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. `osrs-json-hiscores` has TypeScript support, with full definitions for all functions and custom data types.
--- ---
### Disclaimer ### Disclaimer
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) 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)
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.
--- ---
@@ -42,27 +44,14 @@ $ yarn add osrs-json-hiscores
Install the package and then import it into your project: Install the package and then import it into your project:
```javascript ```typescript
const hiscores = require('osrs-json-hiscores'); import { getStatsByGamemode, getSkillPage } from 'osrs-json-hiscores';
``` ```
Once you import it you can call the functions asynchronously: Once you import it you can call the functions asynchronously:
```javascript ```typescript
hiscores const stats = await getStatsByGamemode('Lynx Titan');
.getStats('Lynx Titan')
.then((res) => console.log(res))
.catch((err) => console.error(err));
```
If you are using TypeScript or transpiling your JS you can use ES6 syntax:
```javascript
import hiscores, { getSkillPage } from 'osrs-json-hiscores';
// ...
const stats = await hiscores.getStats('Lynx Titan');
const topPage = await getSkillPage('overall'); const topPage = await getSkillPage('overall');
``` ```
@@ -81,9 +70,8 @@ const topPage = await getSkillPage('overall');
`getSkillPage` and `getActivityPage` require a skill / activity and optionally a gamemode and page: `getSkillPage` and `getActivityPage` require a skill / activity and optionally a gamemode and page:
```javascript ```typescript
hiscores getSkillPage('attack', 'main', 1)
.getSkillPage('attack', 'main', 1)
.then((res) => console.log(res)) .then((res) => console.log(res))
.catch((err) => console.error(err)); .catch((err) => console.error(err));
``` ```
@@ -163,6 +151,7 @@ Activities consist of all levels of clue scrolls as well as minigames and bosses
| Phantom Muspah | `phantomMuspah` | | Phantom Muspah | `phantomMuspah` |
| Sarachnis | `sarachnis` | | Sarachnis | `sarachnis` |
| Scorpia | `scorpia` | | Scorpia | `scorpia` |
| Scurrius | `scurrius` |
| Skotizo | `skotizo` | | Skotizo | `skotizo` |
| Spindel | `spindel` | | Spindel | `spindel` |
| Tempoross | `tempoross` | | Tempoross | `tempoross` |
@@ -189,7 +178,7 @@ Activities consist of all levels of clue scrolls as well as minigames and bosses
`getStats` returns a player object that looks like this: `getStats` returns a player object that looks like this:
```javascript ```typescript
{ {
name: 'Lynx Titan', name: 'Lynx Titan',
mode: 'main', mode: 'main',
@@ -217,7 +206,7 @@ Activities consist of all levels of clue scrolls as well as minigames and bosses
`getSkillPage` returns and array of 25 players (This represents a page on the hiscores): `getSkillPage` returns and array of 25 players (This represents a page on the hiscores):
```javascript ```typescript
[ [
{ rank: 1, name: 'Lynx Titan', level: 2277, xp: 4600000000, dead: false }, { rank: 1, name: 'Lynx Titan', level: 2277, xp: 4600000000, dead: false },
{}, {},
@@ -230,7 +219,7 @@ Activities consist of all levels of clue scrolls as well as minigames and bosses
Get the properly formatted name of any skill, boss, clue or other activity: Get the properly formatted name of any skill, boss, clue or other activity:
```javascript ```typescript
// kril === "K'ril Tsutsaroth" // kril === "K'ril Tsutsaroth"
const kril = FORMATTED_BOSS_NAMES['krilTsutsaroth']; const kril = FORMATTED_BOSS_NAMES['krilTsutsaroth'];
``` ```

View File

@@ -76,6 +76,7 @@
21848,251 21848,251
66260,119 66260,119
108898,26 108898,26
23958,90
373975,9 373975,9
2005,1569 2005,1569
40001,273 40001,273
Can't render this file because it has a wrong number of fields in line 25.

View File

@@ -161,41 +161,42 @@
{ "id": 51, "name": "Phantom Muspah", "rank": 21848, "score": 251 }, { "id": 51, "name": "Phantom Muspah", "rank": 21848, "score": 251 },
{ "id": 52, "name": "Sarachnis", "rank": 66260, "score": 119 }, { "id": 52, "name": "Sarachnis", "rank": 66260, "score": 119 },
{ "id": 53, "name": "Scorpia", "rank": 108898, "score": 26 }, { "id": 53, "name": "Scorpia", "rank": 108898, "score": 26 },
{ "id": 54, "name": "Skotizo", "rank": 373975, "score": 9 }, { "id": 54, "name": "Scurrius", "rank": 23958, "score": 90 },
{ "id": 55, "name": "Spindel", "rank": 2005, "score": 1569 }, { "id": 55, "name": "Skotizo", "rank": 373975, "score": 9 },
{ "id": 56, "name": "Tempoross", "rank": 40001, "score": 273 }, { "id": 56, "name": "Spindel", "rank": 2005, "score": 1569 },
{ "id": 57, "name": "The Gauntlet", "rank": 192608, "score": 7 }, { "id": 57, "name": "Tempoross", "rank": 40001, "score": 273 },
{ "id": 58, "name": "The Corrupted Gauntlet", "rank": 78367, "score": 201 }, { "id": 58, "name": "The Gauntlet", "rank": 192608, "score": 7 },
{ "id": 59, "name": "The Leviathan", "rank": 5679, "score": 583 }, { "id": 59, "name": "The Corrupted Gauntlet", "rank": 78367, "score": 201 },
{ "id": 60, "name": "The Whisperer", "rank": 478, "score": 1760 }, { "id": 60, "name": "The Leviathan", "rank": 5679, "score": 583 },
{ "id": 61, "name": "Theatre of Blood", "rank": 22932, "score": 250 }, { "id": 61, "name": "The Whisperer", "rank": 478, "score": 1760 },
{ "id": 62, "name": "Theatre of Blood", "rank": 22932, "score": 250 },
{ {
"id": 62, "id": 63,
"name": "Theatre of Blood: Hard Mode", "name": "Theatre of Blood: Hard Mode",
"rank": 15059, "rank": 15059,
"score": 7 "score": 7
}, },
{ {
"id": 63, "id": 64,
"name": "Thermonuclear Smoke Devil", "name": "Thermonuclear Smoke Devil",
"rank": 7161, "rank": 7161,
"score": 3066 "score": 3066
}, },
{ "id": 64, "name": "Tombs of Amascut", "rank": 101555, "score": 35 }, { "id": 65, "name": "Tombs of Amascut", "rank": 101555, "score": 35 },
{ {
"id": 65, "id": 66,
"name": "Tombs of Amascut: Expert Mode", "name": "Tombs of Amascut: Expert Mode",
"rank": 610, "rank": 610,
"score": 933 "score": 933
}, },
{ "id": 66, "name": "TzKal-Zuk", "rank": 15733, "score": 2 }, { "id": 67, "name": "TzKal-Zuk", "rank": 15733, "score": 2 },
{ "id": 67, "name": "TzTok-Jad", "rank": -1, "score": -1 }, { "id": 68, "name": "TzTok-Jad", "rank": -1, "score": -1 },
{ "id": 68, "name": "Vardorvis", "rank": 2051, "score": 2078 }, { "id": 69, "name": "Vardorvis", "rank": 2051, "score": 2078 },
{ "id": 69, "name": "Venenatis", "rank": 194, "score": 7096 }, { "id": 70, "name": "Venenatis", "rank": 194, "score": 7096 },
{ "id": 70, "name": "Vet'ion", "rank": 69260, "score": 51 }, { "id": 71, "name": "Vet'ion", "rank": 69260, "score": 51 },
{ "id": 71, "name": "Vorkath", "rank": 14039, "score": 2780 }, { "id": 72, "name": "Vorkath", "rank": 14039, "score": 2780 },
{ "id": 72, "name": "Wintertodt", "rank": 876367, "score": 62 }, { "id": 73, "name": "Wintertodt", "rank": 876367, "score": 62 },
{ "id": 73, "name": "Zalcano", "rank": 165341, "score": 25 }, { "id": 74, "name": "Zalcano", "rank": 165341, "score": 25 },
{ "id": 74, "name": "Zulrah", "rank": 226318, "score": 275 } { "id": 75, "name": "Zulrah", "rank": 226318, "score": 275 }
] ]
} }

View File

@@ -139,6 +139,7 @@ test('Parse CSV to json', () => {
44,6233 44,6233
201,1101 201,1101
82,3404 82,3404
555,7079
5085,61 5085,61
678,903 678,903
18823,23 18823,23
@@ -247,6 +248,7 @@ test('Parse CSV to json', () => {
phantomMuspah: { rank: 44, score: 6233 }, phantomMuspah: { rank: 44, score: 6233 },
sarachnis: { rank: 201, score: 1101 }, sarachnis: { rank: 201, score: 1101 },
scorpia: { rank: 82, score: 3404 }, scorpia: { rank: 82, score: 3404 },
scurrius: { rank: 555, score: 7079 },
skotizo: { rank: 5085, score: 61 }, skotizo: { rank: 5085, score: 61 },
spindel: { rank: 678, score: 903 }, spindel: { rank: 678, score: 903 },
tempoross: { rank: 18823, score: 23 }, tempoross: { rank: 18823, score: 23 },

View File

@@ -1,6 +1,6 @@
{ {
"name": "osrs-json-hiscores", "name": "osrs-json-hiscores",
"version": "2.16.2", "version": "2.17.0",
"description": "The Old School Runescape API wrapper that does more!", "description": "The Old School Runescape API wrapper that does more!",
"main": "lib/index.js", "main": "lib/index.js",
"types": "lib/index.d.ts", "types": "lib/index.d.ts",

View File

@@ -104,6 +104,7 @@ export type Boss =
| 'phantomMuspah' | 'phantomMuspah'
| 'sarachnis' | 'sarachnis'
| 'scorpia' | 'scorpia'
| 'scurrius'
| 'skotizo' | 'skotizo'
| 'spindel' | 'spindel'
| 'tempoross' | 'tempoross'

View File

@@ -111,6 +111,7 @@ export const BOSSES: Boss[] = [
'phantomMuspah', 'phantomMuspah',
'sarachnis', 'sarachnis',
'scorpia', 'scorpia',
'scurrius',
'skotizo', 'skotizo',
'spindel', 'spindel',
'tempoross', 'tempoross',
@@ -196,6 +197,7 @@ export const FORMATTED_BOSS_NAMES: FormattedBossNames = {
phantomMuspah: 'Phantom Muspah', phantomMuspah: 'Phantom Muspah',
sarachnis: 'Sarachnis', sarachnis: 'Sarachnis',
scorpia: 'Scorpia', scorpia: 'Scorpia',
scurrius: 'Scurrius',
skotizo: 'Skotizo', skotizo: 'Skotizo',
spindel: 'Spindel', spindel: 'Spindel',
tempoross: 'Tempoross', tempoross: 'Tempoross',

View File

@@ -2429,9 +2429,9 @@ flatted@^3.1.0:
integrity sha512-zAoAQiudy+r5SvnSw3KJy5os/oRJYHzrzja/tBDqrZtNhUw8bt6y8OBzMWcjWr+8liV8Eb6yOhw8WZ7VFZ5ZzA== integrity sha512-zAoAQiudy+r5SvnSw3KJy5os/oRJYHzrzja/tBDqrZtNhUw8bt6y8OBzMWcjWr+8liV8Eb6yOhw8WZ7VFZ5ZzA==
follow-redirects@^1.15.0: follow-redirects@^1.15.0:
version "1.15.3" version "1.15.4"
resolved "https://registry.yarnpkg.com/follow-redirects/-/follow-redirects-1.15.3.tgz#fe2f3ef2690afce7e82ed0b44db08165b207123a" resolved "https://registry.yarnpkg.com/follow-redirects/-/follow-redirects-1.15.4.tgz#cdc7d308bf6493126b17ea2191ea0ccf3e535adf"
integrity sha512-1VzOtuEM8pC9SFU1E+8KfTjZyMztRsgEfwQl44z8A25uy13jSzTj6dyK2Df52iV0vgHCfBwLhDWevLn95w5v6Q== integrity sha512-Cr4D/5wlrb0z9dgERpUL3LrmPKVDsETIJhaCMeDfuFYcqa5bldGV6wBsAN6X/vxlXQtFBMrXdXxdL8CbDTGniw==
for-each@^0.3.3: for-each@^0.3.3:
version "0.3.3" version "0.3.3"