The genanki package most likely has everything you’ll need. The documentation is short and concise.
For illustration, I’ve copied a simple program I use to create a dynamic cloze deck in Python - I’ve made some comments for an easier start.
Starting out, you’ll probably want to store your note type (HTML_front, HTML_back, CSS) in separate files, then read them into your script:
# Get note html and css
with open('card-type/styling.css', 'r') as file:
styling = file.read()
with open('card-type/front.html', 'r', encoding='utf-8') as file:
front = file.read()
with open('card-type/back.html', 'r', encoding='utf-8') as file:
back = file.read()
# Create cloze note type
note_type = genanki.Model(
1607892320, 'Notetype name',
model_type=genanki.Model.CLOZE,
fields=[{'name': field} for field in fieldnames], # fieldnames is a list of strings you define beforehand
templates=[ # html from template folder
{
'name': 'Cloze-Card',
'qfmt': front,
'afmt': back,
},
],
css = styling, # css from template folder
)
# Create deck
deck = genanki.Deck(2059499999, 'Your Deck Name')
# Custom GUID - set first field as unique identifier
class MyNote(genanki.Note):
@property
def guid(self):
return genanki.guid_for(self.fields[0])
# You'll most likely have some kind of loop to create the notes for the deck
for i in range(x):
my_note = MyNote(
model=note_type, # created above
fields= ['actual', 'field', 'values', '{{c1::with}}', 'clozes', 'or', 'without']
tags = ['list', 'of', 'tags']
)
# Add note to deck - move on
deck.add_note(my_note)
# Write deck to anipackage file
genanki.Package(deck).write_to_file('outfile.apkg')
I cannot offer any mentoring right now, but if you have any further questions I’ll do my best to help.