[][src]Crate top_gg

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 std::env;
use top_gg::Client;

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

    // Create the API Client with authorization.
    let client = Client::new(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(())
}

Re-exports

pub use self::client::Client;
pub use self::error::Error;
pub use self::error::Result;

Modules

client

The client implementation around the API, and finalizer requests for configuring optional parameters.

error

Error enum with all possible reasons for errors and wrapping Result type.

model

Models mapping the top.gg API.

widget

Types for generating widget embed URLs.