Skip to content
Kristjan Kirpu edited this page Feb 26, 2016 · 13 revisions

Examples

There are some examples available in the examples directory.

Steam Market Manager

SteamMarketManager is the root object that node-steam-market-manager exports. You'll need to instantiate it.

Example

var SteamMarketManager = require('steam-market-manager');
var market = new SteamMarketManager({
    "appID": 730
});

Constructor([options])

  • options - Optional. An object containing any or all of the following options:
    • appID - Optional. Will define the default application id when fetching market prices.
    • currency - Optional. Specifies in which currency the values should be. Defaults to EUR, you can see all the available currencies here.
    • keepCurrencySymbols - Optional. Steam by default returns currency symbols too (ex. 12,99€). This defaults to false and will remove the symbols.
    • enableWebApi - Optional. Defaults to false, if true then it will enable the WebApi using Express.
    • webApiPort - Optional. Defaults to 1337. This is the port the WebApi will be listening on.
    • webApiSeperator - Optional. Defaults to !N!. This seperates the items when calling /items/:names.
    • cache - Optional. Defaults to false. Sets the time in seconds for how long to cache the item. Creates a cache.json file with all the items queried.
      • A good idea would be to set the cache time to 3600 seconds (1 hour) and call getAllItems() method.

Methods

getItem(options, callback)

  • name - Required. The market_hash_name for the item. (Ex. "StatTrak™ CZ75-Auto | The Fuschia Is Now (Well-Worn)" without quotes)
  • currency - Optional. Will default to Constructor's value if not set.
  • appID - Optional. Will default to Constructor's value if not set. Required if you did not set the value in Constructor.
  • callback - Required.
    • err - null on success.
    • item - Steam JSON response.

getItems(options, callback)

  • names - Required. Object populated with item market_hash_name's
  • currency - Optional. Will default to Constructor's value if not set.
  • appID - Optional. Will default to Constructor's value if not set. Required if you did not set the value in Constructor.
  • callback - Required.
    • err - null on success.
    • items - Steam JSON responses.

getAllItems(options, callback)

All returned values are in USD. If you wish to get EUR values etc.. you'll have to figure out that by yourself.

  • format - Optional. Will default to JSON.
  • appID - Optional. Will default to Constructor's value if not set. Required if you did not set the value in Constructor.
  • callback - Required.
    • err - null on success.
    • items - Backpack.tf response.

getInventory(options, callback)

Gets the user inventory using node-steamcommunity and adds the option to append priceData to the inventory items.

  • steamid - Required. Steam2 rendered ID, a Steam3 rendered ID or a SteamID64.
  • contextID - Required. Context within the app you want to load.
  • appID - Optional. Will default to Constructor's value if not set. Required if you did not set the value in Constructor.
  • tradableOnly - Optional. Defaults to false. Fetches only the items that can be traded.
  • getWithPrices - Optional. Defaults to false. Adds prices to items.
    • When dealing with large inventories (20+ items) I suggest you to use getAllItems before fetching with prices. Steam has an API limit for priceoverview.
  • callback - Required.
    • err - null on success. Returns an Error object according to node-steamcommunity Wiki.
    • inventory - An array containing CEconItem objects for the user's inventory items

WebApi

/item/:name

Fetches item's price from Market using getItem method. Uses the default constructor values.

/items/:names

Fetches multiple items prices from Market using getItems method. Uses the default constructor values.

/items/all

Fetches all items and their prices from Backpack.tf using getAllItems method. Uses the default constructor values.