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-sdkUsage
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.jsonin the package root.
- Loads the schema from the given path or defaults to
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.
- Search for items by name or partial name. Options:
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.
- Get the item ID for a given name and category. Options:
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.
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.