Expand description
Steam client for Rust.
This crate provides a Steam client for individual and anonymous user account types. Three authentication paths are supported:
- Refresh token — load a previously saved token with
TokenStore(recommended for long-running bots). - Password — call
SteamClient::log_on_with_password; handle thecrate::SteamError::SteamGuardRequirederror to supply a Steam Guard code. - Cookie — call
SteamClient::log_on_with_cookieswith existingsteamcommunity.comsession cookies; the library exchanges them for a short-lived web logon token internally.
§Example: refresh token (persistent session)
use steam_client::{AuthEvent, LogOnDetails, SteamClient, SteamEvent, TokenStore};
#[tokio::main]
async fn main() {
let mut client = SteamClient::new(Default::default());
let token_store = TokenStore::new("steam_tokens.json");
// Load previous session if available, fall back to empty details on first run.
let logon_details = token_store.load(None).unwrap_or_default();
client.log_on(logon_details).await.unwrap();
// In your event loop, persist the token whenever it is refreshed.
// while let Some(event) = client.poll_event_timeout(Duration::from_secs(30)).await.unwrap() {
// if let SteamEvent::Auth(AuthEvent::RefreshToken { token, account_name }) = event {
// token_store.save(account_name, token, 0).unwrap();
// }
// }
}§Example: cookie login
use steam_client::SteamClient;
#[tokio::main]
async fn main() {
let mut client = SteamClient::new(Default::default());
// Cookies must include at least `steamLoginSecure` for the target account.
let cookies = "sessionid=abc123; steamLoginSecure=76561198000000000%7C%7Ctoken";
let response = client.log_on_with_cookies(cookies).await.unwrap();
println!("Logged in as {}", response.steam_id.steam3());
}Re-exports§
pub use client::AccountEvent;pub use client::AppChange;pub use client::AppInfoData;pub use client::AppsEvent;pub use client::AuthEvent;pub use client::CSGOEvent;pub use client::ChatEvent;pub use client::ConnectionEvent;pub use client::ContentEvent;pub use client::CsgoClientHello;pub use client::CsgoCommendation;pub use client::CsgoPartyEntry;pub use client::CsgoRanking;pub use client::CsgoWelcome;pub use client::FriendEntry;pub use client::FriendsEvent;pub use client::LicenseEntry;pub use client::MessageHandler;pub use client::MockHandles;pub use client::NotificationsEvent;pub use client::PackageChange;pub use client::PackageInfoData;pub use client::SteamClient;pub use client::SteamClientBuilder;pub use client::SteamEvent;pub use client::SteamEventStream;pub use client::SystemEvent;pub use client::UserPersona;pub use internal::HeartbeatManager;pub use internal::JobManager;pub use internal::JobResponse;pub use internal::MessageSender;pub use internal::MockMessageSender;pub use internal::ReconnectManager;pub use internal::ReconnectState;pub use internal::SentMessage;pub use internal::SessionInfo;pub use persistence::TokenStore;pub use services::AccountInfo;pub use services::AccountLimitations;pub use services::AddFriendResult;pub use services::AppInfo;pub use services::AppInfoRequest;pub use services::AssetClass;pub use services::AssetClassInfo;pub use services::AuthSessionResult;pub use services::AuthSessionTicket;pub use services::AuthorizedBorrower;pub use services::AuthorizedDevice;pub use services::CdnAuthToken;pub use services::ChatMessage;pub use services::ChatRole;pub use services::ChatRoom;pub use services::ChatRoomGroup;pub use services::ChatRoomMember;pub use services::ChatRoomMessage;pub use services::ContentServer;pub use services::DepotManifest;pub use services::EmailInfo;pub use services::Emoticon;pub use services::EquippedProfileItems;pub use services::FileChunk;pub use services::Friend;pub use services::FriendMessageSession;pub use services::FriendsGroup;pub use services::GCMessage;pub use services::GCProtoHeader;pub use services::GCSendOptions;pub use services::GameServer;pub use services::HistoryMessage;pub use services::IdlerHandle;pub use services::InviteLinkInfo;pub use services::ManifestFile;pub use services::Notification;pub use services::NotificationType;pub use services::OwnedApp;pub use services::OwnedProfileItems;pub use services::PackageInfo;pub use services::PackageInfoRequest;pub use services::PrivacySettings;pub use services::ProfileItem;pub use services::PublishedFileDetails;pub use services::RichPresenceData;pub use services::RolePermissions;pub use services::SendMessageResult;pub use services::SteamGuardDetails;pub use services::TradeRestrictions;pub use services::TradeUrl;pub use services::TwoFactorSecrets;pub use services::VacBans;pub use services::VoteData;pub use services::WalletInfo;pub use utils::Clock;pub use utils::HttpClient;pub use utils::HttpResponse;pub use utils::MockClock;pub use utils::MockHttpClient;pub use utils::MockRequest;pub use utils::MockRng;pub use utils::ReqwestHttpClient;pub use utils::Rng;pub use utils::SystemClock;pub use utils::ThreadRng;
Modules§
- cache
- Cache module for Steam client data.
- client
- Client module containing core Steam client implementation.
- internal
- Internal infrastructure modules.
- persistence
- services
- Steam service handlers.
- utils
- Utility modules for parsing and helper functions.
Structs§
- Heartbeat
Options - Heartbeat configuration options.
- LogOn
Details - Details for logging on to Steam.
- LogOn
Response - Response from a successful login.
- Reconnect
Config - Reconnection configuration.
- SteamID
- Represents a Steam ID with all its components.
- Steam
Options - Options for the Steam client.
Enums§
- EAccount
Type - EApp
Type - EChat
Entry Type - EClan
Relationship - ECurrency
Code - EFriend
Relationship - ELicense
Type - EPayment
Method - EPersona
State - EPlatform
Type - EResult
- EServer
Type - EUniverse
- Steam
Error - Errors that can occur when using the Steam client.