Crate steamr

source ·
Expand description

§steamr 🦀

crates.io Documentation Apache-2 licensed CI

steamr is a simple Rust library to help you to interact with Valve’s Steam API. It uses the reqwest crate under the hood.

§Requirements

You need a valid API key to use this library. Visit https://steamcommunity.com/dev/apikey to obtain yours.

§Example

use steamr::client::SteamClient;
use steamr::errors::SteamError;
use steamr::games::get_owned_games;

fn main() -> Result<(), SteamError> {
    // Create a new client that will be used to communicate with Steam's API. 
    let api_key = String::from("your-api-key");
    let steam_client = SteamClient::new(api_key);
    
    // Get a list of all games from the user with the provided Steam ID (given that they are publicly visible)
    let steam_id = "some-steam-id";
    let steam_lib = get_owned_games(&steam_client, &steam_id)?;
    
    // Print out the games that were played for more than an hour.
    steam_lib.games.iter()
        .filter(|g| g.playtime_forever > 60)
        .for_each(|g| println!("{}", g.name));
    
    Ok(())
}

Modules§

  • The Steam API client
  • Custom error types
  • Functions to handle any friends-related data
  • Contains all functionalities around games