Crate steam_api

Source
Expand description

Simple crate to interact with the Steam API

Build status Crates.io Docs.rs

# Running the example
API_KEY=XXXXXXXXXXXXXXXXXXX cargo run --example example_program

# Running the tests
API_KEY=XXXXXXXXXXXXXXXXXXX cargo test

§Example usage

fn main() -> anyhow::Result<()> {
    let steamids = vec![
        "76561198421169032",
        "76561198149368420",
    ];

    for user in steam_api::get_profile_info(&steamids, &std::env::var("API_KEY")?)?.user {
        match user.steamid.as_str() {
            "76561198421169032" => {
                println!("Persona Name\t{}", user.personaname);
                println!("Steam Level\t{}", user.player_level);
                println!("NumberOfVACBans\t{}", user.NumberOfVACBans);
                assert_eq!(user.personaname, "dind");
            }
            "76561198149368420" => {
                println!("Persona Name\t{}", user.personaname);
                println!("Steam Level\t{}", user.player_level);
                println!("NumberOfVACBans\t{}", user.NumberOfVACBans);
                assert_eq!(user.personaname, "Gone compilin'");
                assert!(user.VACBanned);
            }
            _ => (),
        }
    }
    Ok(())
}

§API Key

Get your API Key here

Modules§

functions
structs

Functions§

get_friends_list
Calls the GetFriendList API
get_player_bans
Calls the GetPlayerBans API
get_player_summaries
Calls the GetPlayerSummaries API
get_profile_info
Calls all the APIs builds the structs::profile::Users struct
get_steam_level
Calls the GetSteamLevel API