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

source-query-ts

v1.0.0

Published

Ultra-lightweight, zero-dependency, pure TypeScript client for Valve Source Engine Server Queries (A2S) and RCON

Readme

NPM Version NPM Downloads GitHub License GitHub Issues TypeScript Bundle Size

About The Project

Hey! I built this because I needed to query server statuses and run console commands on Source engine servers, and found most existing node libraries (like gamedig) to be unnecessarily heavy, full of dependencies, or difficult to type-check in modern TypeScript projects.

This package is a modern, pure TypeScript implementation of Valve's A2S server query protocol and RCON protocol for Node.js and Bun. It has absolutely zero runtime dependencies.

Why this package is special

  • Zero runtime dependencies - Seriously, check the package.json. No third-party network wrappers, no heavy parser utilities.
  • Automatic Challenge Handling - Handles the IP-spoofing challenge response protocol seamlessly for A2S_INFO, A2S_PLAYER, and A2S_RULES.
  • Split Packet Assembly - Automatically assembles multi-packet UDP responses when query payloads exceed MTU limits.
  • Valve RCON Multiplexing - Implements the dummy SERVERDATA_RESPONSE_VALUE packet trick to detect end-of-output reliably, even for huge multi-packet responses (verified with 670KB+ payloads).
  • CS2-compatible RCON - Correctly handles CS2's quirky output routing (responses attributed to the dummy packet id instead of the command id) and uses the proper dummy packet type to avoid triggering empty-command side effects.
  • Works everywhere - Supports ESM and CommonJS runtimes, and is fully type-safe in TypeScript.

Installation

npm install source-query-ts
pnpm add source-query-ts
bun add source-query-ts

Quick example

1. Server Queries (A2S)

import { A2SClient } from "source-query-ts";

const client = new A2SClient("127.0.0.1:27015");

// 1. Get basic server details
const info = await client.getInfo();
console.log(`Server Name: ${info.name}`);
console.log(`Players:     ${info.players}/${info.maxPlayers}`);
console.log(`Map:         ${info.map}`);

// 2. Get active player list
const players = await client.getPlayers();
players.forEach((p) => {
  console.log(`- [#${p.index}] ${p.name} | Score: ${p.score}`);
});

2. Admin Command Execution (RCON)

import { RconClient } from "source-query-ts";

const rcon = new RconClient("127.0.0.1", 27015, "your-secret-password");

try {
  await rcon.connect();
  console.log("Authenticated!");

  const status = await rcon.execute("status");
  console.log(status);
} catch (error) {
  console.error("RCON command failed:", error);
} finally {
  rcon.close();
}

API Reference

A2SClient

  • new A2SClient(host, port?, timeout?) - Initialize a client. Host can be an IP address or a combined host:port string. Default timeout is 2000ms.
  • getInfo(): Promise<A2SInfo> - Fetch basic server metadata.
  • getPlayers(): Promise<A2SPlayer[]> - Fetch players list.
  • getRules(): Promise<A2SRule[]> - Fetch server rules/cvars. Note: most CS2 servers don't respond to A2S_RULES (Valve-side regression in Source 2) — expect a timeout on CS2.

RconClient

  • new RconClient(host, port, password, timeout?) - Initialize an RCON client. Host can be an IP address or a combined host:port string. Default timeout is 5000ms.
  • connect(): Promise<void> - Connect to the TCP port and perform password authentication.
  • execute(command): Promise<string> - Run a console command and get the fully-assembled response.
  • close(): void - Safely disconnect the underlying socket.

For developers

If you want to contribute or build the library locally, please check out the contributing guide.

License

MIT - do whatever you want with it


Credits

Built by K4ryuu