0.1.1 • Published 5 years ago

poe-watch-api v0.1.1

Weekly downloads
2
License
MIT
Repository
github
Last release
5 years ago

poe-watch-api

NPM version NPM Downloads NPM License

Getting Started

Install with npm:

$ npm install poe-watch-api

Integration:

const PoeWatch = require("poe-watch-api");

Example usage:

Before you can do something with data from the API, categories, leagues and itemdata must be updated. This happens automatically once you create a new PoeWatch object unless you set autoUpdate to false. If you want to start doing things as soon as possible you should consider using the ready event, which is emitted once the above data has been updated.

let poeWatch = new PoeWatch();

poeWatch.on("ready", () => {
  // Request data for a 6-linked relic Shavronne's Wrappings
  poeWatch.requestItem({name: "Shavronne's Wrappings", links: 6, relic: true})
  .then((item) => {
    // Get the sparkline of the median value of the last week in Standard league
    let medianSparkline = item.getPriceDataByLeague("Standard").getHistory().getSparkline("median", 7);
    console.log("Median value history of last week: " + medianSparkline.toString());
  })
  .catch((error) => {
    console.error("An error occurred", error);
  });
});

You can also update the data yourself by setting autoUpdate to false and using the .update() method.

let poeWatch = new PoeWatch({autoUpdate: false});

poeWatch.update()
.then(() => {
  return poeWatch.requestItem({name: "Exalted Orb"});
})
.then((item) => {
  let meanValue = item.getPriceDataByLeague("Standard").getMean();
  console.log("Exalted Orbs are currently worth " + meanValue + " Chaos Orbs in Standard league");
})
.catch((error) => {
  console.error("An error occurred", error);
});

Alternatively you can create a PoeWatch object and make sure it's ready with the .isReady() method if you need the API at a later time.

Classes

PoeWatch

Kind: global class

new PoeWatch(options)

ParamTypeDefaultDescription
optionsObject
options.autoUpdatebooleantrueRequests league, item data and category data from poe.watch when creating a new PoeWatch object

poeWatch.update() ⇒ Promise

Requests league, item data and category data from poe.watch and stores them

Kind: instance method of PoeWatch

poeWatch.requestLeagues() ⇒ Promise.<Object>

Requests league data from poe.watch

Kind: instance method of PoeWatch

poeWatch.requestItemdata() ⇒ Promise.<Object>

Requests item data data from poe.watch

Kind: instance method of PoeWatch

poeWatch.requestCategories() ⇒ Promise.<Object>

Requests category data from poe.watch

Kind: instance method of PoeWatch

poeWatch.requestItem(properties) ⇒ Promise.<Item>

Returns item data including price data for a specific item

Item data must be requested with .requestItemdata() or .update() before using this method

Kind: instance method of PoeWatch

ParamTypeDescription
propertiesObjectAn object containing one or more properties of the item
properties.idnumberpoe.watch ID of the item
properties.namestringItem name
properties.typestringBase type
properties.framenumberFrame type
properties.tiernumberMap tier
properties.lvlnumberLevel (e.g. gem level)
properties.qualitynumberQuality (e.g. gem quality)
properties.corruptedbooleanWhether the item is corrupted or not
properties.linksnumberCount of links
properties.ilvlnumberItem level
properties.varstringVariation
properties.relicnumberWhether the item is a relic or not. true always sets properties.frame to 9
properties.iconstringIcon URL
properties.categorystringItem category
properties.groupstringItem category group

poeWatch.getItemData(properties) ⇒ ItemData

Returns item data for a specific item

Item data must be requested with .requestItemdata() or .update() before using this method

Kind: instance method of PoeWatch

ParamTypeDescription
propertiesObjectAn object containing one or more properties of the item
properties.idnumberpoe.watch ID of the item
properties.namestringItem name
properties.typestringBase type
properties.framenumberFrame type
properties.tiernumberMap tier
properties.lvlnumberLevel (e.g. gem level)
properties.qualitynumberQuality (e.g. gem quality)
properties.corruptedbooleanWhether the item is corrupted or not
properties.linksnumberCount of links
properties.ilvlnumberItem level
properties.varstringVariation
properties.relicnumberWhether the item is a relic or not. true always sets properties.frame to 9
properties.iconstringIcon URL
properties.categorystringItem category
properties.groupstringItem category group

poeWatch.getLeague(properties) ⇒ League

Returns league data for a specific league

League data must be requested with .requestLeagues() or .update() before using this method

Only the most useful properties are listed below. You can use any property of a league from the poe.watch API though, please refer to the API structure here

Kind: instance method of PoeWatch

ParamTypeDescription
propertiesObjectAn object containing one or more properties of the league
properties.idnumberID of the league
properties.namestringLeague name

poeWatch.isUpdating() ⇒ boolean

Returns true if data is currently being updated

Kind: instance method of PoeWatch

poeWatch.isReady() ⇒ boolean

Returns true if all data is available and the API is ready to be used

Kind: instance method of PoeWatch

poeWatch.hasLeagues() ⇒ boolean

Returns true if league data is available

Kind: instance method of PoeWatch

poeWatch.hasItemData() ⇒ boolean

Returns true if item data is currently being updated

Kind: instance method of PoeWatch

poeWatch.hasCategories() ⇒ boolean

Returns true if category data is currently being updated

Kind: instance method of PoeWatch

"error"

Emitted when an error occurred while updating on creation. Only emitted when options.autoUpdate is set to true

Kind: event emitted by PoeWatch

"ready"

Emitted when all data has been requested successfully. Only emitted when options.autoUpdate is set to true

Kind: event emitted by PoeWatch

History

Kind: global class

history.getLast(count) ⇒ Array

Returns the latest count entries (days) of the history in an array

Kind: instance method of History

ParamTypeDefaultDescription
countNumbermaxThe count of the last entries (days) that should be returned. Defaults to the full history

history.getSparkline(type, count) ⇒ Array

Returns a sparkline, optionally only of the last count entries (days) in an array

Kind: instance method of History

ParamTypeDefaultDescription
type'mean' | 'median' | 'mode' | 'quantity'meanMean, median, mode or quantity
countNumbermaxThe count of the last entries (days) that should be returned. Defaults to the full history

Item ⇐ ItemData

Kind: global class
Extends: ItemData

item.getPriceData() ⇒ Array.<PriceData>

Returns price data for every league

Kind: instance method of Item
Returns: Array.<PriceData> - Array of PriceData objects for each league holding the price data for the item

item.getPriceDataByLeague(league) ⇒ PriceData

Returns price data for a specific league

Kind: instance method of Item
Returns: PriceData - PriceData object holding the price data for the item

ParamTypeDescription
leaguestring | numberName or ID of the league

item.getId() ⇒ number

Returns the poe.watch ID of the item

Kind: instance method of Item

item.getName() ⇒ string

Returns the name of the item

Kind: instance method of Item

item.getType() ⇒ string

Returns the type of the item

Kind: instance method of Item

item.getFrame() ⇒ string

Returns the frametype of the item

Kind: instance method of Item

item.getTier() ⇒ string

Returns the map tier of the item

Kind: instance method of Item

item.getLevel() ⇒ string

Returns the level of the item

Kind: instance method of Item

item.getQuality() ⇒ string

Returns the quality of the item

Kind: instance method of Item

item.isCorrupted() ⇒ string

Returns true if the item is corrupted

Kind: instance method of Item

item.getLinks() ⇒ number

Returns the links of the item

Kind: instance method of Item

item.getItemLevel() ⇒ number

Returns the item level of the item

Kind: instance method of Item

item.getVariation() ⇒ string

Returns the variation of the item

Kind: instance method of Item

item.getIcon() ⇒ string

Returns the URL to the icon of the item

Kind: instance method of Item

item.getCategory() ⇒ string

Returns the category of the item

Kind: instance method of Item

item.getGroup() ⇒ string

Returns the category group of the item

Kind: instance method of Item

ItemData

Kind: global class

itemData.getId() ⇒ number

Returns the poe.watch ID of the item

Kind: instance method of ItemData

itemData.getName() ⇒ string

Returns the name of the item

Kind: instance method of ItemData

itemData.getType() ⇒ string

Returns the type of the item

Kind: instance method of ItemData

itemData.getFrame() ⇒ string

Returns the frametype of the item

Kind: instance method of ItemData

itemData.getTier() ⇒ string

Returns the map tier of the item

Kind: instance method of ItemData

itemData.getLevel() ⇒ string

Returns the level of the item

Kind: instance method of ItemData

itemData.getQuality() ⇒ string

Returns the quality of the item

Kind: instance method of ItemData

itemData.isCorrupted() ⇒ string

Returns true if the item is corrupted

Kind: instance method of ItemData

itemData.getLinks() ⇒ number

Returns the links of the item

Kind: instance method of ItemData

itemData.getItemLevel() ⇒ number

Returns the item level of the item

Kind: instance method of ItemData

itemData.getVariation() ⇒ string

Returns the variation of the item

Kind: instance method of ItemData

itemData.getIcon() ⇒ string

Returns the URL to the icon of the item

Kind: instance method of ItemData

itemData.getCategory() ⇒ string

Returns the category of the item

Kind: instance method of ItemData

itemData.getGroup() ⇒ string

Returns the category group of the item

Kind: instance method of ItemData

League

Kind: global class

league.getId() ⇒ number

Returns the ID of the league

Kind: instance method of League

league.getName() ⇒ string

Returns the internal name of the league

Kind: instance method of League

league.getDisplayName() ⇒ string

Returns the display name of the league

Kind: instance method of League

league.isHardcore() ⇒ boolean

Returns true if the league is a hardcore league

Kind: instance method of League

league.isUpcoming() ⇒ boolean

Returns true if the league has not started yet

Kind: instance method of League

league.isActive() ⇒ boolean

Returns true if the league is currently active

Kind: instance method of League

league.isEvent() ⇒ boolean

Returns true if the league is an event league

Kind: instance method of League

league.getStart() ⇒ string

Returns the time the league starts

Kind: instance method of League
Returns: string - Time in YYYY-MM-DDThh:mm:ss.sTZD format

league.getEnd() ⇒ string

Returns the time the league ends

Kind: instance method of League
Returns: string - Time in YYYY-MM-DDThh:mm:ss.sTZD format

league.getDuration() ⇒ Object

Returns an object containing the total, elapsed and remaining seconds of the league

Kind: instance method of League

PriceData

Kind: global class

priceData.getLeague() ⇒ League

Returns the league information

Kind: instance method of PriceData

priceData.getMean() ⇒ number

Returns the mean value of the item

Kind: instance method of PriceData

priceData.getMedian() ⇒ number

Returns the median value of the item

Kind: instance method of PriceData

priceData.getMode() ⇒ number

Returns the mode value of the item

Kind: instance method of PriceData

priceData.getMin() ⇒ number

Returns the minimum value of the item

Kind: instance method of PriceData

priceData.getMax() ⇒ number

Returns the maximum value of the item

Kind: instance method of PriceData

priceData.getExalted() ⇒ number

Returns the value of the item in Exalted Orbs

Kind: instance method of PriceData

priceData.getCount() ⇒ number

Returns the total count of listed items

Kind: instance method of PriceData

priceData.getQuantity() ⇒ number

Returns the count of currently listed items

Kind: instance method of PriceData

priceData.getHistory() ⇒ History

Returns the price history of the item

Kind: instance method of PriceData