poe-ninja-api-manager
Contents
Getting Started
Install with npm:
$ npm install poe-ninja-api-manager
Example usage:
var NinjaAPI = ; var ninjaAPI = league: "Standard"; // Update data, then save data, then get item data for Atziri"s Splendour, 5 link, Energy Shield variantninjaAPI;
NinjaAPI
Kind: global class
- NinjaAPI
- new NinjaAPI([options])
- .update([options]) ⇒
Promise
- .getItem(name, [options]) ⇒
Promise
- .getCurrencyDetails(name) ⇒
object
- .hasData([league]) ⇒
boolean
- .getLeague() ⇒
string
- .setLeague(league)
- .load() ⇒
Promise
- .save() ⇒
Promise
- .isUpdating() ⇒
boolean
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 |
Promise
ninjaAPI.update([options]) ⇒ 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 |
Promise
ninjaAPI.getItem(name, [options]) ⇒ 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 |
object
ninjaAPI.getCurrencyDetails(name) ⇒ 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 |
boolean
ninjaAPI.hasData([league]) ⇒ 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 |
string
ninjaAPI.getLeague() ⇒ 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 |
Promise
ninjaAPI.load() ⇒ 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
Promise
ninjaAPI.save() ⇒ 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
boolean
ninjaAPI.isUpdating() ⇒ Returns true
if data is currently being updated
Kind: instance method of NinjaAPI