anki-connect icon indicating copy to clipboard operation
anki-connect copied to clipboard

Allow interfacing with notes via GUID instead of note ID

Open orgtre opened this issue 1 year ago • 1 comments

All Anki-Connect actions operating on notes via some ID currently require note ID's ("noteId") as arguments and provide note ID's as return values. This severely limits the types of applications that can make use of Anki-Connect.

Note ID's are unsuitable as ID for many applications, especially those that involve multiple users, as they are only unique within a users profile. Just because of this, applications such as CrowdAnki and ki, had to write their own interface to Anki from scratch instead of making use of Anki-Connect. Moreover, several applications which rely fully on Anki-Connect are currently restricted in the features they can provide because of this limitation. Examples include org-anki, anki-editor, and my fork of it.

Anki notes are already stored with globally unique identifiers (GUIDs) in Anki's database, so it should not be very difficult to make use of them in Anki-Connect's actions. To enable a complete switch to GUIDs in the above mentioned applications it would be enough if the following actions were to (optionally) accept guid as input instead of noteId: notesInfo, updateNoteFields, deleteNotes, addTags, and removeTags; and if the following actions were to (optionally) return guid's instead noteId's: addNote and findNotes.

To people familiar with Anki-Connect's codebase: How feasible would this be? Any pointers on how to implement this? Would such a pull request have a chance of being accepted? Maybe someone else also has an interest in making this happen?

orgtre avatar Nov 19 '22 20:11 orgtre

I don't have a problem with this kind of a change; the main thing is that we don't want to break backwards compatibility with older clients that rely on note ID. This could be as simple as determining the type of the parameter at runtime and changing behavior accordingly.

FooSoft avatar Nov 19 '22 20:11 FooSoft