CS2 API for Rust
cs2-api is the official Rust client for the CS2 API at cs2-api.org. One blocking client, two small dependencies (ureq with rustls, serde_json), and every Counter-Strike 2 endpoint you need:
- live CS2 match scores and round-level scoreboards
- match results, schedules and streams
- player stats (rating, ADR, KAST, K/D) and leaderboards
- teams, rosters and head-to-head records
- the world ranking and Valve Regional Standings (VRS)
- events, standings and brackets
- roster transfers
- CS2 skin prices across 25+ marketplaces, with price history and trending movers
You need a free API key (500 requests/month, no card): Get a free API key
Install
Or in Cargo.toml:
[]
= "1"
Quickstart
use Client;
Pass the key directly with Client::new("your-key")?, or set a base URL and timeout:
use Duration;
let cs2 = builder
.api_key
.timeout
.build?;
# Ok::
Every method returns the data field of the response as a serde_json::Value. get_raw(path, query) returns the whole envelope (success, data, meta) for pagination.
Endpoints
Teams, players and events accept an id or a slug (vitality, donk). Path segments are percent-encoded for you.
| Area | Methods |
|---|---|
| Live | live(), live_scoreboard(match_id): sides, round, player K/D/ADR, money |
| Matches | upcoming(limit), results(limit), today(), match_by_id(id), match_maps(id), match_player_stats(id), match_streams(id) |
| Teams | team(slug), team_matches(slug, limit), team_stats(slug), team_map_stats(slug), head_to_head(a, b) |
| Players | player(slug), search_players(q, limit), player_stats(slug), player_matches(slug, limit) |
| Events | events(status, limit) ("upcoming", "live", "recent"), event(slug), event_matches(slug), event_standings(slug), event_bracket(slug) |
| Rankings & stats | world_ranking(limit), vrs_ranking(limit), leaderboard(metric, limit), transfers(limit), search(q) |
| Skins | search_skins(q, filters), skin(slug), skin_prices(slug), skin_history(slug, range), trending_skins(timeframe, limit, min_price) |
| Anything else | get(path, query) / get_raw(path, query): any of the 140+ endpoints |
Errors
Every call returns Result<Value, cs2_api::Error>:
Error::Http { status, code, message }: the API answered with an error (bad key, not found, rate limit)Error::Transport(_): no response (DNS, connection, TLS, timeout)Error::Decode(_): the body was not JSONError::MissingKey: no key passed andCITO_API_KEYnot set
Error implements std::error::Error, so ? works with anyhow, Box<dyn Error> and friends.
Use cases
- Discord bots: cs2-discord-bot
- Stream overlays: cs2-obs-overlay
- Skin trading tools: cs2-skin-price-api
- Fantasy, analytics dashboards, prediction models and AI agents
Keep your key safe
Keep it in an environment variable or a git-ignored .env. If a key leaks, revoke it in your dashboard and create a new one.
Links
- CS2 API docs and endpoints: https://cs2-api.org
- API reference for this crate: https://docs.rs/cs2-api
- Pricing: https://citoapi.com/pricing
- Issues: https://github.com/achillesscriptsvip/cs2-api/issues
Also available for JavaScript (npm) and Python (PyPI).
Not affiliated with Valve, HLTV, ESL, BLAST or PGL. MIT licensed.