Feature request: endpoint to import items in BibTeX format
I have another request for a feature that's needed to make Zotero + zotxt usable as a citation processor for Org mode export. For Org users who prefer not to maintain their reference databases in Zotero, it isn't possible to use Zotero + zotxt as a citation processor unless they can load their reference data into Zotero during the export process. So, I'd like to request a /zotxt/import endpoint, to allow this. I think at the moment that accepting BibTeX data would be sufficient.
It seems like this would be pretty simple to add; here's a skeleton:
let importEndpoint = function (url, data, sendResponseCallback) {
let importedItems = [];
var translator = Zotero.loadTranslator("import");
// BibTeX is the only supported input format, for now:
translator.setTranslator('9cb70025-a888-4a29-a210-93ec52da40d4');
translator.setString(data.bibtex);
translator.setHandler('itemDone', function (t, item) {
item.complete();
// TODO: store the item's key and/or EasyKey in importedItems
// should maintain a mapping between input bibtex keys and Zotero key
// and/or EasyKeys here, if possible
};)
translator.setHandler('done', function () {
// TODO: send JSON response containing importedItems
};)
translator.setHandler('error', function () {
// TODO: better error message
sendResponseCallback(400, 'text/plain', 'Could not import some items');
};)
translator.translate();
};
What do you think?