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

@automatedtf/sherpa

v0.0.16

Published

### πŸ“– Table of Contents - [πŸ‘‹ Introduction](#-introduction) - [πŸ”Œ Getting Started](#-getting-started) - [ItemInstance](#iteminstance) - [Getting a Backpack](#getting-a-backpack) - [getUsedSlots](#getusedslots) - [getItemByAssetId]

Downloads

32

Readme

Sherpa ⛰️

πŸ“– Table of Contents

πŸ‘‹ Introduction

Sherpa provides a simplified representation of a player's Team Fortress 2 backpack, utilising @automatedtf/catalog to fully represent items each as compactly as a single SKU string.

πŸ”Œ Getting Started

You can install this module with npm within your project by running the command:

npm install @automatedtf/sherpa

ItemInstance

One of the key types within this module is the ItemInstance interface. It details the least sufficient information required to uniquely identify an item instance within TF2.

interface ItemInstance {
    appid: number; // Game id (440 for TF2, 730 for CS:GO)
    assetid: string; // Steam-given id for possession of item
    instanceid: string; // Internal Steam field for item information caching
    classid: string; // Internal Steam field for item information caching
    icon_url: string; // Image url hash to attach onto CDN link for display purposes
    sku: string; // Item base SKU generated from `@automatedtf/catalog`
    full_sku: string; // sku for item, with any additional item modifications included
}

A class object CItemInstance can be used as a container to extract the properties of an ItemInstance object from EconItem.

class CItemInstance implements ItemInstance {
    appid: number; // Game id (440 for TF2, 730 for CS:GO)
    assetid: string; // Steam-given id for possession of item
    instanceid: string; // Internal Steam field for item information caching
    classid: string; // Internal Steam field for item information caching
    icon_url: string; // Image url hash to attach onto CDN link for display purposes
    sku: string; // Item base SKU generated from `@automatedtf/catalog` 
    full_sku: string; // sku for item, with any additional item modifications included
    ...
}

You would then be able to create an instance of CItemInstance by passing in an EconItem object and then turn it into a ItemInstance object by calling toItemInstance() on it.

const econItem: EconItem = ...; // get some EconItem object from somewhere

const itemInstance: ItemInstance = new CItemInstance(econItem).toItemInstance();

Getting a Backpack

For interacting with the module, getTF2Backpack should be your main entry point. You should query for a user's backpack by using their steamid64.

const steamid = "76561198081082634";
...
const backpack = await getTF2Backpack(steamid);

After resolving and getting a Backpack from getTF2Backpack, you will have access to a number of methods.

getUsedSlots

const totalNumberOfItems: number = backpack.getUsedSlots();

Gets the total number of item instances recorded within the user's backpack, even if they have gone over their maximum number of inventory slots.

getItemByAssetId
const assetidOfItemToFind: string = "837141231";
const item: ItemInstance = backpack.getItemByAssetId(assetidOfItemToFind);

Gets the specific item instance with that assetid. As assetid is unique to every item instance, we can return the specific item saved within the dictionary indexed by assetid.

getInstances
// Warning: Case sensitive!
const nameOfItemsToFind: string = "Scream Fortress XII War Paint Case";
const items: ItemInstance[] = backpack.getInstances(nameOfItemsToFind);

Gets all instances with that itemName.

getInstancesBySKU
const baseSKUOfItemsToFind: string = "5918;6";
const items: ItemInstance[] = backpack.getInstancesBySKU(baseSKUOfItemsToFind);

Gets all instances with that baseSKUOfItemsToFind.

ownsItem
const specialAssetid: string = "837141231";
const ownsSpecialItem: boolean = backpack.ownsItem(specialAssetid);

Checks if the user owns an item with that assetid.

Dealing with Backpack Errors

Calling getTF2Backpack can result in the following errors. These errors are exported by the module to allow you to catch for them.

  • PrivateBackpackError: The user's backpack is private and cannot be accessed.
  • InvalidSteamIdError: The provided steamid is invalid.

πŸ“š Helpful Resources