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-watch-api

v0.1.1

Published

NodeJS module to quickly and easily interact with the poe.watch API

Downloads

7

Readme

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])

| Param | Type | Default | Description | | --- | --- | --- | --- | | [options] | Object | | | | [options.autoUpdate] | boolean | true | Requests 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

| Param | Type | Description | | --- | --- | --- | | properties | Object | An object containing one or more properties of the item | | [properties.id] | number | poe.watch ID of the item | | [properties.name] | string | Item name | | [properties.type] | string | Base type | | [properties.frame] | number | Frame type | | [properties.tier] | number | Map tier | | [properties.lvl] | number | Level (e.g. gem level) | | [properties.quality] | number | Quality (e.g. gem quality) | | [properties.corrupted] | boolean | Whether the item is corrupted or not | | [properties.links] | number | Count of links | | [properties.ilvl] | number | Item level | | [properties.var] | string | Variation | | [properties.relic] | number | Whether the item is a relic or not. true always sets properties.frame to 9 | | [properties.icon] | string | Icon URL | | [properties.category] | string | Item category | | [properties.group] | string | Item 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

| Param | Type | Description | | --- | --- | --- | | properties | Object | An object containing one or more properties of the item | | [properties.id] | number | poe.watch ID of the item | | [properties.name] | string | Item name | | [properties.type] | string | Base type | | [properties.frame] | number | Frame type | | [properties.tier] | number | Map tier | | [properties.lvl] | number | Level (e.g. gem level) | | [properties.quality] | number | Quality (e.g. gem quality) | | [properties.corrupted] | boolean | Whether the item is corrupted or not | | [properties.links] | number | Count of links | | [properties.ilvl] | number | Item level | | [properties.var] | string | Variation | | [properties.relic] | number | Whether the item is a relic or not. true always sets properties.frame to 9 | | [properties.icon] | string | Icon URL | | [properties.category] | string | Item category | | [properties.group] | string | Item 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

| Param | Type | Description | | --- | --- | --- | | properties | Object | An object containing one or more properties of the league | | [properties.id] | number | ID of the league | | [properties.name] | string | League 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

| Param | Type | Default | Description | | --- | --- | --- | --- | | [count] | Number | max | The 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

| Param | Type | Default | Description | | --- | --- | --- | --- | | [type] | 'mean' | 'median' | 'mode' | 'quantity' | mean | Mean, median, mode or quantity | | [count] | Number | max | The 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

| Param | Type | Description | | --- | --- | --- | | league | string | number | Name 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