Expand description
A complete, async-first Rust client for the AnkiConnect API.
This crate provides type-safe access to all AnkiConnect actions, allowing you to programmatically interact with Anki from Rust applications.
§Quick Start
use ankit::AnkiClient;
// Create a client with default settings (localhost:8765)
let client = AnkiClient::new();
// Check that AnkiConnect is running
let version = client.misc().version().await?;
println!("AnkiConnect version: {}", version);§Client Configuration
Use the builder pattern for custom configuration:
use std::time::Duration;
use ankit::AnkiClient;
let client = AnkiClient::builder()
.url("http://localhost:8765")
.api_key("your-api-key")
.timeout(Duration::from_secs(60))
.build();§Action Groups
Operations are organized into groups accessible from the client:
AnkiClient::cards()- Find, inspect, suspend, and answer cardsAnkiClient::decks()- Create, delete, and configure decksAnkiClient::gui()- Control Anki’s graphical interfaceAnkiClient::media()- Store, retrieve, and manage media filesAnkiClient::models()- Manage note types, fields, and templatesAnkiClient::notes()- Add, find, update, and delete notesAnkiClient::statistics()- Review history and collection statisticsAnkiClient::misc()- Version, sync, profiles, and other miscellaneous operations
§Requirements
- Anki must be running with the AnkiConnect add-on installed
- By default, the client connects to
http://127.0.0.1:8765
§Query Builder
Use the QueryBuilder for type-safe query construction:
use ankit::QueryBuilder;
let query = QueryBuilder::new()
.deck("Japanese")
.is_due()
.not_suspended()
.lapses_gte(3)
.build();Re-exports§
pub use client::AnkiClient;pub use client::ClientBuilder;pub use error::Error;pub use error::Result;pub use types::CanAddResult;pub use types::CardAnswer;pub use types::CardInfo;pub use types::CardModTime;pub use types::CardTemplate;pub use types::CreateModelParams;pub use types::DeckConfig;pub use types::DeckStats;pub use types::DuplicateScope;pub use types::Ease;pub use types::FieldFont;pub use types::FindReplaceParams;pub use types::LapseConfig;pub use types::MediaAttachment;pub use types::ModelField;pub use types::ModelStyling;pub use types::NewCardConfig;pub use types::Note;pub use types::NoteBuilder;pub use types::NoteField;pub use types::NoteInfo;pub use types::NoteModTime;pub use types::NoteOptions;pub use types::ReviewConfig;pub use types::StoreMediaParams;pub use actions::MultiAction;pub use actions::ReviewEntry;pub use query::OrBuilder;pub use query::QueryBuilder;