urschrei / pyzotero

Pyzotero: a Python client for the Zotero API
https://pyzotero.readthedocs.org
Other
908 stars 99 forks source link

Are new Zotero beta notes and annotations (not saved in the PDF) retrievable in Pyzotero? #148

Open e-alizadeh opened 2 years ago

urschrei commented 2 years ago

This is really a question for the Zotero Web API maintainers: I'm not aware of any Web API methods that allow retrieval of the annotations. The google group is probably the best place to ask: https://groups.google.com/g/zotero-dev

If there are methods available, I'll add them to Pyzotero.

e-alizadeh commented 2 years ago

Thanks for your quick reply. I further looked at this issue. Zotero beta stores annotations and highlights in their database as opposed to saving them in the PDF files itself. These new annotations are available in Zotero's new PDF editor.

As per following discussion (https://forums.zotero.org/discussion/90753/zotero-beta-integration-with-external-note-taking-tools), web API access to all annotations made in the new PDF editor is available even now. However, annotations aren't yet documented in the web API docs, even though Zotero itself syncs them via the API as a new item type.

Thanks again

urschrei commented 2 years ago

Yep, this is the tracking issue: https://github.com/zotero/dataserver/issues/113.

In the mean time, retrieving annotations using items(itemType='annotation') for an initial dump (which you could dump to JSON along with the library version), and then items(itemType='annotation, since=library_version) to get updates is a bit convoluted, but will work: retrieved annotations have a parentItem key in data that you can use for matching. You then also have to rebuild the annotation images from the raw data (easy in case of rects, more complicated for freehand shapes)…

e-alizadeh commented 2 years ago

How can I retrieve all annotations? Calling items(itemType="annotation") returns 100 items only. Even passing limit with a higher number than 100 still returns 100 annotations. When calling count_items(), I can see that the number increases when I'm adding a new annotations, and I can see the new annotation when calling items(itemType="annotation") as first items. However, I'm not able to retrieve older annotations to start with!!

urschrei commented 2 years ago

Have you tried wrapping the call in Zotero.everything() as per the docs?

https://pyzotero.readthedocs.io/en/latest/#zotero.Zotero.everything

You can also try to build up a list of lists of annotations using one of the generator methods at

https://pyzotero.readthedocs.io/en/latest/#the-follow-and-everything-methods

And then flatten it.

-- steph

On 19 Dec 2021, at 19:28, Essi Alizadeh @.***> wrote:

 How can I retrieve all annotations? Calling items(itemType="annotation") returns 100 items only. Even passing limit with a higher number than 100 still returns 100 annotations. When calling count_items(), I can see that the number increases when I'm adding a new annotations, and I can see the annotation when calling items(itemType="annotation"). However, I'm not able to retrieve older annotations to start with!!

— Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you commented.

e-alizadeh commented 2 years ago

Thanks a lot. all_annotations = zot.everything(zot.items(itemType="annotation")) seems to return all annotations as you suggested. I was not using everything() func properly before.