steamr 🦀
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 make full use of this library. Visit https://steamcommunity.com/dev/apikey to obtain yours.
Example
use steamr::client::SteamClient;
use steamr::errors::SteamError;
fn main() -> Result<(), SteamError> {
let api_key = String::from("your-api-key");
let steam_client = SteamClient::from(api_key);
let steam_id = "some-steam-id";
let steam_lib = steam_client.get_library(&steam_id)?;
steam_lib.games.iter()
.filter(|g| g.playtime_forever > 60)
.for_each(|g| println!("{}", g.name));
Ok(())
}
There are some endpoints that don't require an API key. If you only need those,
you can use SteamClient
like so:
use steamr::client::SteamClient;
use steamr::errors::SteamError;
fn main() -> Result<(), SteamError> {
let steam_client = SteamClient::new();
let app_id = "10";
let news = steam_client.get_game_news(app_id, 5, 100)?;
news.game_news.iter()
.for_each(|n| println!("The article '{}' was written by '{}'", n.title, n.author));
Ok(())
}