A Rust library for interacting with the Hoyo-lab API for Genshin Impact, Honkai Impact 3rd, and other Hoyoverse games.
- Fully Type-Safe: Take advantage of Rust's type system for API responses
- Async by Default: Built on
tokioandreqwestfor efficient async operations - Error Handling: Comprehensive error types with
thiserror - Optional Blocking Support: Use the blocking API with the
blockingfeature - TLS Flexibility: Choose between
native-tlsorrustlsbackends
Install through cargo:
cargo add hoyo-rsuse hoyo_rs::Client;
#[tokio::main]
async fn main() -> anyhow::Result<()> {
// Create a client with cookies
let cookies = [
("ltuid", "119480035"),
("ltoken", "cnF7TiZqHAAvYqgCBoSPx5EjwezOh1ZHoqSHf7dT"),
];
let client = Client::new().cookies(cookies);
// Fetch Genshin Impact user data
let user_data = client.get_genshin_user(710785423).await?;
println!("User has a total of {} characters", user_data.stats.characters);
Ok(())
}Enable the blocking feature and use the synchronous API:
[dependencies]
hoyo-rs = { version = "0.0.1", features = ["blocking"] }use hoyo_rs::Client;
fn main() -> anyhow::Result<()> {
let cookies = [
("ltuid", "119480035"),
("ltoken", "cnF7TiZqHAAvYqgCBoSPx5EjwezOh1ZHoqSHf7dT"),
];
let client = Client::new().cookies(cookies);
let user_data = client.get_genshin_user(710785423)?;
println!("User has a total of {} characters", user_data.stats.characters);
Ok(())
}- default: Includes the
native-tlsfeature - native-tls: Uses the native TLS backend for HTTPS requests
- rustls: Uses the pure-Rust rustls backend for HTTPS requests
- blocking: Enables synchronous API methods
This library handles authentication tokens and cookies. Never share your tokens or expose them in client-side code.
Contributions are welcome! Please feel free to submit a Pull Request.
This project is licensed under the MIT License - see the LICENSE file for details.
This library is inspired by genshin.py, a Python library for the Hoyoverse API.