A NodeJS library for doing everything OSRS related. Access the OSRS hiscores, news, worlds, wiki, items, and more.
- Hiscores
- Items
- News
- Worlds
- Wiki
- Polls
- Clues (Clue Scroll Simulating)
- Monsters (Monster killing simulating)
- Utilies
import { Hiscores } from 'oldschooljs';
const lynxTitan = await Hiscores.fetch('Lynx Titan').catch(console.error);
console.log(lynxTitan);
Possible account types: 'normal' | 'ironman' | 'ultimate' | 'hardcore' | 'deadman' | 'seasonal'
const ironHyger = await Hiscores.fetch('Iron Hyger', { type: 'ironman' }).catch(console.error);
console.log(ironHyger);
import { Items } from 'oldschooljs';
You can call this to have all items fully available for usage (via .get
) at any time without needing to fetch individual items. Items change at most once a week, so you should probably only call this once at startup, and then once every few days.
await Items.fetchAll();
This will fetch the latest version of a particular item.
const twistedBow = await Items.fetch(20997);
if (twistedBow) console.log(twistedBow);
const twistedBow = Items.get(20997);
if (twistedBow) console.log(twistedBow);
const dragonDagger = Items.get('dragon dagger(p++)');
if (dragonDagger) console.log(dragonDagger);
const dragonItems = Items.filter(item => item.name.includes('Dragon'));
console.log(`Found ${dragonItems.size} Dragon Items!`);
for (const item of dragonItems.values()) {
console.log(item.name);
}
import { News } from 'oldschooljs';
Be careful with fetching news articles too often, as the website will ratelimit you after roughly 30 requests in a short period. Whenever a fetch is done, the News
collection will have any new articles cached.
Rather than fetching articles on demand, you may want to
const recentArticles = await News.fetchRecent();
const mostRecentArticle = recentArticles.first();
const monthOfArticles = await News.filter(article => article.year === 2018 && article.month === 12);
console.log(`There were ${monthOfArticles.size} articles in that month.`);
This will fetch news articles for a specific month, i.e it wont be cached. In most cases you can just use News.filter()
instead of this.
const monthOfArticles = await News.fetchMonth({ year: 2018, month: 12 });
console.log(`There were ${monthOfArticles.size} articles in that month.`);
If you want this to be up to 100% up to date, you need to call News.fetchNewArticles()
to fetch newly released articles that aren't cached by oldschooljs.
for (const article of News.values()) {
console.log(article);
}
import { Worlds } from 'oldschooljs';
You must call this atleast once to be able to use Worlds
. To keep worlds up to date, fetching once at startup and then once every few days is enough. If you need an up to date playercount of worlds, you can call it more often or on demand.
await Worlds.fetch();
You can use either form of numbering, giving 301
and 1
will both give you World 1.
const worldOne = Worlds.get(301);
const worldTwo = Worlds.get(2);
const australianWorlds = Worlds.filter(world => world.location === 'Australia');
console.log(`There are ${australianWorlds.size} Australian Worlds!`);
for (const world of Worlds.values()) {
console.log(world);
}
import { Wiki } from 'oldschooljs';
const searchResults = await Wiki.search('Twisted bow');
if (searchResults.length === 0) console.log('Found no results');
else console.log(`Search found these pages: ${searchResults.map(page => page.title)}`);
const randomPages = await Wiki.random(10);
console.log(`Search found these pages: ${searchResults.map(page => page.title)}`);
const twistedBowPage = await Wiki.fetchPage(82098);
console.log(twistedBowPage);
import { Polls } from 'oldschooljs';
for (const poll of Polls.values()) {
console.log(poll.title);
}
const pollsFrom2013 = Polls.filter(poll => new Date(poll.datePosted).getFullYear() === 2013);
console.log(pollsFrom2013.size);
import { Util } from 'oldschooljs';
console.log(Util.isValidUsername(username)); // true
KMB Syntax is how numbers are often formatted in runescape, for example: 5k, 1.5m, 5m, 1b, etc.
Util.toKMB(5); // '5'
Util.toKMB(1000); // '1k'
Util.toKMB(1000000); // '1m'
Util.toKMB(1200000000); // '1.2b'
Util.fromKMB('5'); // 5
Util.fromKMB('1k'); // 1000
Util.fromKMB('1m'); // 1000000
Util.fromKMB('1.2b'); // 1200000000
Allows you to simulate opening clue scroll caskets. The rewards are returned in a format containing the item ID and the quantity.
import { Clues } from 'oldschooljs';
console.log(Clues.Beginner.open(1));
console.log(Clues.Master.open(5));
console.log(Clues.Elite.open());
Allows you to simulate killing monsters. The loot is returned in a format containing the item ID and the quantity.
import { Monsters } from 'oldschooljs';
console.log(Monsters.LuckyImp.roll());
- Ability to ping worlds?
- CrystalMathLabs
- Simulating: killing monsters, opening clue scrolls, pets (like in osbot)
- Quests (e.g. containing all wiki data on quests)
- fetch wiki page by item ID?