| Crates.io | kanjiwrapper |
| lib.rs | kanjiwrapper |
| version | 0.4.0 |
| created_at | 2025-08-08 00:24:41.016205+00 |
| updated_at | 2025-08-08 11:24:35.205753+00 |
| description | Wrapper for kanjiapi.dev |
| homepage | |
| repository | |
| max_upload_size | |
| id | 1786038 |
| size | 49,381 |
kanjiwrapper is a Rust client library for accessing the KanjiAPI, a REST API providing detailed data about Japanese kanji characters and words.
reqwest and tokiouse anyhow::Result;
use kanjiwrapper::{KanjiResponse, get};
use reqwest::Client;
#[tokio::main]
async fn main() -> Result<()> {
let client = Client::new(); //Set up your Client
let kanjichar_details = get(&client, KanjiResponse::SingleKanji('夏')).await?; // Fetch details for a single kanji character
let kanjichar_content = kanjichar_details.into_kanji_detail()?; // Unwrap the KanjiDetail struct
println!("{}", kanjichar_content.meanings[0]); //Get the first meaning of the kanji
println!("Kunyomi readings: {:?}", kanjichar_content.kun_readings); //Get the kun reading
println!("Onyomi readings: {:?}", kanjichar_content.on_readings); //Get the on reading
let kanjilist = get(&client, KanjiResponse::Jlpt(4)).await?; // Fetch a list of kanji for JLPT level 4
let kanjilist_content = kanjilist.into_kanji_chars()?; // Unwrap the Vec<String>
println!("Kanji list for JLPT 4: {:?}", kanjilist_content);
let wordsusingkanji = get(&client, KanjiResponse::Words('日')).await?; //Fetch a list of words containing the kanji supplied
let wordsusingkanji_content = wordsusingkanji.into_words()?; // Unwrap the Vec<Word>
println!("Words using '日': {:#?}", wordsusingkanji_content);
Ok(())
}
Add this to your Cargo.toml:
[dependencies]
kanjiwrapper = "0.4"