GithubHelp home page GithubHelp logo

svikashk / poe-ninja-api-manager Goto Github PK

View Code? Open in Web Editor NEW

This project forked from klayver/poe-ninja-api-manager

0.0 0.0 0.0 256 KB

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

License: MIT License

JavaScript 100.00%

poe-ninja-api-manager's Introduction

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

poe-ninja-api-manager's People

Contributors

klayver avatar damianpoole avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.