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

poe-ninja-api-manager

v0.7.0

Published

Access item data easily and update, save and load data from poe.ninja with NodeJS

Downloads

33

Readme

poe-ninja-api-manager

NPM version NPM Downloads NPM License

Contents

Getting Started

Install with npm:

$ npm install poe-ninja-api-manager

Example usage:

var NinjaAPI = require("poe-ninja-api-manager");

var ninjaAPI = new NinjaAPI({
  league: "Standard"
});

// Update data, then save data, then get item data for Atziri"s Splendour, 5 link, Energy Shield variant
ninjaAPI.update()
.then((result) => {
  console.log("Updated data, here are the results of the requests:", result);
  return ninjaAPI.save();
})
.then((success) => {
  console.log("Saved data", success);
  return ninjaAPI.getItem("Atziri's Splendour", {links: 5, variant: "ES"});
})
.then((item) => {
  return console.log("An item matching the query was found", item);
})
.catch((err) => {
  console.log(err);
});

NinjaAPI

Kind: global class

new NinjaAPI([options])

Creates a new NinjaAPI object

| Param | Type | Default | Description | | --- | --- | --- | --- | | [options] | Object | | An optional options object | | [options.league] | string | "Standard" | League that should be used as default | | [options.path] | string | "./" | Path where data should be saved | | [options.dataFile] | string | "ninjaData.json" | File in which data should be saved |

ninjaAPI.update([options]) ⇒ Promise

Updates data from poe.ninja for a specific league.

Kind: instance method of NinjaAPI
Fulfil: Array - An array of objects containing the requested data of each API
Reject: Error - The error.message contains information about why the promise was rejected

| Param | Type | Default | Description | | --- | --- | --- | --- | | [options] | Object | | An optional options object | | [options.league] | string | "Standard" | League that should be updated | | [options.delay] | string | 200 | Delay between API calls |

ninjaAPI.getItem(name, [options]) ⇒ Promise

Returns data for an item from the currently loaded poe.ninja data object. The returned item object is the same you'd receive from poe.ninja, but it has an additional property apiType. The optional options do no apply for currency items, except for options.league.

Kind: instance method of NinjaAPI
Fulfil: Array - An array containing the matching item as an object. If you receive multiple objects, please open an issue.
Reject: Error - The error.message contains information about why the promise was rejected

| Param | Type | Default | Description | | --- | --- | --- | --- | | name | String | | Name of the item | | [options] | Object | | An optional options object | | [options.league] | string | "Standard" | League that should be searched | | [options.links] | string | 0 | Links the item should have | | [options.variant] | string | null | Variant of the item. If no variant is specified, any variant of the item will be returned, but preferably the default (null variant) of the item | | [options.fallbackVariant] | string | null | If a variant was specified but not found, try to find this instead. Useful for defaulting gems to the level 20 variant | | [options.relic] | string | false | Set to true for the relic version of the item | | [options.baseType] | string | null | Base type of the item. Is ignored if not specified |

ninjaAPI.getCurrencyDetails(name) ⇒ object

Returns an object containing details about a currency item. Returns an empty object if no data is available for the specified currency name.

Kind: instance method of NinjaAPI

| Param | Type | Description | | --- | --- | --- | | name | string | Name of the currency |

ninjaAPI.hasData([league]) ⇒ boolean

Returns true if any poe.ninja data is available. This means that it has been loaded or updated before calling this method.

Kind: instance method of NinjaAPI

| Param | Type | Description | | --- | --- | --- | | [league] | string | By setting a league, true will be returned if there's data for this league |

ninjaAPI.getLeague() ⇒ string

Returns the league that is currently set as default.

Kind: instance method of NinjaAPI

ninjaAPI.setLeague(league)

Sets a league as default.

Kind: instance method of NinjaAPI

| Param | Type | Description | | --- | --- | --- | | league | string | League that should be set as default |

ninjaAPI.load() ⇒ Promise

Loads previously saved data from file.

Kind: instance method of NinjaAPI
Fulfil: boolean - true if the data was loaded successfully
Reject: Error - The error.message contains information about why the promise was rejected

ninjaAPI.save() ⇒ Promise

Saves the currently loaded or updated data to file.

Kind: instance method of NinjaAPI
Fulfil: boolean - true if the data was saved successfully
Reject: Error - The error.message contains information about why the promise was rejected

ninjaAPI.isUpdating() ⇒ boolean

Returns true if data is currently being updated

Kind: instance method of NinjaAPI