| Crates.io | trace-moe |
| lib.rs | trace-moe |
| version | 1.0.3 |
| created_at | 2025-10-05 01:31:09.849063+00 |
| updated_at | 2025-10-11 00:51:49.504208+00 |
| description | Client library for the trace.moe anime scene search API. |
| homepage | https://github.com/benz206/trace-moe |
| repository | |
| max_upload_size | |
| id | 1868512 |
| size | 60,855 |
Rust client for the trace.moe anime scene search API.
reqwestmecargo add trace-moe
use trace_moe::tracemoe::{new_client_with_key, SearchQuery, SearchResponse, Episode};
#[tokio::main]
async fn main() {
let api_key = std::env::var("TRACE_MOE_API_KEY").ok();
let client = new_client_with_key(api_key.as_deref()).expect("client");
let query = SearchQuery {
url: Some("https://i.imgur.com/DLHIbog.png".to_string()),
anilist_id: None,
cut_borders: Some(true),
anilist_info: Some(false),
};
let resp: SearchResponse = client
.tracemoe_search_by_url(&query)
.await
.expect("search");
println!("{} results, error='{}'", resp.result.len(), resp.error);
for (idx, r) in resp.result.iter().enumerate() {
let episode = match &r.episode {
Some(Episode::Number(n)) => n.to_string(),
Some(Episode::Text(t)) => t.clone(),
None => "-".to_string(),
};
println!(
"#{} sim={:.2}% anilist={} file={} ep={} time={:.2}-{:.2}\n image={}\n video={}\n",
idx + 1,
r.similarity * 100.0,
r.anilist,
r.filename,
episode,
r.from,
r.to,
r.image,
r.video,
);
}
}
TRACE_MOE_API_KEY and use new_client_with_key(Some(key)).x-trace-key.let query = SearchQuery {
url: Some("https://example.com/image.jpg".into()),
anilist_id: None,
cut_borders: Some(true),
anilist_info: Some(true),
};
let results: SearchResponse = client.tracemoe_search_by_url(&query).await?;
let bytes = std::fs::read("./frame.jpg")?;
let results: SearchResponse = client.tracemoe_search_upload(bytes).await?;
let me = client.tracemoe_me().await?;
println!("quota={}, used={}", me.quota, me.quota_used);
new_client_with_key(Option<&str>) -> ClientClient::tracemoe_search_by_url(&SearchQuery) -> SearchResponse<TAnilist>Client::tracemoe_search_upload(bytes) -> SearchResponse<TAnilist>Client::tracemoe_me() -> MeResponseSearchQuery, SearchResponse<TAnilist>, SearchResult<TAnilist>, Episode, AnilistInfo, AnilistInfoTitle, MeResponseDocs: https://docs.rs/trace-moe
Run the included example:
cargo run --example quick
# with API key
TRACE_MOE_API_KEY=your_key cargo run --example quick
Licensed under MIT.