1 unstable release

0.1.0-alpha.0 Oct 11, 2019
0.0.0 Oct 10, 2019

#11 in #gg

ISC license

39KB
572 lines

ci-badge license-badge docs-badge rust badge

top-gg

An unofficial async Rust HTTP client around the top.gg API.

Installation

This library requires at least Rust 1.39.0.

Add the following to your Cargo.toml file:

[dependencies]
top-gg = "0.1.0-alpha.0"

Examples

Request a bot by ID:

use reqwest::Client as HttpClient;
use top_gg::Client;
use std::{
    env,
    error::Error,
};

#[tokio::main]
async fn main() -> Result<(), Box<Error>> {
    // Create the Reqwest Client.
    let reqwest_client = HttpClient::new();
    let token = env::var("TOP_GG_TOKEN")?;

    // Create the API Client with authorization.
    let client = Client::from(http_client, token);

    // Request the bot information.
    let bot = client.get_bot(270_198_738_570_444_801).await?;

    println!("The bot's name is: {}", bot.username);

    Ok(())
}

Dependencies

~7–11MB
~243K SLoC