poe-ninja-api-manager

0.7.0 • Public • Published

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

Package Sidebar

Install

npm i poe-ninja-api-manager

Weekly Downloads

2

Version

0.7.0

License

MIT

Unpacked Size

33.3 kB

Total Files

6

Last publish

Collaborators

  • klayver