topstats 0.1.0

Rust SDK for the TopStats.gg API - Discord bot statistics tracking
Documentation

TopStats Rust SDK

Rust SDK for the TopStats.gg API - Discord bot statistics from Top.gg.

Installation

[dependencies]
topstats = "0.1.0"

For blocking mode:

[dependencies]
topstats = { version = "0.1.0", default-features = false, features = ["blocking", "ureq-client"] }

Usage

use topstats::{Client, RankingsQuery, SortBy};

#[tokio::main]
async fn main() -> Result<(), topstats::Error> {
    let client = Client::new("your-api-token")?;

    // Get bot information
    let bot = client.get_bot("432610292342587392").await?;
    println!("{} has {} monthly votes", bot.name, bot.monthly_votes);

    // Get rankings
    let rankings = client
        .get_rankings(RankingsQuery::default().sort_by(SortBy::MonthlyVotes).limit(10))
        .await?;

    for bot in &rankings.data {
        println!("#{}: {}", bot.monthly_votes_rank, bot.name);
    }

    Ok(())
}

Links

License

MIT