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

steam-api-fetcher

v1.1.0

Published

A TypeScript library for fetching Steam user inventories and player data with proxy support and retry mechanisms

Readme

steam-inventory-fetcher

A TypeScript library for fetching Steam user inventories and player data with proxy support and retry mechanisms.

Features

  • 🔍 Fetch Steam Inventories - Get user inventories for any Steam game
  • 👤 Get Player Summaries - Retrieve player profile information via Steam Web API
  • 🔄 Automatic Retry - Built-in retry mechanism for failed requests
  • 🌐 Proxy Support - Rotate through multiple proxies with configurable repeat counts
  • 📦 TypeScript - Full TypeScript support with comprehensive type definitions
  • Modern - Built with async/await and modern JavaScript features
  • 🛡️ Error Handling - Comprehensive error handling with custom error types

Installation

npm install steam-inventory-fetcher

Quick Start

Basic Inventory Fetch

import SteamAPI from 'steam-inventory-fetcher';

const api = new SteamAPI({
    requestTimeout: 10000,
    retryDelay: 1000,
});

// Fetch TF2 inventory
const result = await api.getPlayerInventory(
    '76561199099521803', // SteamID64
    440, // TF2 appid
    2, // contextid
    false, // tradableOnly
    2, // retries
    'english' // language
);

console.log(`Found ${result.inventory.length} items`);
console.log(`Total count: ${result.total_inventory_count}`);

Get Player Summaries

import SteamAPI from 'steam-inventory-fetcher';

const api = new SteamAPI({
    apiKey: 'YOUR_STEAM_WEB_API_KEY', // Get from https://steamcommunity.com/dev/apikey
    requestTimeout: 10000,
});

// Get player summaries
const players = await api.getPlayerSummaries(['76561199099521803', '76561198114402400']);

players.forEach((player) => {
    console.log(`${player.personaname} - ${player.profileurl}`);
});

API Reference

Constructor Options

interface SteamAPIOptions {
    apiKey?: string; // Steam Web API key for GetPlayerSummaries
    proxy?: string | string[]; // Proxy URL(s) for requests
    proxyRepeat?: number; // How many times to use each proxy before rotating (default: 1)
    retryDelay?: number; // Delay between retries in ms (default: 0)
    requestOptions?: RequestOptions; // Custom request options
    requestTimeout?: number; // Request timeout in ms (default: 9000)
}

Methods

getPlayerInventory(steamid, appid, contextid, tradableOnly?, retries?, language?)

Fetches a user's inventory for a specific game.

Parameters:

  • steamid (string | SteamID): SteamID64 string or SteamID object
  • appid (number): Steam application ID (e.g., 440 for TF2, 730 for CS:GO)
  • contextid (number): Context ID within the app (usually 2)
  • tradableOnly (boolean, optional): Filter to only tradable items (default: false)
  • retries (number, optional): Number of retry attempts (default: 1)
  • language (string, optional): Language for item descriptions (default: 'english')

Returns: Promise<InventoryResult>

interface InventoryResult {
    inventory: CEconItem[]; // Array of inventory items
    currency: CEconItem[]; // Array of currency items
    total_inventory_count: number; // Total item count
}

Example:

const result = await api.getPlayerInventory('76561199099521803', 440, 2, false, 2, 'english');

// Access items
result.inventory.forEach((item) => {
    console.log(item.market_hash_name);
    console.log(item.getImageURL());
});

getPlayerSummaries(steamids, retries?)

Fetches player summaries from Steam Web API.

Parameters:

  • steamids (string | string[]): Single SteamID64 or array of SteamID64s (max 100 per request)
  • retries (number, optional): Number of retry attempts (default: 1)

Returns: Promise<PlayerSummary[]>

Example:

const players = await api.getPlayerSummaries(['76561199099521803', '76561198114402400']);

players.forEach((player) => {
    console.log(player.personaname);
    console.log(player.avatarfull);
    console.log(player.realname);
});

Configuration Examples

With Proxy

const api = new SteamAPI({
    proxy: ['http://proxy1.example.com:8080', 'http://proxy2.example.com:8080'],
    proxyRepeat: 2, // Use each proxy 2 times before rotating
    requestTimeout: 10000,
});

Custom Request Options

const api = new SteamAPI({
    requestOptions: {
        headers: {
            'Custom-Header': 'value',
        },
        timeout: 15000,
    },
});

Custom Endpoint

const api = new SteamAPI({
    requestOptions: {
        uri: (steamid, appid, contextid) => {
            return `https://api.steamapis.com/steam/inventory/${steamid}/${appid}/${contextid}`;
        },
    },
});

Error Handling

The library throws SteamAPIError for API-related errors:

import { SteamAPIError } from 'steam-inventory-fetcher';

try {
    const result = await api.getPlayerInventory('76561199099521803', 440, 2);
} catch (err) {
    if (err instanceof SteamAPIError) {
        console.error('Status:', err.statusCode);
        console.error('Message:', err.message);
    }
}

Common Errors:

  • 403 - Profile or inventory is private
  • 404 - Profile could not be found
  • 401 - Invalid Steam Web API key (for GetPlayerSummaries)

CEconItem

Items are returned as CEconItem instances with useful methods:

const item = result.inventory[0];

// Get image URLs
const imageUrl = item.getImageURL();
const largeImageUrl = item.getLargeImageURL();

// Get tag by category
const qualityTag = item.getTag('Quality');

// Access properties
console.log(item.market_hash_name);
console.log(item.tradable);
console.log(item.marketable);

Rate Limiting

Steam API has rate limits. When fetching multiple inventories, add delays between requests:

const steamIDs = ['76561199099521803', '76561198114402400'];

for (const steamID of steamIDs) {
    const result = await api.get(steamID, 440, 2);
    // Wait 2 seconds before next request
    await new Promise((resolve) => setTimeout(resolve, 2000));
}

Common Game AppIDs

  • Team Fortress 2: 440
  • Counter-Strike: Global Offensive: 730
  • Dota 2: 570
  • Rust: 252490
  • PUBG: 578080

Most games use contextid: 2 for the main inventory context.

Getting a Steam Web API Key

  1. Visit https://steamcommunity.com/dev/apikey
  2. Log in with your Steam account
  3. Enter a domain name (localhost works for testing)
  4. Copy your API key
  5. Use it in the constructor:
const api = new SteamAPI({
    apiKey: 'YOUR_API_KEY_HERE',
});

TypeScript Support

Full TypeScript support with comprehensive type definitions:

import SteamAPI, {
    SteamAPIOptions,
    InventoryResult,
    PlayerSummary,
    SteamAPIError,
    CEconItem,
} from 'steam-inventory-fetcher';

Examples

Fetch Multiple Inventories

const steamIDs = ['76561199099521803', '76561198114402400'];
const results = [];

for (const steamID of steamIDs) {
    try {
        const result = await api.getPlayerInventory(steamID, 440, 2);
        results.push({ steamID, success: true, count: result.inventory.length });
    } catch (err) {
        results.push({ steamID, success: false, error: err.message });
    }
    await new Promise((resolve) => setTimeout(resolve, 2000));
}

Filter Tradable Items

// Get only tradable items
const result = await api.getPlayerInventory('76561199099521803', 440, 2, true);

console.log(`Tradable items: ${result.inventory.length}`);

Different Games

const games = [
    { name: 'TF2', appid: 440, contextid: 2 },
    { name: 'CS:GO', appid: 730, contextid: 2 },
    { name: 'Dota 2', appid: 570, contextid: 2 },
];

for (const game of games) {
    const result = await api.getPlayerInventory('76561199099521803', game.appid, game.contextid);
    console.log(`${game.name}: ${result.inventory.length} items`);
}

License

MIT

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

Related Projects

Support

For issues, questions, or contributions, please open an issue on GitHub.