Constructing web-library URLs from web-API responses

60 views
Skip to first unread message

Emiliano Heyns

unread,
Oct 14, 2024, 5:37:10 PM10/14/24
to zotero-dev
I want to direct-link to attachments in my web library. How are these URLs constructed? I see that one looks like https://www.zotero.org/emilianoeheyns/items/<item key>/attachment/<attachment key>/reader and another like https://www.zotero.org/emilianoeheyns/collections/<collection key>/items/<item key>/attachment/<attachment key>/reader. I'm somewhat surprised by these -- the item key nor the collection key seem required to find the attachment, and the item can be in multiple collections.

Tomasz Najdek

unread,
Oct 15, 2024, 5:19:05 AM10/15/24
to zoter...@googlegroups.com
The URL in the web library contains all the details needed to bring you back to the exact location, so if you copy it and open it in another tab, you will see the same collection selected, and on a mobile device, the same view should open.

That being said, if you don't need these details, you can construct the URL as:
`<libraryPrefix>/items/<itemKey>`. The web library will detect that the item in question is an attachment and will internally redirect to a URL containing both the selected item and the selected attachment, with no collection selected. If you add `/reader` at the end of the URL, it will open the attachment in the reader view, in which case no redirection occurs because the parent item's key is irrelevant.
On Monday, 14 October 2024 at 23:37, Emiliano Heyns <emilian...@iris-advies.com> wrote:
I want to direct-link to attachments in my web library. How are these URLs constructed? I see that one looks like https://www.zotero.org/emilianoeheyns/items/<item key>/attachment/<attachment key>/reader and another like https://www.zotero.org/emilianoeheyns/collections/<collection key>/items/<item key>/attachment/<attachment key>/reader. I'm somewhat surprised by these -- the item key nor the collection key seem required to find the attachment, and the item can be in multiple collections.

--
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/73718c71-0cfe-4a0c-8883-e40fe2c4712cn%40googlegroups.com.

Emiliano Heyns

unread,
Oct 16, 2024, 6:10:08 PM10/16/24
to zotero-dev
Can I get the library prefix if I have an API key?
Reply all
Reply to author
Forward
0 new messages