Can you add words to the custom dictionary programatically

I have created an application to help analyse novels written in Libra writer.
One of the features is storing a character name which tend to be (fantasy) made up names.
It it possible to add these names programatically to the dictionary:
/home/{user name}/.config/libreoffice/4/user/wordbook/standard.dic

Are there any other references other than the standard.dic file that need to be considered?

You can add those names to the standard.dic file, where you add words that aren’t in the dictionary of the spell checker. But if you write or edit books with many personal (fantasy) names, that doesn’t seem to be a good idea. It’s better to make a new custom dictionary for each new book, and add the names and odd words there, so that you prevent that similar names from different books get mixed (up). What if a person is named Ganndalf in one book and another person is called Gandalf in another, and that you get both spellings in the same dictionary file? For instance, neither of these names gets underlined as I type them in Firefox.

Good idea - thanks.
I’ll create a new dictionary for each series (multiple books) so that I can keep some consistency.
When I archive the series/book, I’ll take a copy of the specific dictionary as well.