Skip to main content
This page lists all available hooks in Anki. It is generated from pylib/tools/genhooks.py and qt/tools/genhooks_gui.py. See Hooks & Filters for usage instructions.

Backend Hooks (anki.hooks)

card_odue_was_invalid

No arguments. No docstring.

schema_will_change

Args: proceed: bool
Returns: bool
No docstring.

notes_will_be_deleted

Args: col: anki.collection.Collection, ids: Sequence[anki.notes.NoteId] No docstring.

note_will_be_added

Args: col: anki.collection.Collection, note: anki.notes.Note, deck_id: anki.decks.DeckId Allows modifying a note before it’s added to the collection. This hook may be called both when users use the Add screen, and when add-ons like AnkiConnect add notes. It is not called when importing. If you wish to alter the Add screen, use gui_hooks.add_cards_will_add_note instead.

media_files_did_export

Args: count: int Only used by legacy .apkg exporter. Will be deprecated in the future.

legacy_export_progress

Args: progress: str Temporary hook used in transition to new import/export code.

exporters_list_created

Args: exporters: list[tuple[str, Any]] No docstring.

media_file_filter

Args: txt: str
Returns: str
Allows manipulating the file path that media will be read from

field_filter

Args: field_text: str, field_name: str, filter_name: str, ctx: anki.template.TemplateRenderContext
Returns: str
Allows you to define custom {{filters:..}} Your add-on can check filter_name to decide whether it should modify field_text or not before returning it.

note_will_flush

Args: note: Note Allow to change a note before it is added/updated in the database.

card_will_flush

Args: card: Card Allow to change a card before it is added/updated in the database.

card_did_render

Args: output: anki.template.TemplateRenderOutput, ctx: anki.template.TemplateRenderContext Can modify the resulting text after rendering completes.

importing_importers

Args: importers: list[tuple[str, Any]] Allows updating the list of importers. The resulting list is not saved and should be changed each time the filter is called. NOTE: Updates to the import/export code are expected in the coming months, and this hook may be replaced with another solution at that time. Tracked on https://github.com/ankitects/anki/issues/1018

deck_added (Obsolete)

Args: deck: anki.decks.DeckDict
Obsolete, do not use.

note_type_added (Obsolete)

Args: notetype: anki.models.NotetypeDict
Obsolete, do not use.

sync_stage_did_change (Obsolete)

Args: stage: str
Obsolete, do not use.

sync_progress_did_change (Obsolete)

Args: msg: str
Obsolete, do not use.