#joke #chuck #api #api-bindings #norris

norris-jokes

Chuck Norris jokes API sync & async fetcher library for Rust applications

3 unstable releases

0.2.0 Jun 19, 2024
0.1.1 Jun 18, 2024
0.1.0 Jun 18, 2024

#873 in Web programming

Download history 1/week @ 2024-07-22 43/week @ 2024-09-16 24/week @ 2024-09-23 1/week @ 2024-09-30

83 downloads per month

MIT/Apache

13KB
258 lines

Norris Jokes API

Chuck Norris jokes API sync & async fetcher library for Rust applications

Usage

Usage for synchronous calls

use norris_jokes::jokecategory::JokeCategory;

fn main() {
    let mut result = norris_jokes::get_random();
    println!("{:?}", result);
    
    result = norris_jokes::get_random_with_category(JokeCategory::Sport);
    println!("{:?}", result);
    
    let result_list = norris_jokes::get_with_query("sport");
    println!("{:?}", result_list);
}

Usage for asynchronous calls

use norris_jokes::jokecategory::JokeCategory;
use std::error::Error;

#[tokio::main]
async fn main() -> Result<(), Box<dyn Error>> {
    let mut joke = norris_jokes::get_random_async().await;
    println!("{:?}", joke);
    
    joke = norris_jokes::get_random_with_category_async(JokeCategory::Sport).await;
    println!("{:?}", joke);
    
    let result_list = norris_jokes::get_with_query_async("sport").await;
    println!("{:?}", result_list);

    Ok(())
}

Dependencies

~7–18MB
~237K SLoC