Crates.io | some-random-api |
lib.rs | some-random-api |
version | 0.3.0 |
source | src |
created_at | 2023-05-29 13:56:31.634647 |
updated_at | 2023-06-01 08:08:22.87865 |
description | An asynchronous API wrapper for Some Random API. |
homepage | |
repository | https://github.com/flazepe/some-random-api-rs |
max_upload_size | |
id | 877138 |
size | 51,819 |
An asynchronous API wrapper for Some Random API.
use some_random_api::{Client, WelcomeImage, WelcomeImageBackground};
use std::{error::Error, fs::write};
use tokio::main;
#[main]
async fn main() -> Result<(), Box<dyn Error>> {
// Create a client without an API key
let client = Client::new(None::<String>);
// Look up definition of a word
let definition = client.others.dictionary("resuscitate").await?;
println!("{:#?}", definition);
// Generate a welcome image
let welcome_image = client
.welcome
.image(
WelcomeImage::new(
"Username",
"0001",
"https://cdn.discordapp.com/embed/avatars/0.png",
"Guild Name",
194,
)
.set_background(WelcomeImageBackground::Night),
)
.await?;
// Save the welcome image to a file
write("welcome.png", welcome_image)?;
Ok(())
}
Read the documentation for more information.