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

@cratetf/item-url-codec

v1.0.0

Published

Canonical Crate.tf item URL generation and TF2 SKU path parsing.

Downloads

37

Readme

Crate.tf item URL codec

The official, dependency-free reference implementation for converting TF2 SKUs to canonical Crate.tf item links and parsing supported item URL segments back to API SKUs.

This repository is the public integration contract for websites, bots, browser extensions, and other tools linking to Crate.tf item pages. Crate.tf backend APIs continue to use authoritative semicolon-delimited TF2 SKUs; public item URLs use a readable hyphenated representation.

Why this exists

A naive replacement works in the forward direction when the input is already a canonical TF2 SKU, but it cannot safely parse URLs in reverse. Some valid SKU attributes contain native hyphens:

9258;5;uncraftable;td-31154

The corresponding public path is:

/item/9258-5-uncraftable-td-31154

The codec recognizes the TF2 SKU grammar and preserves attributes such as td-31154, kt-2, and od-456.

Installation

Install the package from npm:

npm install @cratetf/item-url-codec

Non-JavaScript integrations can implement the language-neutral contract from CONTRACT.md and verify their implementation against test-vectors.json.

Usage

import {
  toApiSkuFromItemPathSegment,
  toCrateTfItemUrl,
  toItemPathFromSku,
} from '@cratetf/item-url-codec'

toItemPathFromSku('5978;6;c151')
// '/item/5978-6-c151'

toCrateTfItemUrl('9258;5;uncraftable;td-31154')
// 'https://crate.tf/item/9258-5-uncraftable-td-31154'

toApiSkuFromItemPathSegment('9258-5-uncraftable-td-31154')
// '9258;5;uncraftable;td-31154'

For outbound links, integrations normally need only toCrateTfItemUrl() or toItemPathFromSku(). Reverse parsing is primarily useful to Crate.tf itself.

Public API

normalizeTf2Sku(rawSku)

Normalizes case, whitespace, untradeable, and known tolerant numeric attribute spellings while preserving the semicolon-delimited API representation.

toCanonicalItemPathSegment(rawSku)

Returns the canonical hyphenated item path segment.

toItemPathFromSku(rawSku)

Returns the canonical site-relative /item/<segment> path.

toCrateTfItemUrl(rawSku, baseUrl?)

Returns an absolute item URL. It defaults to https://crate.tf and rejects an empty SKU or non-HTTP(S) base URL.

toApiSkuFromItemPathSegment(pathSegment)

Returns the normalized API SKU for a canonical or supported legacy segment. Returns an empty string for ambiguous or unsupported segments.

isCanonicalItemPathSegment(value)

Returns whether the input is already the exact canonical path representation.

Canonical examples

| API SKU | Canonical path | | --- | --- | | 5021;6 | /item/5021-6 | | 5978;6;c151 | /item/5978-6-c151 | | 30911;5;u144 | /item/30911-5-u144 | | 9258;5;uncraftable;td-31154 | /item/9258-5-uncraftable-td-31154 | | 123;6;kt-2 | /item/123-6-kt-2 | | 123;6;od-456;oq6 | /item/123-6-od-456-oq6 |

Requirements and compatibility

  • Zero runtime dependencies.
  • ESM package with bundled TypeScript declarations.
  • Browser and Node.js compatible.
  • Node.js 20 or newer for package tooling and automated tests.
  • Semantic Versioning for public API and contract changes.

The package does not check whether an SKU currently exists in the Crate.tf catalog. It only normalizes and converts identifiers. A correctly formed link may still return 404 when the item is not present in the live catalog.

Development

npm ci
npm run check
npm pack --dry-run

npm run check performs strict TypeScript validation, builds declarations and source maps, and executes the conformance tests.

Security

This package processes public identifiers and does not access credentials, network services, or the filesystem. Report security concerns according to SECURITY.md.

Contributing

See CONTRIBUTING.md. Changes to parsing behavior must include portable contract vectors and tests.

License

MIT. See LICENSE.