steam-client-rs
A comprehensive Steam client library for Rust, providing Individual and Anonymous user account types. This crate handles connection management, authentication, and communication with Steam's CM (Connection Manager) servers via WebSocket.
Disclaimer
This library facilitates automated interactions with Steam, including game idling, bulk free-license activation, and similar activities that may violate the Steam Subscriber Agreement. You are solely responsible for understanding Steam's Terms of Service and for using this library in a manner consistent with them. The authors take no responsibility for account restrictions, bans, or other consequences arising from misuse.
This library is provided "as is", without warranty of any kind. It is not affiliated with or endorsed by Valve Corporation.
Features
-
Multiple Authentication Methods
- Refresh token login (persistent sessions)
- Password login with Steam Guard support (email, TOTP, mobile confirmation)
- Anonymous login for public data access
-
Connection Management
- WebSocket-based connections to Steam CM servers
- Automatic reconnection with exponential backoff
- Server load balancing and blacklisting
- Heartbeat keep-alive
- Smart Server Refresh: Self-healing mechanism that automatically updates the server list every 7 days from WebAPI, ensuring reliable connections even after long periods of inactivity.
-
Friends & Social
- Friends list management
- Persona states (Online, Away, Busy, Offline, etc.)
- Friend nicknames and levels
- Friend messages and typing indicators
-
Games & Apps
- Set playing status (up to 32 games)
- Support for Non-Steam games with custom names
- Auto-Idler: Built-in utility for automatic game idling with randomized intervals
- Rich presence data
- App info and PICS (Package Info Cache System)
- License/ownership information
- Free license requests
-
Economy & Trading
- Asset class info
- Trade URLs
- Trade restrictions
- Emoticons and profile items
-
Content Delivery
- Content server discovery
- Depot decryption keys
- Manifest parsing
-
Advanced Features
- Game Coordinator (GC) messaging with request-response pattern
- Family sharing management
- Chat rooms and group chats
- Notification system
- Two-factor authentication management
- Gift redemption
- Store tag metadata and localization
- App ownership tickets and encrypted app tickets
- Persona cache with configurable TTL
- Automatic cache population from events
- Thread-safe with size limits
-
CS:GO/CS2 Integration
- Game Coordinator communication
- Party search
- Lobby management (create, join, leave, update)
- Rich presence / fake score
- Player profiles
Installation
[]
= "0.1"
= { = "1", = ["full"] }
The crate is imported as steam_client in your code (the package name is steam-client-rs because steam-client is taken on crates.io).
Architecture
┌─────────────────────────────────────────────────────────────────────┐
│ SteamClient │
├─────────────────────────────────────────────────────────────────────┤
│ ┌─────────────┐ ┌─────────────┐ ┌─────────────┐ ┌────────────┐ │
│ │ Connection │ │ Jobs │ │ GC Jobs │ │ Reconnect │ │
│ │ Manager │ │ Manager │ │ Manager │ │ Manager │ │
│ └─────────────┘ └─────────────┘ └─────────────┘ └────────────┘ │
├─────────────────────────────────────────────────────────────────────┤
│ Cache Layer │
│ ┌─────────────────────────────────────────────────────────────┐ │
│ │ PersonaCache │ │
│ └─────────────────────────────────────────────────────────────┘ │
├─────────────────────────────────────────────────────────────────────┤
│ Services Layer │
│ ┌─────────┐ ┌─────────┐ ┌─────────┐ ┌─────────┐ ┌─────────┐ │
│ │ Friends │ │ Apps │ │ CDN │ │ Chat │ │ Econ │ │
│ └─────────┘ └─────────┘ └─────────┘ └─────────┘ └─────────┘ │
│ ┌─────────┐ ┌─────────┐ ┌─────────┐ ┌──────────┐ ┌─────────┐ │
│ │ChatRoom │ │ CS:GO │ │TwoFactor│ │ Account │ │ Trading │ │
│ └─────────┘ └─────────┘ └─────────┘ └──────────┘ └─────────┘ │
│ ┌─────────┐ ┌─────────┐ ┌─────────┐ ┌──────────┐ ┌─────────┐ │
│ │ Gifts │ │ GC │ │ Store │ │ Idler │ │ PubFiles│ │
│ └─────────┘ └─────────┘ └─────────┘ └──────────┘ └─────────┘ │
└─────────────────────────────────────────────────────────────────────┘
Prior Art / Why This Crate
| Library | Language | Notes |
|---|---|---|
steam-vent |
Rust | Active Rust CM client; lower-level, closer to raw protobufs. Good choice if you need fine-grained control or a production-hardened foundation. |
node-steam-user |
JavaScript | The primary API inspiration for this crate. steam-client-rs deliberately mirrors its struct names, method names, and event model so that existing node-steam-user experience transfers directly. |
SteamKit2 |
C# | The canonical reference implementation that most Steam client libraries (including node-steam-user) build on. |
When to use this crate: you want a node-steam-user-style ergonomic Rust API and are comfortable with an actively-developed but pre-1.0 library. If you need a battle-tested production client today, evaluate steam-vent as well.
Quick Start
Login with Refresh Token
use ;
async
Anonymous Login
use ;
async
Password Login with Steam Guard
// EAuthSessionGuardType re-exported from the steam_auth crate.
use ;
use EAuthSessionGuardType;
async
Cookie Login
Logs onto the CM using existing steamcommunity.com web session cookies. The
cookies themselves never reach the CM — they are exchanged at
https://steamcommunity.com/chat/clientjstoken for a short-lived web logon
token, which (together with the account name and SteamID returned by that
endpoint) authenticates the CM logon.
use SteamClient;
async
Refresh Token Persistence
The most common real-world flow: save the refresh token after first login and reuse it on subsequent runs. TokenStore handles serialisation to disk atomically.
use ;
async
Configuration
SteamOptions
// EConnectionProtocol lives in steam_client::options; use Default::default() for
// the common case or construct SteamOptions directly for fine-grained control.
use ;
use Duration;
LogOnDetails
use LogOnDetails;
Event System
The client uses a categorized event system for type-safe event handling:
Event Categories
| Category | Description | Events |
|---|---|---|
Auth |
Authentication | LoggedOn, LoggedOff, RefreshToken |
Connection |
Connection lifecycle | Connected, Disconnected, ReconnectAttempt, ReconnectFailed |
Friends |
Social features | FriendsList, PersonaState, FriendRelationship |
Chat |
Messaging | FriendMessage, FriendTyping |
Apps |
Games/licenses | LicenseList, ProductInfoResponse, PICSChanges, GCReceived |
Content |
Content delivery | RichPresence |
System |
Debug/errors | Debug, Error |
Event Loop
use ;
use Duration;
async
Event Helpers
// Assumes `event: SteamEvent` is in scope (e.g. from poll_event_timeout).
use SteamEvent;
// Check event category
event.is_auth; // Authentication event?
event.is_connection; // Connection event?
event.is_friends; // Friends event?
event.is_chat; // Chat event?
event.is_apps; // Apps event?
event.is_content; // Content event?
event.is_system; // System event?
// Get chat sender
if let Some = event.chat_sender
Services
Friends Service
use ;
use SteamID;
async
Chat Service
use SteamClient;
use SteamID;
async
Games Service
use SteamClient;
use SteamID;
use HashMap;
async
Idler Service
The IdlerHandle provides a way to automatically refresh your playing status at random intervals (15-30 minutes) to avoid bot detection patterns.
use ;
async
Apps Service
use ;
async
Store Service
use SteamClient;
async
App Auth Service
use SteamClient;
async
CDN Service
use SteamClient;
// Note: get_manifest requires a ContentServer reference and depot key obtained
// from the preceding calls; the full signature is shown below.
async
Account Service
use SteamClient;
async
Two-Factor Service
use SteamClient;
async
Game Coordinator Service
use ;
async
CS:GO/CS2 Service
use ;
use CSGOClient;
use SteamID;
async
Gift Service
use SteamClient;
async
Persona Cache
use ;
use SteamID;
use Duration;
async
Error Handling
use ;
async
LogOnResponse
After successful login, you receive:
Examples
Run the examples with:
# Basic bot - login, set status, play game
REFRESH_TOKEN="your_token"
# Chat bot - respond to messages
REFRESH_TOKEN="your_token"
# Friends list - dump all friends info
REFRESH_TOKEN="your_token"
# Anonymous login - no credentials needed
# Password login - interactive with Steam Guard
# Cookie login - mint a web logon token from steamcommunity.com cookies
STEAM_COOKIES="sessionid=...; steamLoginSecure=..."
# Licenses dumper - show owned games/packages
REFRESH_TOKEN="your_token"
# Rich presence - set custom game status
REFRESH_TOKEN="your_token"
# Token dumper - get refresh token from password login
Services Summary
| Service | Module | Key Types |
|---|---|---|
| Account | services::account |
AccountInfo, AccountLimitations, WalletInfo, VacBans, PrivacySettings |
| App Auth | services::appauth |
AuthSessionTicket, AuthSessionResult |
| Apps | services::apps |
AppInfo, PackageInfo, OwnedApp |
| CDN | services::cdn |
ContentServer, DepotManifest, ManifestFile, CdnAuthToken |
| Chat | services::chat |
ChatMessage, HistoryMessage, SendMessageResult |
| Chat Rooms | services::chatroom |
ChatRoom, ChatRoomGroup, ChatRoomMember, ChatRole |
| CS:GO/CS2 | services::csgo |
CSGOClient, LobbyConfig, LobbyData, JoinLobbyResult, LobbyMetadata |
| Economy | services::econ |
AssetClass, AssetClassInfo, TradeUrl, Emoticon, ProfileItem |
| Family Sharing | services::familysharing |
AuthorizedBorrower, AuthorizedDevice |
| Friends | services::friends |
Friend, FriendsGroup, AddFriendResult |
| Game Coordinator | services::gc |
GCMessage, GCProtoHeader, GCSendOptions, GCJobManager |
| Game Servers | services::gameservers |
GameServer |
| Gifts | services::gifts |
GiftDetails |
| Idler | services::idler |
IdlerService |
| Notifications | services::notifications |
Notification, NotificationType |
| Persona Cache | cache::persona |
PersonaCache, PersonaCacheConfig, CachedPersona |
| Published Files | services::pubfiles |
PublishedFileDetails, VoteData |
| Rich Presence | services::rich_presence |
RichPresenceData |
| Store | services::store |
StoreTag |
| Trading | services::trading |
TradeRestrictions |
| Two-Factor | services::twofactor |
TwoFactorSecrets |
Related Crates
| Crate | Description |
|---|---|
steamid-rs |
Steam ID parsing and formatting |
steam-enums |
Steam protocol enumerations |
steam-protos |
Protobuf message definitions |
steam-crypto-rs |
Cryptographic utilities (AES, RSA) |
steam-auth-rs |
Authentication session management |
steam-totp-rs |
TOTP code generation for Steam Guard |
steam-cm-provider |
CM server discovery |
steam-friend-code |
CS2 friend code encoding/decoding |
Testing
The crate includes comprehensive testing infrastructure:
use ;
use Duration;
License
MIT
Acknowledgements
This crate's API is deliberately modelled after node-steam-user by Nick Alverson — the struct names, method names, and event model are intentional mirrors of that library so that existing JS experience transfers directly to Rust.
The underlying Steam protocol knowledge comes largely from SteamKit2 (SteamRE), the canonical open-source C# reference implementation that the broader Steam ecosystem builds on.
No source code from either project was copied. Credit is given here because the design clearly stands on their shoulders.