cs2schema
v1.0.2
Published
A TypeScript SDK for Counter-Strike 2 schema data with ID/name resolution utilities
Maintainers
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.
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.
- Generate all possible weapon market hash names with wear states. Options:
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;
}