AnkiConnect findCards returns empty [] despite cards existing; notesInfo errors ('int' object is not iterable)

Goal:
I’m trying to create a custom local web-based interface (HTML/CSS/JS) to study my existing Anki cards. The key features are displaying multiple cards at once (e.g., 10 cards in two columns), allowing front/back selection, and using Anki’s scheduling via Again/Hard/Good/Easy buttons.

Approach:
Using the AnkiConnect add-on to allow my local HTML/JS application (opened via file://) to interact with my running Anki Desktop application.

Core Problem:
AnkiConnect’s findCards action consistently returns an empty result array ({“result”: , “error”: null}) for any query I try (e.g., deck:“My Deck” limit:1, deck:* limit:1, limit:1). This happens despite the fact that:

  1. Cards definitely exist in the specified decks.

  2. The exact same query strings (e.g., deck:“My Deck”) work correctly and find cards when used directly in the Anki Desktop Browser search bar.

Secondary Problem:
When attempting to bypass findCards and fetch note data directly using a known Note ID via the notesInfo action, AnkiConnect returns {“result”: null, “error”: “‘int’ object is not iterable”}. This suggests a deeper issue than just the search function.

Key Finding:
Both the findCards empty result and the notesInfo error persist even when testing on a completely new, clean Anki profile with only one simple card (“Basic” type) in a new deck (“TestDeck”). This strongly indicates the issue is not specific to my main collection’s data or structure.

Troubleshooting Steps Performed:

  1. Verified Card Existence: Confirmed cards exist in relevant decks using Anki Browser.

  2. Tested Queries in Anki Browser: Confirmed the exact query strings used via API work correctly within Anki’s own Browser search.

  3. Direct API Calls: Used direct fetch commands from the browser’s developer console, bypassing my custom app’s code. The issues (findCards returning , notesInfo erroring) were reproduced here.

  4. AnkiConnect Config: Verified AnkiConnect’s CORS settings (webCorsOriginList) includes “null” to allow requests from file:// origins. The config was confirmed correct. Basic actions like version and deckNames work correctly via the API.

  5. Anki Maintenance: Ran Anki’s “Check Database” tool.

  6. Add-on Conflicts: Disabled all other Anki add-ons except AnkiConnect; the issue persisted.

  7. Reinstall AnkiConnect: Deleted and reinstalled the AnkiConnect add-on (v6 is reported by the version action).

  8. Anki Version Downgrade: Issue occurred on my original latest Anki version. Downgraded to Anki 23.10.1 (tried Qt6 build); the issue persisted on both. Reinstalled the latest Anki version – issue persists.

  9. Clean Anki Profile: Created a new Anki user profile, added one card, ensured AnkiConnect was enabled and CORS configured; the issue persisted on this clean profile.

  10. System Firewall/Antivirus: Temporarily disabled Windows Defender Firewall (active profile) and any relevant real-time antivirus protection; the issue persisted.

  11. Different Browsers: Tested direct fetch calls from multiple browsers (e.g., Chrome, Firefox, Edge); the issue persisted.

  12. Port Conflicts: Used netstat to confirm port 8765 is listened on by anki.exe when Anki is running and free otherwise.

  13. AnkiConnect Logging: Enabled apiLogPath. The log file successfully recorded incoming requests (findCards, notesInfo) and their corresponding replies ({“result”: , “error”: null} for findCards, {“result”: null, “error”: “‘int’ object is not iterable”} for notesInfo) but showed no internal error messages or stack traces within AnkiConnect itself during the processing of these actions.

System Information:

  • OS: Windows 11 Home

  • Anki Versions Tested: Latest stable (e.g., 24.04.1), 23.10.1 (Qt6).

Question:
Given that findCards returns empty and notesInfo errors even on a clean profile, despite basic actions working and no errors logged by AnkiConnect itself, has anyone encountered a similar issue or have any suggestions for diagnosing this further? It seems like a deeper incompatibility or environmental issue affecting how AnkiConnect interacts with Anki’s core data handling on my specific machine.

You can check against yomitan/ext/js/comm/anki-connect.js at a2f594bbb4fbbe2daf5b2e539e5c184e9da852df · yomidevs/yomitan · GitHub and its uses to confirm that the requests you’re making are properly formatted

That method expects an array of note ids, even if it’s just an array of 1. The fact that you’re getting back a reply suggests it’s neither a cors nor an api key issue at least