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

steam-web

v0.7.0

Published

A wrapper for the Steam Web API.

Downloads

27,323

Readme

steam-web

Full Documentation on GH Pages

A node.js wrapper for Valve's Steam Web API. Also supports the methods provided for TF2/TF2Beta/Portal.

Use of the API requires an API key, obtainable here.

This implementation is not supported, endorsed, or created by Valve - I'm just a fan. This is just a wrapper - all of Valve's terms and conditions for using their API still apply, see the Steam community developer page for additional information.

Installation

$ npm install steam-web

Methods

All methods accept a single options object. The key names match the query string parameters specified in the valve documentation. See usage and the valve documentation for any additional params.

All methods can be passed a .apiVersion property that overrides the default api version in the url. Some methods (such as getSchema) will support different games on different versions (TF2 is only supported on v0001, CSGO is only supported on v0002). You can use this property to change the version for the api request if you are not getting back the expected response.

If using JSON for results (default), the result will automatically be parsed into a json object before being passed to the callback. Any other formats will return the raw data (xml or vdf).

getNewsForApp

getGlobalAchievementPercentagesForApp

getPlayerSummaries

getFriendList

getSchema

getPlayerItems

getAssetPrices

getAssetClassInfo

getPlayerAchievements

getRecentlyPlayedGames

getUserStatsForGame

getOwnedGames

getGlobalStatsForGame

isPlayingSharedGame

getSchemaForGame

getPlayerBans

getAppList

getServersAtAddress

upToDateCheck

getUserGroupList

resolveVanityURL

getNumberOfCurrentPlayers

getSteamLevel

getBadges

getCommunityBadgeProgress

getServerInfo

getSupportedAPIList

getSchemaURL

getStoreMetadata

getStoreStatus

Usage

var steam = require('steam-web');

var s = new steam({
  apiKey: 'XXXXXXXXXXXXXXXX',
  format: 'json' //optional ['json', 'xml', 'vdf']
});

s.getNewsForApp({
  appid: 440,
  count: 3,
  maxlength: 300,
  callback: function(err, data) {
    console.log(data);
  }
})
s.getGlobalAchievementPercentagesForApp({
  gameid: 440,
  callback: function(err, data) {
    console.log(data);
  }
});
s.getPlayerSummaries({
  steamids: ['76561198037414410', '76561197960435530'],
  callback: function(err, data) {
    console.log(data);
  }
})
s.getFriendList({
  steamid: '76561197960435530',
  relationship: 'all', //'all' or 'friend'
  callback: function(err,data) {
    console.log(data);
  },
})
s.getSchema({
  gameid: 440,
  callback: function(err, data) {
    console.log(data);
  }
})
s.getPlayerItems({
  gameid: 440,
  steamid: '76561197960435530',
  callback: function(err, data) {
    console.log(data);
  }
})
s.getAssetPrices({
  appid: 440,  //can also use gameid instead for convenience
  callback: function(err,data) {
    console.log(data);
  }
})
s.getPlayerAchievements({
  gameid: 440,
  steamid: '76561197960435530',
  l: 'en',
  callback: function(err,data) {
    console.log(data);
  }
})
s.getRecentlyPlayedGames({
  steamid: '76561197960435530',
  callback: function(err,data) {
    console.log(data)
  }
})
s.getOwnedGames({
  steamid: '76561197960435530',
  callback: function(err,data) {
    console.log(data)
  }
})
s.getUserStatsForGame({
  steamid: '76561197963506690',
  appid: 730,
  callback: function(err,data) {
    console.log(data);
  }
})
s.getGlobalStatsForGame({
  appid: 17740,
  name: ['global.map.emp_isle'], // can also pass a single string
  count: 1, // or you can let the module work it out for you
  callback: function(err,data) {
    console.log(data);
  }
})
s.isPlayingSharedGame({
  steamid: '76561198120639625',
  appid_playing: 730,
  callback: function(err,data) {
    console.log(data);
  }
})
s.getSchemaForGame({
  appid: 730,
  callback: function(err,data) {
    console.log(data);
  }
})
s.getPlayerBans({
  steamids: ['76561198120639625'], // can also pass a single string
  callback: function(err,data) {
    console.log(data);
  }
})
s.getAppList({
  callback: function(err, data) {
    console.log(data);
  }
})
s.getServersAtAddress({
  addr: '193.192.58.116',
  callback: function(err, data) {
    console.log(data);
  }
})    
s.upToDateCheck({
  version: 100,
  appid: 440,
  callback: function(err, data) {
    console.log(data);
  }
})  
s.getUserGroupList({
  steamid: '76561197960435530',
  callback: function(err, data) {
    console.log(data);
  }
})    
s.resolveVanityURL({
  vanityurl: 'vincegogh',
  callback: function(err, data) {
    console.log(data);
  }
})  
s.getNumberOfCurrentPlayers({
  appid: 440,
  callback: function(err, data) {
    console.log(data);
  }
})
s.getSteamLevel({
  steamid: '76561197960435530',
  callback: function(err, data) {
    console.log(data);
  }
})    
s.getBadges({
  steamid: '76561197960435530',
  callback: function(err, data) {
    console.log(data);   
  }
})
s.getCommunityBadgeProgress({
  steamid: '76561197960435530',
  badgeid: 2,
  callback: function(err, data) {
    console.log(data);
  }
})  
s.getServerInfo({
  callback: function(err, data) {
    console.log(data);
  }
})    
s.getSupportedAPIList({
  callback: function(err, data) {
    console.log(data);
  }
})
s.getSchemaURL({
  appid: 440,
  callback: function(err, data) {
    console.log(data);
  }
})    
s.getStoreMetadata({
  appid: 440,
  callback: function(err, data) {
    console.log(data);
  }
})
s.getStoreStatus({
  appid: 440,
  callback: function(err, data) {
    console.log(data);
  }
})

There are two ways to use getAssetClassInfo. By default, the Steam API wants a query string formatted as: ?classid0=1234&classid1=5678&class_count=2

As such, you can either manually generate the keys and call the method like this:

s.getAssetClassInfo({
  appid: 440, //can also use gameid instead for convenience
  classid0: '16891096',
  classid1: 151,
  class_count: 2,
  callback: function(err,data) {
    console.log(data);
  }
})

OR, we have provided a convenience property so you can just pass an array of ids (when using the convenience property, you don't need to pass class_count either)

s.getAssetClassInfo({
  appid: 440, //can also use gameid instead for convenience
  classIds: ['16891096',151],
  callback: function(err,data) {
    console.log(data);
  }
})

Run Tests

Build Status

$ npm test

Run JsFmt/JsHint

$ npm run format
$ npm run lint

Generate Docs

$ npm run docs

Generate Coverage Report

$ npm run coverage

All (travis integration tests)

$ npm run integrate

Changes

0.7.0

  • Add error handler to catch all 4XX http error codes
  • Add deprecation information to getPlayerItems for CS:GO

0.6.0

  • Add apiVersion config property to all methods for changing generated enpoints (#24)
  • Add tests for addVersion method (#24)
  • Split tests into multiple .spec files
  • Fix jsfmt for proper indentation
  • Marked private methods as private (hidden in docs)
  • Update tasks in Readme

0.5.0

  • Fix README styling (#18)
  • Improve code documentation (#17)
  • Add lint build task
  • Add format build task
  • Add docs build task
  • Add coverage build task
  • Update AUTHORS file

0.4.0

  • Added getAppList
  • Added getServersAtAddress
  • Added upToDateCheck
  • Added getUserGroupList
  • Added resolveVanityURL
  • Added getNumberOfCurrentPlayers
  • Added getSteamLevel
  • Added getBadges
  • Added getCommunityBadgeProgress
  • Added getServerInfo
  • Added getSupportedAPIList
  • Added getSchemaURL
  • Added getStoreMetadata
  • Added getStoreStatus
  • Updated Readme and tests
  • Updated AUTHORS file

0.3.0

  • Added getGlobalStatsForGame
  • Added isPlayingSharedGame
  • Added getSchemaForGame
  • Added getPlayerBans
  • Replaced tests with chai/mocha
  • Updated Readme
  • Added AUTHORS file

0.2.5

  • Added error handling for invalid api keys
  • Added tests and README

0.2.4

  • Added getUserStatsForGame
  • Updated README and tests, added gitignore

0.2.3

  • Added getOwnedGames
  • Added getRecentlyPlayedGames
  • Add getPlayerAchievements method
  • Add an error handler to the HTTP get request. This will capture ETIMEDOUT and other connections errors.
  • Updated README and tests with new methods

0.2.1

  • Changed npm module to steam-web to allow https://github.com/seishun/node-steam to use steam npm module name, update your dependencies.

0.1.3

  • Implemented new API methods from 12/1/2011 update: getAssetClassInfo, getAssetPrices, and getFriendList
  • Fixed bug where callbacks were fired twice for certain error events
  • Added convenience property to getAssetClassInfo (classIds instead of forcing manual property generation)

0.1.2

  • Changed requirements to node >= 0.4.0
  • Modified API so first argument of all callbacks is err (to correspond with standard practices)
  • Additional error handling (though methods will return empty arrays if invalid ids are sent to steam