Skip to content

teehee567/hoyo-rs

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 

Repository files navigation

hoyo-rs

A Rust library for interacting with the Hoyo-lab API for Genshin Impact, Honkai Impact 3rd, and other Hoyoverse games.

Crates.io Documentation License: MIT

Features

  • Fully Type-Safe: Take advantage of Rust's type system for API responses
  • Async by Default: Built on tokio and reqwest for efficient async operations
  • Error Handling: Comprehensive error types with thiserror
  • Optional Blocking Support: Use the blocking API with the blocking feature
  • TLS Flexibility: Choose between native-tls or rustls backends

Installation

Install through cargo:

cargo add hoyo-rs

Usage

use 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(())
}

Blocking Usage

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(())
}

Features

  • default: Includes the native-tls feature
  • 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

Security Note

This library handles authentication tokens and cookies. Never share your tokens or expose them in client-side code.

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

License

This project is licensed under the MIT License - see the LICENSE file for details.

Acknowledgements

This library is inspired by genshin.py, a Python library for the Hoyoverse API.

About

API wrapper for Hoyolab.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors