poe-watch-api
v0.1.1
Published
NodeJS module to quickly and easily interact with the poe.watch API
Downloads
13
Maintainers
Readme
poe-watch-api
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
- PoeWatch
- new PoeWatch([options])
- .update() ⇒ Promise
- .requestLeagues() ⇒ Promise.<Object>
- .requestItemdata() ⇒ Promise.<Object>
- .requestCategories() ⇒ Promise.<Object>
- .requestItem(properties) ⇒ Promise.<Item>
- .getItemData(properties) ⇒ ItemData
- .getLeague(properties) ⇒ League
- .isUpdating() ⇒ boolean
- .isReady() ⇒ boolean
- .hasLeagues() ⇒ boolean
- .hasItemData() ⇒ boolean
- .hasCategories() ⇒ boolean
- "error"
- "ready"
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
- .getSparkline([type], [count]) ⇒ Array
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 ⇐ ItemData
- .getPriceData() ⇒ Array.<PriceData>
- .getPriceDataByLeague(league) ⇒ PriceData
- .getId() ⇒ number
- .getName() ⇒ string
- .getType() ⇒ string
- .getFrame() ⇒ string
- .getTier() ⇒ string
- .getLevel() ⇒ string
- .getQuality() ⇒ string
- .isCorrupted() ⇒ string
- .getLinks() ⇒ number
- .getItemLevel() ⇒ number
- .getVariation() ⇒ string
- .getIcon() ⇒ string
- .getCategory() ⇒ string
- .getGroup() ⇒ string
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
- .getName() ⇒ string
- .getType() ⇒ string
- .getFrame() ⇒ string
- .getTier() ⇒ string
- .getLevel() ⇒ string
- .getQuality() ⇒ string
- .isCorrupted() ⇒ string
- .getLinks() ⇒ number
- .getItemLevel() ⇒ number
- .getVariation() ⇒ string
- .getIcon() ⇒ string
- .getCategory() ⇒ string
- .getGroup() ⇒ string
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
- .getName() ⇒ string
- .getDisplayName() ⇒ string
- .isHardcore() ⇒ boolean
- .isUpcoming() ⇒ boolean
- .isActive() ⇒ boolean
- .isEvent() ⇒ boolean
- .getStart() ⇒ string
- .getEnd() ⇒ string
- .getDuration() ⇒ Object
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
- .getMean() ⇒ number
- .getMedian() ⇒ number
- .getMode() ⇒ number
- .getMin() ⇒ number
- .getMax() ⇒ number
- .getExalted() ⇒ number
- .getCount() ⇒ number
- .getQuantity() ⇒ number
- .getHistory() ⇒ History
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