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-trade-stats

v0.2.9

Published

A simple, typed API wrapper for Grand Exchange. Includes daily trade volume data. Wiki | Official API | OSRSbox | Scraped trade volume

Downloads

53

Readme

Node library which scrapes trade volume from the official grand exchange page, alongside wrapping around common APIs.

Importing the library

Using NPM

import * as OSRS from 'osrs-trade-stats';

Table Of Contents

Usage

Getting item IDs used for queries

This package comes with an item list which can be used to quickly access item IDs.

console.log(OSRS.ITEMS_LIST.Abyssal_whip);

output:

4151

Getting Data

:warning: Do not spam requests to the APIs: The services may time you out!

Trade Volume Data (OSRS's grand exchange graphs)

(Not available on the official OSRS API) This will return trade volume data from the official website.

const data = await OSRS.getTradeVolume(4151);
console.log(data);

Output:

  // ...
  {
    tradeVolume: 1616,
    date: 2020-09-19T23:00:00.000Z,
    dateString: '9/20/2020',
    priceAverage: 2670124,
    priceDaily: 2659245
  },
  {
    tradeVolume: 3072,
    date: 2020-09-20T23:00:00.000Z,
    dateString: '9/21/2020',
    priceAverage: 2669895,
    priceDaily: 2687489
  },
  {
    tradeVolume: 6565,
    date: 2020-09-21T23:00:00.000Z,
    dateString: '9/22/2020',
    priceAverage: 2669650,
    priceDaily: 2678354
  },
  //... 80 more items

Official OSRS API

Bare bones OSRS API that is publicly available.

const itemData = await OSRS.getFromOfficialAPI(OSRS.ITEMS_LIST.Abyssal_whip);
console.log(itemData);

Output:

{
  icon: 'https://secure.runescape.com/m=itemdb_oldschool/1607602554160_obj_sprite.gif?id=4151',
  icon_large: 'https://secure.runescape.com/m=itemdb_oldschool/1607602554160_obj_big.gif?id=4151',
  id: 4151,
  type: 'Default',
  typeIcon: 'https://www.runescape.com/img/categories/Default',
  name: 'Abyssal whip',
  description: 'A weapon from the abyss.',
  current: { trend: 'neutral', price: '2.9m' },
  today: { trend: 'negative', price: '- 10.9k' },
  members: 'true',
  day30: { trend: 'positive', change: '+4.0%' },
  day90: { trend: 'positive', change: '+9.0%' },
  day180: { trend: 'positive', change: '+1.0%' }
}

OSRS Wiki API

Get long term trading data from the wiki.

const tradeData = await OSRS.getFromWiki(4151);
console.log(tradeData); // tradeVolume undefined as tracking began in 2018
console.log(tradeData[tradeData.length - 10]); // this should have some tradeVolume data

Output:

// ...
  { // Old data
    date: 1430006400000,
    dateString: '04/26/2015',
    priceDaily: 2488963,
    tradeVolume: undefined
  },
  {
    date: 1430092800000,
    dateString: '04/27/2015',
    priceDaily: 2571803,
    tradeVolume: undefined
  }, // ... 1980 more times


{ // More recent data
  date: 1607644800000,
  dateString: '12/11/2020',
  priceDaily: 2908135,
  tradeVolume: 8743
}

osrsbox API

const tradeData = await OSRS.getFromOsrsBox(4151);
console.log(tradeData);

Output:

{
  id: 4151,
  name: 'Abyssal whip',
  incomplete: false,
  members: true,
  tradeable: true,
  tradeable_on_ge: true,
  stackable: false,
  stacked: null,
  noted: false,
  noteable: true,
  linked_id_item: null,
  linked_id_noted: 4152,
  linked_id_placeholder: 14032,
  placeholder: false,
  equipable: true,
  equipable_by_player: true,
  equipable_weapon: true,
  cost: 120001,
  lowalch: 48000,
  highalch: 72000,
  weight: 0.453,
  buy_limit: 70,
  quest_item: false,
  release_date: '2005-01-26',
  duplicate: false,
  examine: 'A weapon from the abyss.',
  icon: 'iVBORw0KGgoAAAANSUhEUg', // ...
  wiki_name: 'Abyssal whip',
  wiki_url: 'https://oldschool.runescape.wiki/w/Abyssal_whip',
  wiki_exchange: 'https://oldschool.runescape.wiki/w/Exchange:Abyssal_whip',
  equipment: {
    attack_stab: 0,
    attack_slash: 82,
    attack_crush: 0,
    attack_magic: 0,
    attack_ranged: 0,
    defence_stab: 0,
    defence_slash: 0,
    defence_crush: 0,
    defence_magic: 0,
    defence_ranged: 0,
    melee_strength: 82,
    ranged_strength: 0,
    magic_damage: 0,
    prayer: 0,
    slot: 'weapon',
    requirements: { attack: 70 }
  },
  weapon: {
    attack_speed: 4,
    weapon_type: 'whips',
    stances: [ [Object], [Object], [Object] ]
  }
}

CORS

Some of the endpoints may require a cors proxy, such as cors anywhere. To supply this to, simply pass it in as a parameter.

const tradeData = await API.getTradeVolume(
  4151,
  'https://cors-anywhere.herokuapp.com/',
);

This should now work in the browser.