Modifying decks with python: examples or documentation?

Hello everyone!
I’m new to scripting for Anki Decks and I feel I struggle to find where to get documentation or information.

I found the genanki project to generate Decks, which I was easily able to achieve, but I can’t find something handy to modify existing decks, improve them and use them again as if nothing happened in between.

I’m trying to use Python to modify a decks I’m currently using to learn things. I have several ideas but for instance in a vocabulary deck I’d like to use a script to detect all nouns and add a “noun” tag to them so that I can practice only the nouns of a deck, without resetting the delay before asking the card again.

I found several people suggesting using the Anki code directly. I’ve tried and read the code but it seems a bit hard for me to master just by reading without any documentation nor snippet examples.

Any ideas?
Thanks in advance.

There are two alternatives :

I tried the first approach but now I prefer the second one to keep track of the changes or the direct python method you mentioned.

I’m not aware of any real good documentation about this last solution, but you have some hints in the docs : Command-Line Use - Writing Anki Add-ons and The 'anki' Module - Writing Anki Add-ons. Maybe the best solution is to clone your current anki profile, open a python shell and to try to play with the API, starting with this:

from anki.collection import Collection
collection = Collection(ANKI_CLONED_PROFILE_PATH)

Now, you can discover how to use collection methods like collection.find_notes() :slight_smile:

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.