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

csgo-market

v1.5.2

Published

Module to get pricing data for CS:GO weapon skins from Steam Community Market

Downloads

24

Readme

CSGO-Market

Simplified CSGO skin pricing API

Straight from Steam's community market

Use case:

var csgomarket = require('csgo-market');

csgomarket.getSinglePrice('AK-47', 'Vulcan', 'Factory New', null, function (err, data) {

  if (err) {
    console.error('ERROR', err);
  } else {
    console.log(data);
  }

});

// If you want to disable strictNameMode.
csgomarket.strictNameMode = false;

// Notice the missing '-' in AK 47. With strictNameMode off it will internally swap to 'AK-47'.
csgomarket.getSinglePrice('AK 47', 'Vulcan', 'Factory New', null, function (err, data) {

  if (err) {
    console.error('ERROR', err);
  } else {
    console.log(data);
  }

});

Example output from above code (prices will always return in USD):

{
  "success": true,
  "lowest_price": "$80.50",
  "volume": "48",
  "median_price": "$80.01",
  "wep": "AK-47",
  "skin": "Vulcan",
  "wear": "Factory New",
  "stattrak": false
}
  • Lowest price: $80.50
  • Median price: $80.01
  • 48 sold/bought on the market

Methods

Each function returns data from the Steam market to callback with 2 arguments (err, data) where data is the response if successful, otherwise, err will be populated with a message.

getSinglePrice(wep, skin, wear, stattrak, callback)

  • wep: Name of the weapon to be requested. Ex: 'AK-47'.
  • skin: Name of the skin to be requested. Ex: 'Vulcan'.
  • wear: Wear of the skin to be requested. These options are available: Factory New, Minimal Wear, Field-Tested, Well-Worn, and Battle-Scarred. Defaults to 'Field-Tested' but a Levenshtein distance will be used to ensure a match.
  • stattrak: Boolean which signifies if you want StatTrak to be included in the request or not. Defaults to false
  • callback: Callback function which returns the request data. function(err, data).

getSingleKnifePrice(knife, skin, wear, stattrak, callback)

  • knife: Name of the knife to be requested. Ex: 'Karambit'.
  • skin: Name of the skin to be requested. Ex: 'Crimson Web'. Note: If skin is set to null then it will request the version of the Knife with no skin. example of a knife with no skin
  • wear: Wear of the skin to be requested. These options are available: Factory New, Minimal Wear, Field-Tested, Well-Worn, and Battle-Scarred. Defaults to 'Field-Tested' but a Levenshtein distance will be used to ensure a match. Note: If skin is set to null wear will also be set to null.
  • stattrak: Boolean which signifies if you want StatTrak to be included in the request or not. Defaults to false
  • callback: Callback function which returns the request data. function(err, data).

getSingleStickerPrice(stickerName, foil, callback)

  • stickerName: Name of the Sticker to be requested Note: Do not include the initial 'Sticker | ' infront of the sticker name. Also, do not include '(Foil)' within the name. Ex: 'Robo' or 'kennyS | Cologne 2015'.
  • foil: Boolean which signifies if you want the (Foil) option included in the request. Note: Not all stickers have foil counterparts.
  • callback: Callback function which returns the request data. function(err, data).

getSingleKeyPrice(key, callback)

  • key: Name of the key to be requested. Supports any Case Key and the eSports key. Does not support capsule keys currently. Example strings you can pass in: 'Chroma', 'Winter Offensive' or 'eSports'. 'Key' or 'Case Key' do not need to be added to the name.

  • callback: Callback function which returns the request data. function(err, data).

Asyncrhonous Methods

getSinglePriceAsync(wep, skin, wear, statrak)

Same parameters minus the callback as the non-async version. Promisified version of the getSinglePrice method (Example usage below).

getSingleKnifePriceAsync(knife, skin, wear, stattrak)

Same parameters minus the callback as the non-async version. Promisified version of the getSingleKnifePrice method.

getSingleStickerPriceAsync(stickerName, foil)

Same parameters minus the callback as the non-async version. Promisified version of the getSingleStickerPrice method.

getSingleKeyPriceAsync(key)

Same parameters minus the callback as the non-async version. Promisified version of the getSingleKeyPrice method.

Use case:

var csgomarket = require('csgo-market');
var Q = require('q');

var wears = ['Factory New', 'Minimal Wear',
  'Field-Tested', 'Well-Worn', 'Battle-Scarred'];

var data = {
  prices : [{
    weapon : "AWP",
    cached : false,
    skins : ['Asiimov', 'BOOM', 'Man-o\'-war'],
    skinData : {}
  }]
}

var getPrice = function(theData) {
  var promises = [];
  theData.skins.forEach(function(skin) {
    theData.skinData[skin] = {};
    wears.forEach(function(wear) {
      promises.push(csgomarket.getSinglePriceAsync(theData.weapon, skin, wear, false).then(function(data) {
        theData.skinData[skin][wear] = data;
      }));
    });
  });
  return Q.allSettled(promises).then(function() {
    return theData;
  });
}

getPrice(data.prices[0]).then(function(results) {
  // Do something with returned results here.
})

NOTE:

Capitalization is important for passed in values. If you are unsure of the exact name/spelling/capitilization/punctuation of a weapon and/or skin I highly recommend checking the community market as a reference or turning off strictNameMode by using csgomarket.strictNameMode = false;. Turning strictNameMode off will attempt to match a passed in string with a Weapon or Knife that exists in the game if the string is not formatted correctly. Does not affect passed in Key, Sticker, or Skin names.

Main goals to add in the near future:

  • Method for all wears given a particular gun and skin or knife and skin.

This module is still under-development and this is just the first iteration.

If you have any suggestions I am open to add additional functionality! I'd like to keep it small, but I'd love feedback. Email me at [email protected]