Update readme

This commit is contained in:
Max
2019-06-14 18:50:45 -04:00
parent 2fcf9d2029
commit 2d75642456

View File

@@ -8,9 +8,11 @@
## What it does ## What it does
The official hiscores API for Oldschool Runescape (OSRS) returns CSV. 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). 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).
An additional function is provided which screen-scrapes the OSRS leaderboards and returns the list of players as json Additional functions are provided that screen-scrape the OSRS leaderboards and return a list of players as json.
`osrs-json-hiscores` has Typescript support, with full definitions for all functions and custom data types.
## Installation ## Installation
@@ -20,12 +22,18 @@ With npm:
$ npm install osrs-json-hiscores $ npm install osrs-json-hiscores
``` ```
With Yarn:
```
$ yarn add osrs-json-hiscores
```
## How to use ## How to use
Install the package via npm and then import it into your project: Install the package and then import it into your project:
```javascript ```javascript
import hiscores from 'osrs-json-hiscores'; const hiscores = require('osrs-json-hiscores');
``` ```
Once you import it you can call the functions asynchronously: Once you import it you can call the functions asynchronously:
@@ -37,6 +45,17 @@ hiscores
.catch(err => console.error(err)); .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');
```
`getStats` will return a `full` player object with game mode by default, but it will also accept any of the following game modes: `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 | | Game mode | Param |
@@ -49,17 +68,16 @@ hiscores
| Seasonal Deadman | `sdmm` | | Seasonal Deadman | `sdmm` |
| DMM Tournament | `dmmt` | | DMM Tournament | `dmmt` |
`getHiscores` requires a game mode and optionally a category and page: `getSkillPage` and `getActivityPage` require a skill/activity and optionally a gamemode and page:
```javascript ```javascript
hiscores hiscores
.getHiscores('main', 'overall', 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));
``` ```
The default values for category and page are `overall` and `1` respectively. Activities consist of all levels of clue scrolls as well as minigames:
Categories include all OSRS skills as well as:
### Clue Scrolls ### Clue Scrolls
@@ -90,31 +108,29 @@ Categories include all OSRS skills as well as:
rsn: 'Lynx Titan', rsn: 'Lynx Titan',
mode: 'main', mode: 'main',
dead: false, dead: false,
deulted: false,
deironed: false, deironed: false,
main: { main: {
stats: { skills: {
overall: {rank: 1, level: 2277, xp: 4600000000}, overall: {rank: 1, level: 2277, xp: 4600000000},
attack: {}, attack: {},
defence: {}, defence: {},
... // ...
}, },
clues: {}, clues: {},
bh: {}, bh: {},
lms: {} lms: {}
}, }
iron: {},
hc: {},
ult: {}
} }
``` ```
`getHiscores` 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 ```javascript
[ [
{mode: 'main', category: 'overall', rank: 1, rsn: 'Lynx Titan', level: 2277, xp: 4600000000}, { rank: 1, rsn: 'Lynx Titan', level: 2277, xp: 4600000000, dead: false },
{}, {},
{}, {},
... // ...
] ];
``` ```