https://github.com/benjaminhottell/rust-anki-connect-wrapper
Wrapper for Anki-Connect REST API written in Rust
https://github.com/benjaminhottell/rust-anki-connect-wrapper
anki anki-connect ankiconnect
Last synced: about 2 months ago
JSON representation
Wrapper for Anki-Connect REST API written in Rust
- Host: GitHub
- URL: https://github.com/benjaminhottell/rust-anki-connect-wrapper
- Owner: benjaminhottell
- License: other
- Created: 2025-08-18T02:09:39.000Z (10 months ago)
- Default Branch: main
- Last Pushed: 2025-08-28T02:04:19.000Z (10 months ago)
- Last Synced: 2025-08-28T09:31:58.321Z (10 months ago)
- Topics: anki, anki-connect, ankiconnect
- Language: Rust
- Homepage:
- Size: 43 KB
- Stars: 0
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# rust-anki-connect-wrapper
A thin wrapper around the [Anki-Connect REST API](https://git.sr.ht/~foosoft/anki-connect) for [Anki](https://apps.ankiweb.net/), written in Rust.
## Usage
Create a client wrapper
```rust
let anki = ankiconnect::Client::builder()
.with_url(args.url)
.build();
```
Make an API request
```rust
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);
};
```
## Testing
### Unit testing
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.
```rust
cargo test --lib
```
You can also run the doctests without an Anki instance running.
```rust
cargo test --doc
```
### Integration testing
Integration 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.
```rust
cargo test --tests stateless
```
In the future modifying tests could be added so it is best to specify `stateless` explicitly.
## Help wanted
Only a small subset of all of the API endpoints have been implemented. Pull requests to add support for more endpoints are welcome.