JSPM

cs2schema

1.0.2
  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 4
  • Score
    100M100P100Q21756F
  • License MIT

A TypeScript SDK for Counter-Strike 2 schema data with ID/name resolution utilities

Package Exports

  • cs2schema
  • cs2schema/dist/index.js

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (cs2schema) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

CS2 Schema SDK

A TypeScript SDK for Counter-Strike 2 schema data with ID/name resolution utilities.

Installation

pnpm add cs2-schema-sdk

Usage

import { CS2SchemaSDK } from "cs2-schema-sdk";

const sdk = new CS2SchemaSDK();

// Example: Search for an item
const results = sdk.searchItems("ak-47");

API

Constructor

  • new CS2SchemaSDK(schemaPath?: string)
    • Loads the schema from the given path or defaults to schema.json in the package root.

Methods

  • clearCache()

    • Clears the internal search cache.
  • searchItems(query: string, options?: SearchOptions): ResolveResult[]

    • Search for items by name or partial name. Options: caseSensitive, category, exactMatch.
  • resolveIdToName(id: string, category: ItemCategory): string | null

    • Get the market hash name for a given item ID and category.
  • resolveNameToId(name: string, category: ItemCategory, options?: SearchOptions): string | null

    • Get the item ID for a given name and category. Options: caseSensitive, exactMatch.
  • getItemById(id: string, category: ItemCategory): ResolveResult | null

    • Get the item object for a given ID and category.
  • getItemByName(name: string, category: ItemCategory, options?: SearchOptions): ResolveResult | null

    • Get the item object for a given name and category.
  • searchSkins(query: string, options?: Omit<SearchOptions, 'category'>): WeaponSkinResolveResult[]

    • Search for weapon skins by name or partial name.
  • getCollections(): Collection[]

    • Get all collections.
  • getRarities(): Rarity[]

    • Get all rarities.
  • getCollectionByKey(key: string): Collection | null

    • Get a collection by its key.
  • getRarityByKey(key: string): Rarity | null

    • Get a rarity by its key.
  • getAllItemsInCategory(category: ItemCategory): ResolveResult[]

    • Get all items in a given category.
  • getAllCharmNames(): string[]

    • Get all charm names from the keychains category.
  • generateAllWeaponMarketHashNames(options?: { includeSouvenir?: boolean; includeStatTrak?: boolean; specificCollections?: string[] }): GeneratedMarketHashName[]

    • Generate all possible weapon market hash names with wear states. Options: includeSouvenir, includeStatTrak, specificCollections.
  • generateWeaponMarketHashNamesByCollection(collectionKey: string, options?: { includeSouvenir?: boolean; includeStatTrak?: boolean }): GeneratedMarketHashName[]

    • Generate weapon market hash names for a specific collection.
  • getCategoryStats(): Record<ItemCategory, number>

    • Get the number of items in each category.
  • isInitialized(): boolean

    • Check if the SDK is initialized and schema loaded.
  • getSchema(): Schema

    • Get the full processed schema object.

Types

See src/types.ts for all type definitions used in the SDK.

GeneratedMarketHashName

interface GeneratedMarketHashName {
  baseName: string;
  wearState: string;
  fullName: string;
  minFloat: number;
  maxFloat: number;
  collection?: string;
  isSouvenir?: boolean;
}

WeaponWearState

interface WeaponWearState {
  name: string;
  minFloat: number;
  maxFloat: number;
}