Python with the Zotero API
Greetings,
I'm wondering if anyone knows of a Python tool kit for interacting with the locally hosted Zotero database.
I see this one https://github.com/urschrei/pyzotero. But it seems to be for interacting with the web API...
OR is the local and web APIs the same thing, only with a destination change...?
I'm wondering if anyone knows of a Python tool kit for interacting with the locally hosted Zotero database.
I see this one https://github.com/urschrei/pyzotero. But it seems to be for interacting with the web API...
OR is the local and web APIs the same thing, only with a destination change...?
It uses the debug bridge to run code locally. I've used it successfully to automatically import files from disk with links, tags, notes etc, but I haven't tried it over the last month and can't guarantee that nothing broke in the meantime.
@adamsmith: Is there hope to get a local API in the future?
The debug bridge already provides most of the functionality needed for a local API. Any chance it could become an official part of Zotero?
With a local API, a lot of things would become much easier:
- Custom importers for existing libraries (often asked here)
- Text mining, similarity search, extracting references from documents. The ML ecosystem is mostly Python-based, and it wouldn't make sense to run such tasks in a browser context anyway.
We have had a vague plan to try to expose a local HTTP API that mirrors the web API, so that tools could easily be programmed to work with either, but not sure when we'll be able to work on that.
The commands that I use are:
- create items with attachments, notes, tags, etc.
- used for importing documents into Zotero
- get item currently selected in Zotero.
- used to add a document with notes to existing items
- traverse Zotero library and get all files, links, notes for items.
I don't mind doing most of the processing in Python, but I fear that going through a debug interface might not be stable in the long run.
For example, I am not sure that it will still work after the switch to Electron.
The HTTP part is small by comparison, but that is where I had most of the difficulty when still using MozRepl. No issues with the debug bridge so far. It might be little code, but it is really the core component, so I would love if this approach was at least officially sanctioned including Electron.
Of course, a local API would be much better, but I understand that this is not a priority.
I will follow up and report.
(@dstillman, I was reluctantly looking at Bookends, I don't like it all on the desktop, but it works well enough on an ipad ... I have yet to try it in anger, I'd prefer to try and get something working on what I have using DTTG to ingest into DTP and on the desktop slurp it into Zotero and back into DTP in the right place.)
The library is pretty complete as far as creating items, notes and attachments etc., but there is still a lot of old code left from when I switched from MozRepl to the debug-bridge. I don't want to clean it up just to run into incompatibility issues.
Do you think it would be possible to create a minimal, stable, debug-bridge like functionality that was directly integrated in Zotero and that will remain stable when the switch to Electron happens?
This would make it very easy and less of a hack to create a local API in Python. I think there is a lot of potential for adding and processing items with notes, tags, and attachments, but also for running ML stuff on the database to find similar papers, add a citation graph etc. There are lots of libraries for analytics in Python, but currently there is no good way to connect them to Zotero.
see https://forums.zotero.org/discussion/87671/a-new-python-tool-kit-for-interacting-with-the-locally-hosted-zotero-database#latest
and https://github.com/sailist/pyzotero-local