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-async

v1.0.3

Published

Async wrapper for Steam Web API

Downloads

3

Readme

Steam Web API for NodeJS (Async / await)

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-async

Basic idea and usage

const SteamWebAsync = require('steam-web-async');



var apiSWA = new SteamWebAsync({
    apiKey: 'your_key',
    format: 'json' //optional ['json', 'xml', 'vdf']
});


//examples of Async code
(async () => {
    
    var news = await apiSWA.getNewsForApp({appid: 440,count: 3, maxlength: 100})
    console.log(news);

    var acc = await apiSWA.resolveVanityURL({ vanityurl: 'Gabe'}); 
    console.log( acc.response);

})();

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. 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 steamAsync = require('steam-web-async');

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

s.getNewsForApp({
  appid: 440,
  count: 3,
  maxlength: 300
})
s.getGlobalAchievementPercentagesForApp({
  gameid: 440
});
s.getPlayerSummaries({
  steamids: ['76561198037414410', '76561197960435530']
})
s.getFriendList({
  steamid: '76561197960435530',
  relationship: 'all', //'all' or 'friend'
  },
})
s.getSchema({
  gameid: 440
})
s.getPlayerItems({
  gameid: 440,
  steamid: '76561197960435530'
})
s.getAssetPrices({
  appid: 440,  //can also use gameid instead for convenience
  }
})
s.getPlayerAchievements({
  gameid: 440,
  steamid: '76561197960435530',
  l: 'en',
  }
})
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,
  }
})
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
  }
})
s.isPlayingSharedGame({
  steamid: '76561198120639625',
  appid_playing: 730,
  }
})
s.getSchemaForGame({
  appid: 730,
  }
})
s.getPlayerBans({
  steamids: ['76561198120639625'], // can also pass a single string
  }
})
s.getAppList(
})
s.getServersAtAddress({
  addr: '193.192.58.116'
})    
s.upToDateCheck({
  version: 100,
  appid: 440
})  
s.getUserGroupList({
  steamid: '76561197960435530'
})    
s.resolveVanityURL({
  vanityurl: 'vincegogh'
})  
s.getNumberOfCurrentPlayers({
  appid: 440
})
s.getSteamLevel({
  steamid: '76561197960435530'
})    
s.getBadges({
  steamid: '76561197960435530'
})
s.getCommunityBadgeProgress({
  steamid: '76561197960435530',
  badgeid: 2
})  
s.getServerInfo(
})    
s.getSupportedAPIList(
})
s.getSchemaURL({
  appid: 440
})    
s.getStoreMetadata({
  appid: 440
})
s.getStoreStatus({
  appid: 440
})

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
})

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]
})

Changes

1.0.0

  • Added async / await support
  • Added error handler (console output)