AnkiSharp 1.1.0 is out !

1.2.0 version is out, but you can still read this article because the use didn’t change a lot. Just, instead of initializing an AnkiItem like this :

AnkiItem item = new Item(FieldList, THE_VALUES);

You can do :

Anki test = new Anki();
var item = test.CreateAnkiItem(THE_VALUES);

Happy reading !

In the previous article, I explained the very first release of AnkiSharp and some of it’s features. However, the last version just got released and things changed a little bit.

For those who don’t know about AnkiSharp, It’s an open source C# library which aims to automatize the process of anki decks and cards creation. So if you are interested in creating an C# application for language learning, why not considering using it.

Using the library

First, you need to create an Anki object. In the new version, there are two way to do it. The old one :

Anki test = new Anki(_NAME_OF_APKG_FILE_);

and the new way which is:

Anki test = new Anki(_NAME_OF_APKG_FILE_, new ApkgFile(_PATH_TO_EXISTING_APKG_FILE_));

If you want to have more than two fields (the front and back) on your card, you can use the SetFields.

test.SetFields("English", "Spanish", "French");

Then, it’s time to add the value of your fields. If we keep the previous example with the three fields you could do something like:

test.AddItem("Hello", "Hola", "Bonjour");
test.AddItem("How are you?", "Como estas?", "Comment ca va?");
test.AddItem("Flower", "flor", "fleur");
test.AddItem("House", "Casa", "Maison");

If you want to add items without using the SetFields you will be able to do:

test.AddItem("Hello", "Bonjour");
test.AddItem("How are you ?", "Comment ca va ?");
test.AddItem("Flower", "fleur");
test.AddItem("House", "Maison");

You can add as much fields as you want, however be sure that the number of parameters is the same as the number of fields or you’ll experience a ArgumentException.

Finally, let’s create the apkg file to be able to import it in our Anki app.


But what’s so different?

If you read the previous you might notice that in terms of usage, the library didn’t change a lot and that’s true. But what’s important is the things you can’t see.

Avoid Redundancy

Now, when you are using the addItem function to add new words in your deck, we are checking if the very same element is not already inside. Furthermore if you want to be able to decide if you want to add a new element created or not in your deck, you could use the function ContainsItem.

Let’s say that you are analyzing a pdf file and that you are analyzing the most important words or the most used ones. You would like then to add the words you don’t know in the deck. You could just do :

AnkiItem item = new AnkiItem(test.Fields, "尊敬", "to respect");
if (test.ContainsItem(item) == false)

Data consistency

In the previous version, you could only create a new deck. Now you can start a new deck from a already existing one. It causes a problem, we need to keep the previous apkg’s data in the new Anki object before to create a new apkg. The new version provides that. So you could, let’s say, want to update your apkg file with new words. You could just do:

Anki test = new Anki(_NAME_OF_APKG_FILE, new ApkgFile(_PATH_TO_EXISTING_APKG_FILE_));
AnkiItem item = new AnkiItem(test.Fields, "尊敬", "to respect");
if (test.ContainsItem(item) == false)

And it would create a copy of the ancient anki file with the new word if it doesn’t exists in it.


The goal is really to provide you an easy tool to help you to review optimally without thinking too much about doing cards manually because it could be really tiring.

If you want to contribute to the library, check the github : You’re welcome to contribute on everything, even if it’s little improvements. Just enjoy!