npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

osrs-api

v0.1.2

Published

A wrapper for OSRS's hiscores API and Grand Exchange API.

Downloads

4

Readme

osrs-api

npm

A node.js-based wrapper for OSRS's hiscores API and Grand Exchange API. Forked from atjeff/Osrs-Wrapper.

Installation

$ npm install --save osrs-api

Usage

Hiscores

getPlayer({ name, type })

Used to retrieve a player's hiscore entry.

Example
const { constants, hiscores } = require("osrs-api");

hiscores.getPlayer({ name: "Sadie Miller", type: constants.playerTypes.hardcoreIronman }).then(console.log).catch(console.error);
Output
{
  name: "Sadie Miller",
  type: "hardcore_ironman",
  overall: { rank: "5399", level: "1200", experience: "7164307" },
  attack: { rank: "4891", level: "64", experience: "448334" },
  defence: { rank: "3799", level: "64", experience: "435491" },
  strength: { rank: "4006", level: "70", experience: "749071" },
  hitpoints: { rank: "5029", level: "66", experience: "538854" },
  ranged: { rank: "9132", level: "48", experience: "88163" },
  prayer: { rank: "7234", level: "44", experience: "56690" },
  magic: { rank: "7309", level: "60", experience: "283069" },
  cooking: { rank: "8854", level: "59", experience: "257180" },
  woodcutting: { rank: "2869", level: "72", experience: "911090" },
  fletching: { rank: "8171", level: "56", experience: "190596" },
  fishing: { rank: "4647", level: "70", experience: "772902" },
  firemaking: { rank: "19938", level: "61", experience: "312150" },
  crafting: { rank: "6371", level: "51", experience: "121833" },
  smithing: { rank: "4682", level: "52", experience: "124557" },
  mining: { rank: "1486", level: "73", experience: "1016912" },
  herblore: { rank: "3221", level: "50", experience: "106477" },
  agility: { rank: "7425", level: "66", experience: "533348" },
  thieving: { rank: "6968", level: "52", experience: "126391" },
  slayer: { rank: "11707", level: "26", experience: "9100" },
  farming: { rank: "3831", level: "45", experience: "66951" },
  runecrafting: { rank: "12438", level: "14", experience: "2225" },
  hunter: { rank: "25687", level: "9", experience: "1000" },
  construction: { rank: "7707", level: "28", experience: "11923" },
  easyClueScrolls: { rank: "-1", score: "-1" },
  mediumClueScrolls: { rank: "-1", score: "-1" },
  clueScrolls: { rank: "-1", score: "-1" },
  bountyHunter: { rank: "-1", score: "-1" },
  bountyHunterRogues: { rank: "-1", score: "-1" },
  hardClueScrolls: { rank: "-1", score: "-1" },
  lastManStanding: { rank: "-1", score: "-1" },
  eliteClueScrolls: { rank: "-1", score: "-1" },
  masterClueScrolls: { rank: "-1", score: "-1" }
}

getPlayers([{ name, type }, ...])

Used to retrieve multiple players' hiscore entries.

createHiscoresInterface(axiosInstance)

Used to create a new interface using a custom instance of axios. Exposes getPlayer and getPlayers.

Example
const axios = require("axios");
const { hiscores } = require("osrs-api");

const hiscoresInterface = hiscores.createHiscoresInterface(axios.create());

Grand Exchange

getItem(itemId)

Used to retrieve an item's Grand Exchange details.

Example
const { grandExchange } = require("osrs-api");

grandExchange.getItem(2).then(console.log).catch(console.error);
Output
{
  item: {
    icon: "http://services.runescape.com/m=itemdb_oldschool/1522058952475_obj_sprite.gif?id=2",
    icon_large: "http://services.runescape.com/m=itemdb_oldschool/1522058952475_obj_big.gif?id=2",
    id: 2,
    type: "Default",
    typeIcon: "http://www.runescape.com/img/categories/Default",
    name: "Cannonball",
    description: "Ammo for the Dwarf Cannon.",
    current: { trend: "neutral", price: 166},
    today: { trend: "positive", price: "+2" },
    members: "true",
    day30: { trend: "negative", change: "-8.0%"},
    day90: { trend: "negative", change: "-11.0%"},
    day180: { trend: "negative", change: "-8.0%"}
  }
}

getGraph(itemId)

Used to retrieve an item's Grand Exchange price data for the last six months.

Example
const { grandExchange } = require("osrs-api");

grandExchange.getGraph(2).then(console.log).catch(console.error);
Output
{
  daily: {
    1506729600000: 186,
    // ...
    1522195200000: 166
  },
  average: {
    1506729600000: 185,
    // ...
    1522195200000: 169
  }
}

createGrandExchangeInterface(axiosInstance)

Used to create a new interface using a custom instance of axios. Exposes getItem and getGraph.

Example
const axios = require("axios");
const { grandExchange } = require("osrs-api");

const grandExchangeInterface = grandExchange.createGrandExchangeInterface(axios.create());

Constants

For convenience, a set of constants have been exposed for proper usage with this API. When indexing into objects generated by this API, using the proper constant exposed by this module is highly recommended.

Keys in this README will be kept up to date. Values will not be kept up to date.

skills

Valid skill names (including "overall") for use with the hiscores API.

Example
const { constants } = require("osrs-api");

console.log(constants.skills);
Output
{
  overall: "overall",
  attack: "attack",
  defence: "defence",
  strength: "strength",
  hitpoints: "hitpoints",
  ranged: "ranged",
  prayer: "prayer",
  magic: "magic",
  cooking: "cooking",
  woodcutting: "woodcutting",
  fletching: "fletching",
  fishing: "fishing",
  firemaking: "firemaking",
  crafting: "crafting",
  smithing: "smithing",
  mining: "mining",
  herblore: "herblore",
  agility: "agility",
  thieving: "thieving",
  slayer: "slayer",
  farming: "farming",
  runecrafting: "runecrafting",
  hunter: "hunter",
  construction: "construction"
}

minigames

Valid minigame names (including "overall") for use with the hiscores API.

Example
const { constants } = require("osrs-api");

console.log(constants.minigames);
Output
{
  easyClueScrolls: "easyClueScrolls",
  mediumClueScrolls: "mediumClueScrolls",
  clueScrolls: "clueScrolls",
  bountyHunter: "bountyHunter",
  bountyHunterRogues: "bountyHunterRogues",
  hardClueScrolls: "hardClueScrolls",
  lastManStanding: "lastManStanding",
  eliteClueScrolls: "eliteClueScrolls",
  masterClueScrolls: "masterClueScrolls"
}

playerTypes

Valid player types for use with the hiscores API.

Example
const { constants } = require("osrs-api");

console.log(constants.playerTypes);
Output
{
  normal: "normal",
  ironman: "ironman",
  ultimateIronman: "ultimate",
  hardcoreIronman: "hardcore_ironman",
  deadman: "deadman",
  seasonal: "seasonal"
}

hiscoreSkillEntryOrder

An array populated with the names of skills in the order they appear on the hiscores.

hiscoreMinigameEntryOrder

An array populated with the names of minigames in the order they appear on the hiscores.

ingameSkillOrder

An array populated with the names of skills in the order they appear in the ingame skill tab (ordered from left to right, up to down).

Future Plans/Features

  • Translate all numeric values into JavaScript numerics
  • Different forms of output for hiscores (({ skills: [], minigames: [] }) or ({ skills: {}, minigames: {} }))