How to add attachment to currently selected item?

133 views
Skip to first unread message

Michael Hucka

unread,
Feb 15, 2024, 10:25:08 AM2/15/24
to zoter...@googlegroups.com
Suppose that I have an item selected in my Zotero application running on macOS. From outside of the Zotero application, can I attach a file to the item using an API endpoint of some kind? If so, what is the API (or the API options) and where can I find out more?

Here's an example for more context. Better BibTeX listens on a port and allows some operations over a network API, and I've been using this to get data about Zotero entries. The API is convenient because I can write a small script (e.g., in AppleScript or shell) that uses HTTPS calls to perform operations. However, BBT doesn't seem to offer a way to attach something (unless I've missed it?). So, I'm looking for something that might work roughly like using the BBT API, except that I want to send files.

The closest I've been able to find is that it could be done using PyZotero. That would work (and I use PyZotero for other things), but here I'm looking for a more direct approach, if there is one.

My apologies if I've missed something obvious or past discussions. I did search first, but failed to find an answer.

Best regards,
MH
--
Mike Hucka, Ph.D. (he/him/his)
mhu...@caltech.edu -- http://www.cds.caltech.edu/~mhucka
California Institute of Technology

Dan Stillman

unread,
Feb 16, 2024, 3:58:24 PM2/16/24
to zoter...@googlegroups.com
On 2/15/24 9:44 AM, Michael Hucka wrote:
> Suppose that I have an item selected in my Zotero application running on macOS. From outside of the Zotero application, can I attach a file to the item using an API endpoint of some kind? If so, what is the API (or the API options) and where can I find out more?
>
> Here's an example for more context. Better BibTeX listens on a port and allows some operations over a network API, and I've been using this to get data about Zotero entries. The API is convenient because I can write a small script (e.g., in AppleScript or shell) that uses HTTPS calls to perform operations. However, BBT doesn't seem to offer a way to attach something (unless I've missed it?). So, I'm looking for something that might work roughly like using the BBT API, except that I want to send files.

There's no built-in way at the moment, but I think BBT allows you to run
arbitrary JavaScript, and it's trivial to do this with Zotero's internal
API, so you could just pass a path and have Zotero add the file. Look
for ZoteroPane.getSelectedItems() and Zotero.Attachments.importFromFile().

Michael Hucka

unread,
Feb 20, 2024, 4:37:45 PM2/20/24
to zoter...@googlegroups.com
Hi,

Thanks for the tips!

Best regards,
MH
> --
> You received this message because you are subscribed to the Google Groups "zotero-dev" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to zotero-dev+...@googlegroups.com.
> To view this discussion on the web visit https://groups.google.com/d/msgid/zotero-dev/0100018db3b6874f-fb88fed9-462a-4497-b459-168fdac54b57-000000%40email.amazonses.com.
Reply all
Reply to author
Forward
0 new messages