# Api to simplify addon writing

**URL:** <https://forums.ankiweb.net/t/api-to-simplify-addon-writing/12457>\
**Category:** Suggestions\
**Created:** [August 19, 2021, 3:44am UTC](https://forums.ankiweb.net/t/api-to-simplify-addon-writing/12457 "2021-08-19T03:44:48Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![xinyu](https://avatars.discourse-cdn.com/v4/letter/x/67e7ee/32.png) [@xinyu](https://forums.ankiweb.net/u/xinyu)\
**Post date:** [August 19, 2021, 3:44am UTC](https://forums.ankiweb.net/t/api-to-simplify-addon-writing/12457/1 "2021-08-19T03:44:48Z")

</div>

I am writing a addon to generate new cards from BIng Dictionary but I am not familiar with anki. I want a simple api to connect my code and anki so I find [ankiconnect](https://github.com/FooSoft/anki-connect).  
But the ankiconnect addon is in _self-serve mode_ and has some [bugs](https://github.com/FooSoft/anki-connect/issues/277).

I am thinking if it is possible to have some one or a group to create a similar api to help others to create their addons or even better add the api to anki itself.

Addons is a great way to make anki much more powerful. With the user group growing larger, I think making more addons is the best and maybe the only way to fit more people’s needs. Maybe addons can be as important to anki as extensions to Vscode and a easy to use and rubust api can really help.

---

<div class="post-metadata">

**Author:** ![malcolm](https://avatars.discourse-cdn.com/v4/letter/m/e19b73/32.png) [@malcolm](https://forums.ankiweb.net/u/malcolm)\
**Post date:** [August 19, 2021, 9:30am UTC](https://forums.ankiweb.net/t/api-to-simplify-addon-writing/12457/2 "2021-08-19T09:30:24Z")

</div>

I can’t help you with an API but I can tell you about my adventures with add ons.

I wanted an add on that didn’t exist to do some batch changes.

There were already two add ons that were close to what I wanted Note\_id and Batch\_id. Together with my new add on I got my files fixed.

Interestingly, I probably spent many more hours making the add on than I would have spent had I changed all my decks manually. But now if I ever have to do it again, I can do it relatively quickly…

I now also partially know QT5 (spit, stamp and burn, I don’t like QT5 ! ! ! )

I created a new add on by copying an existing add on in the anki directory to a new directory

C:\Users\mnmmc\AppData\Roaming\Anki2\addons21\somenumber to  
C:\Users\mnmmc\AppData\Roaming\Anki2\addons21\myspiffynewaddon

then change the meta.json file and you now have a new add on

then delete the original add on so you don’t have conflicts

restart Anki make sure it still works

I changed the dialogs and menu structure and got some bits from other add ons

I must admit I had a great deal of difficulty getting my dialog to work correctly but once you have one bit working and you understand what you did to make it work you just have to add more bits

Custom background gave me most of dialog bits and showed me how to do lambda functions to get stuff from my dialog to the program

Note\_id can show you how to populate fields when you create a new card

Batch\_edit can also show you how to change a bunch of cards in a deck

If you bring up the list of adds on and search for import, there are a bunch of add ons that import stuff so no end of code to look at there for importing your data.

I asked for some help to create the dialog and the following was suggested

A Qt tutorial may help: [PyQt/Tutorials - Python Wiki](https://wiki.python.org/moin/PyQt/Tutorials)

---

<div class="post-metadata">

**Author:** ![xinyu](https://avatars.discourse-cdn.com/v4/letter/x/67e7ee/32.png) [@xinyu](https://forums.ankiweb.net/u/xinyu)\
**Post date:** [August 19, 2021, 2:59pm UTC](https://forums.ankiweb.net/t/api-to-simplify-addon-writing/12457/3 "2021-08-19T14:59:57Z")

</div>

Thank you for sharing your experience. It is a good idea to check some similar addons. And I don’t like QT5 too! ! !

---

<div class="post-metadata">

**Author:** ![BlueGreenMagick](https://avatars.discourse-cdn.com/v4/letter/b/dc4da7/32.png) [@BlueGreenMagick](https://forums.ankiweb.net/u/BlueGreenMagick)\
**Post date:** [August 21, 2021, 5:07pm UTC](https://forums.ankiweb.net/t/api-to-simplify-addon-writing/12457/4 "2021-08-21T17:07:55Z")

</div>

Anki already does kind of have an api.  
[https://addon-docs.ankiweb.net/hooks-and-filters.html](https://addon-docs.ankiweb.net/hooks-and-filters.html)
