A thin wrapper around the Anki-Connect REST API for Anki, written in Rust.
Create a client wrapper
let anki = ankiconnect::Client::builder()
.with_url(args.url)
.build();Make an API request
let browse_query = "prop:ivl>=21";
let browse_request = GuiBrowse::builder()
.query(browse_query)
.build();
if let Err(e) = anki.invoke(&browse_request).await {
eprintln!("Failed to display browser: {e}");
std::process::exit(1);
};Unit tests can be executed without an Anki instance running. These test internal components only, and do not make any connections to Anki or Anki-Connect.
cargo test --libYou can also run the doctests without an Anki instance running.
cargo test --docIntegration tests require an Anki instance with the Anki-Connect plugin installed, available at the default port on localhost.
The stateless tests will run a series of non-modifying API requests (e.g. version). These should not modify the state of the Anki instance, and should therefore be 'safe' to run.
cargo test --tests statelessIn the future modifying tests could be added so it is best to specify stateless explicitly.
Only a small subset of all of the API endpoints have been implemented. Pull requests to add support for more endpoints are welcome.