Skip to content
Simon Sørensen edited this page Jun 2, 2023 · 12 revisions

bptf-prices

A Node.js wrapper for the Backpack.tf economy Web API.

Documentation

When you require() the module, the EconomyWrapper class is returned. This page lists all methods (properties are private) available from that class.

However, you'll first need to instantiate a new instance of the module and supply it with your Backpack.tf developer API key.

Below is a CommonJS example:

// Require the module 
const bptfprices = require('bptf-prices');
// and supplying your API key
const bptf = new bptfprices({ apiKey: 'XXXXXXXXXXXXXXXXXXXXXXXX' });

Methods

All methods support both callbacks and async/await.

Also, please note: Function parameters are all supplied in a single object. If one or more are omitted, the function resorts to its default values.

constructor (options)

  • options - An object containing valid bptf-prices constructor options.
    • apiKey - Your Backpack.tf API key (This option is required for performing all the requests).

Constructs a new EconomyWrapper instance.

getCurrencies ({ raw, callback })

  • raw - If set, modifies the raw value for the price index objects by allowing or preventing averaging behavior.
  • callback - Optional, called when a response is available. If omitted the function returns a promise.
    • error - An Error object on failure, or null on success.
    • response - The response object.

Returns a GetCurrenciesResponse object with Backpack.tf's internal currency data for Team Fortress 2.

getPriceHistory({ appid, item, quality, tradable, craftable, priceindex, callback })

  • appid - The app that owns the item (defaults to 440).
  • item - The item's base or market_hash_name (defaults to The Team Captain).
  • quality - The item's quality property (defaults to Unique).
  • tradable - The item's tradeable state (defaults to Tradable).
  • craftable - The item's craftable state (defaults to Craftable).
  • priceindex - The item's price index as a number (defaults to 0).
  • callback - Optional, called when a response is available. If omitted the function returns a promise.
    • error - An Error object on failure, or null on success.
    • response - The response object.

Returns a GetPriceHistoryResponse object with the price history corresponding to the item parameter.

getPrices({ raw, since, callback })

  • raw - If set, modifies the raw value for the price index objects by allowing or preventing averaging behavior.
  • since - If set, only returns prices that have a last_update value greater than or equal to this UNIX time.
  • callback - Optional, called when a response is available. If omitted the function returns a promise.
    • error - An Error object on failure, or null on success.
    • response - The response object.

Returns a GetPricesResponse object with the Team Fortress 2 price schema.

getSpecialItems({ appid, callback })

  • appid - The app that owns the item (defaults to 440).
  • callback - Optional, called when a response is available. If omitted the function returns a promise.
    • error - An Error object on failure, or null on success.
    • response - The response object.

Returns a GetSpecialItemsResponse object with Backpack.tf's internal item placeholders corresponding to the appid parameter.

Examples

For now, there are some examples available in the test directory.

Support

Feel free to create an issue if you need to report any bugs or have a suggestion for a new feature.