use steam_user::{SteamID, SteamUser, SteamUserError};
use steam_user::types::{AppId, ContextId};
use tracing::info;
#[tokio::main]
async fn main() -> Result<(), SteamUserError> {
tracing_subscriber::fmt::init();
let community = SteamUser::new(&["steamLoginSecure=76561198012345678||YOUR_ACCESS_TOKEN", "sessionid=YOUR_SESSION_ID"])?;
let target_steam_id = SteamID::from(76561198012345678u64);
let app_id = AppId::new(730);
let context_id = ContextId::new(2);
info!("Fetching inventory for {}...", target_steam_id.steam_id64());
info!("App ID: {}, Context ID: {}", app_id, context_id);
match community.get_user_inventory_contents(target_steam_id, app_id, context_id).await {
Ok(items) => {
info!("\nFound {} items:", items.len());
for (i, item) in items.iter().enumerate().take(10) {
info!("\n=== Item {} ===", i + 1);
info!(" Asset ID: {}", item.assetid);
info!(" Name: {}", item.desc.name);
info!(" Market Hash Name: {}", item.desc.market_hash_name);
info!(" Type: {}", item.desc.item_type);
info!(" Tradable: {}", item.desc.tradable);
info!(" Marketable: {}", item.desc.marketable);
if item.amount > 1 {
info!(" Amount: {}", item.amount);
}
}
if items.len() > 10 {
info!("\n... and {} more items", items.len() - 10);
}
}
Err(e) => {
info!("Failed to fetch inventory: {}", e);
}
}
info!("\n\n=== Steam Trading Cards ===");
let steam_app_id = AppId::new(753); let cards_context_id = ContextId::new(6);
match community.get_user_inventory_contents(target_steam_id, steam_app_id, cards_context_id).await {
Ok(items) => {
info!("Found {} community items", items.len());
let cards: Vec<_> = items.iter().filter(|item| item.desc.item_type.contains("Card")).collect();
info!("Trading cards: {}", cards.len());
for card in cards.iter().take(5) {
info!(" - {} ({})", card.desc.name, card.desc.market_hash_name);
}
}
Err(e) => {
info!("Failed to fetch community items: {}", e);
}
}
Ok(())
}