9 unstable releases (3 breaking)
0.4.3 | Sep 10, 2024 |
---|---|
0.4.2 | Aug 4, 2024 |
0.3.1 | Jul 25, 2024 |
0.2.0 | Jul 24, 2024 |
0.1.1 | Jul 22, 2024 |
#1297 in Web programming
650 downloads per month
40KB
989 lines
Smite-rs
Smite-rs is a Rust library for interacting with the Smite API. It is designed to be easy to use and provide a simple interface for interacting with the API.
Quick Start
In order to use the Smite API, you will need to obtain a dev-id and auth-key from the Hi-Rez Developer Portal. Once you have it, you can use it to create a new Client
instance and start making requests.
use smite::client::Client;
async fn example() -> Result<(), Box<dyn std::error::Error>> {
let client = Client::new("my-dev-id".to_string(), "my-auth-key".to_string());
let player_name = "player-name";
// API may return multiple players with the same name
let player_info = &client.get_player(player_name).await?[0];
println!(
"Player {player_name} played for {} hours.",
player_info.hours_played
);
Ok(())
}
Custom requests
Some endpoints are not yet fully supported by library.
In this case you can use Client::make_request
method to make custom requests.
use serde_json::Value;
use smite::client::Client;
async fn example() -> Result<(), Box<dyn std::error::Error>> {
let dev_id = "my-dev-id";
let auth_key = "my-auth-key";
let client = Client::new(dev_id.to_string(), auth_key.to_string());
let res: Value = client.make_request("gettopmatches", true, &[]).await?;
// ...
// Or if you want to use custom struct make sure it implements `serde_json::Deserialize`
// let response: MyCustomStruct = client.make_request("gettopmatches", true, &[]).await?;
Ok(())
}
Dependencies
~8–19MB
~266K SLoC