Add cheerio to getRSNFormat and getHiscoresPage

This commit is contained in:
maxswa
2019-06-10 13:48:49 -04:00
parent f776e5e936
commit 2fd1c4f9b1
5 changed files with 213 additions and 63 deletions

View File

@@ -1,64 +1,82 @@
# OSRS .json Hiscores
**The Oldschool Runescape API wrapper that does more!**
## What it does
The official hiscores API for Oldschool Runescape (OSRS) returns CSV.
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-ironed or died as a hardcore ironman).
An additional function is provided which screen-scrapes the OSRS leaderboards and returns the list of players as json
## Installation
With npm:
```
$ npm install osrs-json-hiscores
```
## How to use
Install the package via npm and then import it into your project:
```javascript
import hiscores from 'osrs-json-hiscores'
import hiscores from 'osrs-json-hiscores';
```
Once you import it you can call the functions asynchronously:
```javascript
hiscores.getStats('Lynx Titan', 'full')
hiscores
.getStats('Lynx Titan', 'full')
.then(res => console.log(res))
.catch(err => console.error(err))
.catch(err => console.error(err));
```
`getStats` will return a `full` player object with game mode by default, but it will also accept any of the following game modes:
Game mode | Param
--- | :-:
Regular | `main`
Ironman | `iron`
Hardcore Ironman | `hc`
Ultimate Ironman | `ult`
Deadman Mode | `dmm`
Seasonal Deadman | `sdmm`
DMM Tournament | `dmmt`
| Game mode | Param |
| ---------------- | :----: |
| Regular | `main` |
| Ironman | `iron` |
| Hardcore Ironman | `hc` |
| Ultimate Ironman | `ult` |
| Deadman Mode | `dmm` |
| Seasonal Deadman | `sdmm` |
| DMM Tournament | `dmmt` |
`getHiscores` requires a game mode and optionally a category and page:
```javascript
hiscores.getHiscores('main', 'overall', 1)
hiscores
.getHiscores('main', 'overall', 1)
.then(res => console.log(res))
.catch(err => console.error(err))
.catch(err => console.error(err));
```
The default values for category and page are `overall` and `1` respectively.
Categories include all OSRS skills as well as:
### Clue Scrolls
Type | Param
--- | :-:
All | `allclues`
Easy | `easyclues`
Medium | `mediumclues`
Hard | `hardclues`
Elite | `eliteclues`
Master | `masterclues`
| Type | Param |
| -------- | :-------------: |
| All | `allclues` |
| Beginner | `beginnerclues` |
| Easy | `easyclues` |
| Medium | `mediumclues` |
| Hard | `hardclues` |
| Elite | `eliteclues` |
| Master | `masterclues` |
### Minigames
Minigame | Param
--- | :-:
Bounty Hunter (Rogue) | `roguebh`
Bounty Hunter (Hunter) | `hunterbh`
Last Man Standing | `lms`
| Minigame | Param |
| ---------------------- | :--------: |
| Bounty Hunter (Rogue) | `roguebh` |
| Bounty Hunter (Hunter) | `hunterbh` |
| Last Man Standing | `lms` |
## What you'll get
@@ -72,7 +90,7 @@ Last Man Standing | `lms`
deironed: false,
main: {
stats: {
overall: {rank: 1, level: 2277, xp: 5,000,000,000},
overall: {rank: 1, level: 2277, xp: 4600000000},
attack: {},
defence: {},
...
@@ -91,9 +109,9 @@ Last Man Standing | `lms`
```javascript
[
{mode: 'main', category: 'overall', rank: 1, rsn: 'Lynx Titan', level: 2277, xp: 5,000,000,000},
{mode: 'main', category: 'overall', rank: 1, rsn: 'Lynx Titan', level: 2277, xp: 4600000000},
{},
{},
...
]
```
```