@sulphate/steamprice
v1.1.0
Published
A simple library that uses various APIs to get prices for CSGO items.
Readme
Uses Dr. McKay's steamcommunity package (for development use) and unofficial Steam
APIs (API keys required) to get prices for CS:GO items.
Installation
npm install @sulphate/steamprice
About
This package allows you to get prices for one, two or all of the items on CS:GO, in a few lines of code.
Usage
The main file exports a PricingMethod constant, to decide which method you are using,
and a PriceManager class which you can use to fetch the prices.
- Require/Import the package:
// ES6
import { PricingMethod, PriceManager } from "@sulphate/steamprice";
// ES5
const { PricingMethod, PriceManager } = require("@sulphate/steamprice");Available Pricing Methods
Note: Only the PricingMethod.STEAM_COMMUNITY is currently functional, others will
be added in the near future.
PricingMethod.STEAM_COMMUNITY- Uses an instance of thesteamcommunitypackage to fetch the price of items from the Steam Community Market.PricingMethod.STEAMAPI_IO_KEY- Uses an API key to communicate with the SteamAPI.io pricing endpoints. Note: This API may have additional terms that you need to comply with.PricingMethod.STEAMLYTICS_KEY- Uses an API key to communicate with the Steamlytics.xyz (CS:GO) pricing endpoints.
Example Usage
This example uses the STEAM_COMMUNITY pricing method to fetch the price of an item.
import { PricingMethod, PriceManager } from "@sulphate/steamprice";
// community is a logged-in instance of steamcommunity.
let method = PricingMethod.STEAM_COMMUNITY;
let pManager = new PriceManager(method, community);
let itemHashName = "MP7 | Urban Hazard (Minimal Wear)";
pManager.getPriceForItem(itemHashName)
.then(price => {
// Price is in cents.
console.log(`Price for ${itemHashName}: $${ price.price / 100 }`);
})
.catch(err => {
console.log(err.message);
});The available methods you can use are:
getPriceForItem(marketHashName)- Returns a promise, which will resolve to the price of the given item.getPricesForAllItems()- Returns an object with market hash names as keys with the price of every item for CS:GO. Does not work with theSTEAM_COMMUNITYpricing method.
