Add Item by Identifier through API (pyzotero)

94 views
Skip to first unread message

Tyler K

unread,
Jun 25, 2019, 1:53:07 AM6/25/19
to zotero-dev
Hi. I'm part of an academic reading group discord server (Computational Sciences Reading Group). We're trying to make a bot that takes articles posted by members, and saves them to a publicly viewable Zotero group. Is there a way to use the API so that only a link is needed to complete the item metadata. This is possible using the desktop app, or web extension, but I haven't found anything in the docs to suggest how this might be done programatically.

Thanks

Dan Stillman

unread,
Jun 26, 2019, 3:29:58 AM6/26/19
to zoter...@googlegroups.com
There are currently two main ways to do this, one supported and one not.

Supported: Run an instance of translation-server [1] in Docker,
restarted daily (for now) to update translators. Send URLs at that
server, and then post the returned JSON to the Zotero API.

Unsupported: curl -d '{ "url": "https://example.com" }' -H
"Content-Type: application/json" https://api.zotero.org/users/1/items

In either case, you might get a 300 and will need to delete unwanted
results from the 'items' object and resend the JSON. (The format differs
slightly, but that shouldn't matter to you.)

The latter approach is currently undocumented, it could change in the
future, and we can't make any guarantees about it, but as long as you're
saving to your Zotero library you're welcome to use it. (It shouldn't be
used for generic translation to non-Zotero destinations. In those cases
we ask that people run their own translation-server.)

For manual web-based saving, https://www.zotero.org/save can also be
used, including with an optional 'q' query parameter.

We'll have some other options for online saving in the near future.

Note that, for all these methods, the results won't always be as good as
you'd get from the Zotero client, and won't include PDFs. An upcoming
Zotero version will provide a way of trying to update/improve metadata
after the fact, and you can use Find Available PDF(s) in Zotero to try
to retrieve PDFs for saved items.


[1] https://github.com/zotero/translation-server

Tyler K

unread,
Jun 26, 2019, 3:46:10 AM6/26/19
to zotero-dev
Thank you very much for such a comprehensive answer. We were afraid we'd have to run individual translator instances or something else similarly cumbersome. 

Regarding the Find Available PDFs, I'm assuming this has to be done through the Zotero client and not the API, correct? Is there a way to do this in batches, or would someone have to manually go through and use Find Available PDFs?  

Thanks again,
Tyler

Dan Stillman

unread,
Jun 26, 2019, 4:20:58 AM6/26/19
to zoter...@googlegroups.com
On 6/26/19 3:46 AM, Tyler K wrote:
> Regarding the Find Available PDFs, I'm assuming this has to be done
> through the Zotero client and not the API, correct? Is there a way to
> do this in batches, or would someone have to manually go through and
> use Find Available PDFs?

Yes, Find Available PDF is a client feature. A future version of online
saving might try to locate and attach OA PDFs, the same as the client,
but it would never be able to take advantage of subscription access the
way you can locally (direct/VPN for Find Available PDF or
direct/VPN/web-based-proxy for the Zotero Connector), so any online
saving is inherently somewhat provisional.

You can use Find Available PDFs in batches on multiple items, if that's
what you mean, so you could just periodically sort by Date Added in a
synced client. As noted above, Find Available PDF will work for OA PDFs
or for direct/VPN-based access, but it can't currently take advantage of
a web-based proxy.

There's also an open translation-server PR [1] to expose attachment
URLs. We haven't made a decision about that yet, but if you have a
server with direct access to gated resources, you could run a
translation-server build with that patch, try to download any PDFs
returned, and upload those to the API along with the item data.

[1] https://github.com/zotero/translation-server/pull/99
Reply all
Reply to author
Forward
0 new messages