rosu

Crates.iorosu
lib.rsrosu
version0.6.0
sourcesrc
created_at2020-02-21 16:09:45.266825
updated_at2023-07-08 15:55:33.000782
descriptionAn osu!api v1 wrapper
homepage
repositoryhttps://github.com/MaxOhn/rosu
max_upload_size
id211204
size131,162
Badewanne3 (MaxOhn)

documentation

https://docs.rs/rosu/

README

crates.io docs

rosu

rosu is a rust wrapper for the osu!api v1 .

The wrapper provides access to the beatmap, user, score, user-best, user-recent, and match endpoints.

Note: Only the osu!api v1 is supported. If you want to use v2, check out rosu-v2.

An API key can be generated here.

Examples

use rosu::{
    model::*,
    Osu, OsuResult,
};
use time::OffsetDateTime;

#[tokio::main]
async fn main() -> OsuResult<()> {
    // Initialize the client
    let osu = Osu::new("osu_api_key");

    // --- Retrieving top scores ---
    let mut scores = osu.top_scores("Badewanne3")
        .mode(GameMode::Mania)
        .limit(4)
        .await?;
    match scores.pop() {
        Some(score) => {
            // Retrieve user of the score
            let user = score.get_user(&osu).mode(GameMode::Osu).await?;
            // ...
        }
        None => println!("No top scores found"),
    }

    // --- Retrieving beatmaps ---
    let mut maps = osu.beatmaps()
        .mode(GameMode::Mania)
        .limit(3)
        .since(OffsetDateTime::from_unix_timestamp(1542150088).unwrap())
        .mapset_id(945496)
        .await?;
    if let Some(map) = maps.pop() {
        let leaderboard: Vec<Score> = map
            .get_global_leaderboard(&osu)
            .limit(13)
            .await?;
        // ...
    }
    // --- Retrieving user ---
    let user: Option<User> = osu.user("Badewanne3").await?;
    // ...

    // --- Retrieving match ---
    let osu_match: Match = osu.osu_match(58494587).await?;
    // ...

    Ok(())
}

Features

Flag Description deps
serialize Provides serialization for all types in the model module serde-repr
metrics Make the client count each request type and enable a method on the client to get a prometheus::IntCounterVec prometheus
Commit count: 142

cargo fmt