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 🙏

© 2026 – Pkg Stats / Ryan Hefner

steamapi-wasm

v3.1.5-wasm

Published

A WASM-compatible Steam API wrapper (fork of steamapi).

Readme

SteamAPI (WASM edition)

本包是 xDimGG/node-steamapi 的 WASM 兼容 fork,完整移除 Node.js 运行时依赖。

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

Future plans for 4.x

  • Allow getGameDetails to return either a GameDetails object or a map of string to GameDetails depending on if the user supplied a single id or an array of ids.
  • Maybe separate groups of endpoints into different classes so there isn't just a monolithic SteamAPI class? Not quite sure how they would be grouped.
  • Add some convenience methods to the Cache class to reduce double logic in SteamAPI.ts

Setup

Installation

npm i steamapi-wasm@wasm

要求 Node.js >= 18(依赖全局 fetch)。Node < 18 或非浏览器环境需自行注入 fetch

当前发布线:[email protected](prerelease,跟随上游 3.1.x 版本体系,dist-tag 为 wasm

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-wasm';

const steam = new SteamAPI('steam token');

API Key 解析顺序

  1. 显式传入:new SteamAPI('explicit_key')
  2. envConfignew SteamAPI(undefined, { envConfig: { STEAM_API_KEY: 'config_key' } })
  3. process.env.STEAM_API_KEY(Node.js)
  4. 均未找到时输出警告(new SteamAPI(false) 可禁用)

Environment Support

本分支移除全部 Node.js 运行时依赖(node:querystringnode:modulenode-fetchsteamid 包),可在以下环境使用:

| 环境 | 支持 | 说明 | | --- | --- | --- | | Node.js (>=18) | ✅ | 使用全局 fetch | | 浏览器 | ✅ | 使用 window/globalThisfetch | | Web Worker | ✅ | 使用 self.fetch | | WASM 运行时 (WASI/QuickJS 等) | ✅ | 需注入 fetch 实现 |

fetch 探测顺序:globalThis.fetchself.fetchwindow.fetch → 抛出错误。

WASM 环境使用

import SteamAPI from 'steamapi-wasm';

const steam = new SteamAPI(undefined, {
  envConfig: { STEAM_API_KEY: 'your_key_here' }
});

更多环境变量用法见 ENV_USAGE.md

Breaking changes from 2.x to 3.x

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); // 76561198146931523
});

Now let's take that ID, and fetch the user's profile.

steam.getUserSummary('76561198146931523').then(summary => {
	console.log(summary);
	/**
	UserSummary {
		steamID: '76561198146931523',
		avatar: {
			small: 'https://avatars.steamstatic.com/7875e33529232d95cad28ea1054897618907fa03.jpg',
			medium: 'https://avatars.steamstatic.com/7875e33529232d95cad28ea1054897618907fa03_medium.jpg',
			large: 'https://avatars.steamstatic.com/7875e33529232d95cad28ea1054897618907fa03_full.jpg',
			hash: '7875e33529232d95cad28ea1054897618907fa03'
		},
		url: 'https://steamcommunity.com/id/DimGG/',
		visible: true,
		personaState: 0,
		personaStateFlags: 0,
		allowsComments: true,
		nickname: 'dim',
		lastLogOffTimestamp: 1704553877,
		createdTimestamp: 1406393110,
		realName: undefined,
		primaryGroupID: '103582791457347196',
		gameID: undefined,
		gameName: undefined,
		gameServerIP: undefined,
		gameServerID: undefined,
		countryCode: 'US',
		stateCode: undefined,
		cityID: undefined
	}
	*/
});

3.1.5-wasm 分支变更说明

相对上游 3.1.5 的变更:

  • 零 Node.js 依赖:可运行于浏览器 / Web Worker / WASM 运行时
  • 内置 SteamID 实现SteamID 导出,替代 steamid 包)
  • 参数编码行为变化:数组参数由 key=1&key=2 改为逗号拼接 key=1,2;空格统一编码为 +
  • API key 环境变量new SteamAPI() 自动读取 process.env.STEAM_API_KEY(详见 ENV_USAGE.md
  • 增强错误信息:非 2xx 响应提取 Steam 错误页 <h1>/<title> 或 JSON 错误消息,Error.status 附带 HTTP 状态码

Development

npm install        # 自动生成 src/version.ts(prepare 钩子)
npm run build      # 生成 dist
npm test           # vitest 单测(无需 API key)
npm run test:node  # 真实 API 集成测试(需创建 test/cfg.mjs 导出 key,参考 test/test.mjs)