A Rust library and CLI tool for querying Valve Source Engine servers using the A2S protocol.
Use cargo add:
cargo add --git https://github.com/NiTrO0FuN/a2s-queryOr manually add to your Cargo.toml:
[dependencies]
a2s_query = { git = "https://github.com/NiTrO0FuN/a2s-query" }git clone https://github.com/NiTrO0FuN/a2s-query
cd a2s-query
cargo build --releaseThe a2s-query binary allows you to query Source servers from the command line and get the results in JSON format.
a2s-query --host <HOST> [--port <PORT>] <COMMAND>Arguments:
--host <HOST>: IP address or hostname of the Source server--port <PORT>: Port number (default: 27015)
Commands:
info: Get server information (name, map, player count, etc.)players: Get list of connected playersrules: Get server rules and configuration
a2s-query --host play.example.com infoResponse:
{
"protocol": 17,
"name": "Example Server",
"map": "de_dust2",
"folder": "csgo",
"game": "Counter-Strike: Global Offensive",
"app_id": 730,
"players": 12,
"max_players": 32,
"bots": 0,
"server_type": "Dedicated",
"environment": "Linux",
"password": false,
"vac": true,
"version": "2025.03.26"
}use a2s_query::{A2S, errors::Error, info::Info, players::Player, rules::Rule};
fn main() -> Result<(), Error> {
// Create a new A2S query instance
let a2s = A2S::new("play.example.com:27015");
// Query server information
let info: Info = a2s.info()?;
// Query player list
let players: Vec<Player> = a2s.players()?;
// Query server rules
let rules: Vec<Rule> = a2s.rules()?;
Ok(())
}