Find cards implementation with ankiconnect #101
Draft
+728
−57
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Reviewing changes in AnkiConnectAndroid to draft the PR details:
[5 tools called]
Pull request description for AnkiConnectAndroid:
Title
Add
findCardsandcardsInfoactions for Anki-Connect compatibilityDescription
Adds support for
findCardsandcardsInfoactions, matching desktop Anki-Connect. Enables card-based workflows and improves compatibility with desktop add-ons and tools.Changes
New Features
findCardsaction — Search cards using Anki query syntax"deck:MyDeck prop:ivl<20 -is:new")/cardsendpoint (updated on my own forked versioncardsInfoaction — Get detailed information for card IDsImplementation Details
New Files
CardAPI.java— New API class for card operationsfindCards(String query)— Search cards using Anki query syntaxcardsInfo(List<Long> cardIds)— Get card informationModified Files
IntegratedAPI.javapublic final CardAPI cardAPIfieldcardAPIin constructorAnkiAPIRouting.javafindCardscase to routing switchcardsInfocase to routing switchfindCards()andcardsInfo()private methodsParser.javagetCardQuery(JsonObject raw_data)— Extracts query parameter forfindCardsgetCardIds(JsonObject raw_data)— Extracts card IDs array forcardsInfoTechnical Highlights
Robust Authority Detection
com.ichi2.anki.flashcards) and debug (com.ichi2.anki.debug.flashcards) authorities/cardsendpoint)Performance Optimizations
cardsInfo(collects unique note IDs, fetches once)Error Handling
IllegalArgumentExceptionfor unsupported URIsSecurityExceptionfor permission issuesUse Cases Enabled
Anki-Connect Desktop Compatibility
findCards/cardsInfonow work with AndroidCard-Based Filtering
prop:ivl<20deck:"MyDeck"-is:newStudy Applications
API Examples
findCards
{ "action": "findCards", "version": 6, "params": { "query": "deck:MyDeck prop:ivl<20 -is:new" } }Response:
{ "result": [1001, 1002, 1003, ...], "error": null }cardsInfo
{ "action": "cardsInfo", "version": 6, "params": { "cards": [1001, 1002, 1003] } }Response:
{ "result": [ { "cardId": 1001, "note": 12345, "due": 1707246949, "interval": 5, "factor": 2.5, "reps": 3, "modelName": "Basic", "fields": { "Front": {"value": "Hello", "order": 0}, "Back": {"value": "你好", "order": 1} } }, ... ], "error": null }Testing
Dependencies
Requires AnkiDroid with
/cardsendpoint support/cardsContentProvider endpointcontent://authority/cardswith query parameter for searchingcontent://authority/cards/<cardId>for direct card accessdue,interval,ease_factor,reviewsBackward Compatibility
Related Issues
Checklist
This PR significantly improves Anki-Connect compatibility and enables card-based workflows that were previously impossible on Android.
Additional Notes for Maintainers
/cardsendpoint