nekosbest

Rust API wrapper for nekos.best.

Usage

toml [dependencies] nekosbest = "0.18"

Example

```rust ,no_run

[tokio::main]

async fn main() -> Result<(), Box> { let imgurl: String = nekosbest::get(nekosbest::Category::Neko).await?.url; println!("{}", imgurl); Ok(()) } ```

Or with an amount (amount is capped at 20 by the server):

```rust ,no_run

[tokio::main]

async fn main() -> Result<(), Box> { let images = nekosbest::get_amount(nekosbest::Category::Neko, 20).await?.0; println!("{:?}", images); Ok(()) } ```

Or if you already have a Client that you want to use, use get_with_client and get_with_client_amount respectively:

```rust ,no_run

[tokio::main]

async fn main() -> Result<(), Box> { let client = nekosbest::client::Client::new(nekosbest::client::ClientConfig::default()); let details = nekosbest::getwithclient(&client, nekosbest::Category::Neko) .await? .details .tryintoimage() .unwrap(); println!("Source: {}", details.sourceurl); println!("Artist: {}", details.artistname); println!("Artist link: {}", details.artist_href); Ok(()) } ```

There is another property called details:

For Category::Neko, Category::Husbando, Category::Kitsune, Category::Waifu (image endpoints):

```rust ,no_run

[tokio::main]

async fn main() -> Result<(), Box> { let details = nekosbest::get(nekosbest::Category::Neko) .await? .details .tryintoimage() .unwrap(); println!("Source: {}", details.sourceurl); println!("Artist: {}", details.artistname); println!("Artist link: {}", details.artist_href); Ok(()) } ```

For everything else (GIF endpoints):

```rust ,no_run

[tokio::main]

async fn main() -> Result<(), Box> { let details = nekosbest::get(nekosbest::Category::Pat) .await? .details .tryintogif() .unwrap(); println!("Anime name: {}", details.anime_name); Ok(()) } ```

Or with the strong-types feature, bringing strong types guarantees for details, so no unwrap / expect for the details type:

Warning: Experimental, may change at any point in the future.

Remember to add the st_ in front of get, get_amount, get_with_client and get_with_client_amount.

Neko:

```rust ,no_run

[tokio::main]

async fn main() -> Result<(), Box> { let resp = nekosbest::stget::().await?; let details = resp.details(); println!("Artist: {}", details.artistname); println!("Artist link: {}", details.artisthref); println!("Source: {}", details.sourceurl); Ok(()) } ```

GIF:

```rust ,no_run

[tokio::main]

async fn main() -> Result<(), Box> { let details = nekosbest::stget::().await?.details; println!("Anime name: {}", details.animename); Ok(()) } ```

Blocking client

All functions become blocking when used with the "blocking" feature.