SteamAPI
Documentation
A list of all the methods SteamAPI provides is available here.
Breaking changes from 2.x to 3.x
- CommonJS Modules -> ES Modules
- Import using
import
statement instead of require()
- SteamAPI constructor now takes false as the first parameter if you don't want to supply a key
- Options for constructor have changes from
{ enabled, expires, disableWarnings }
to { language, currency, headers, baseAPI, baseStore, baseActions, inMemoryCacheEnabled, gameDetailCacheEnabled, gameDetailCacheTTL, userResolveCacheEnabled, userResolveCacheTTL }
- Custom caching may be enabled by setting
inMemoryCacheEnabled: false
and setting <SteamAPI>.gameDetailCache
/<SteamAPI>.userResolveCache
. Must implement CacheMap<K, V>
interface in src/Cache.ts - getFeaturedGames() returns object instead of array
- Server#game -> Server#gameDir
- App IDs are passed as numbers not strings (although a string will probably still work)
- Any other changes to the API can be found in https://github.com/xDimGG/node-steamapi/blob/master/PORT.md
Setup
Installation
npm i steamapi
Getting an API Key
Once signed into Steam, head over to http://steamcommunity.com/dev/apikey to generate an API key.
Usage
First, we start by making a SteamAPI "user".
import SteamAPI from 'steamapi';
const steam = new SteamAPI('steam token');
Now, we can call methods on the steam
object.
For example, let's retrieve the SteamID64 of a user. SteamAPI provides a resolve
method, which accepts URLs and IDs.
steam.resolve('https://steamcommunity.com/id/DimGG').then(id => {
console.log(id);
});
Now let's take that ID, and fetch the user's profile.
steam.getUserSummary('76561198146931523').then(summary => {
console.log(summary);
});