CollectionID/CollectionKey

I'm sure this is Zotero 101, but can someone please tell me how to find my CollectionKey/CollectionID (they the same thing, right?). When I go to the folders in my library I see nothing that gives me a collectionkey.

My userID is clearly visible in the settings->api/feeds, but I'm not able to find anything that gives me different keys for each collection. Please help.
  • Better to post API questions to zotero-dev.
  • To answer your question, though, you can see the key in the URL on the website.
  • Thank you a lot Dan!!

    The API documentation seems to be missing this crucial information.
  • Not sure what you mean by that — the API basics page covers how to view your library data, which includes collection keys. The fact that you can see object keys on the website is somewhat tangential.
  • Hello! is there a way to get the collection key via a translator in zotero standalone or the only option is to copy the key from the collection the the browser?
  • The collection key is available to translators.
  • Hello @emilianoeheyns sorry to bother you but could you direct me to a translator that does so as an example to copy it?

    I tried to create an export translator using both group and library id as the var to retrieve the collection key without success. My goal is to be able to generate and URI to specific item in an specific collection in the new beta.

    https://forums.zotero.org/discussion/73893/zotero-select-for-collections#latest

    But my attempt at a translator below gave me an error when I tried to use it for export.

    The #a1# and such is to use it with the word macro to turn the generated uri into an hyperlink as shared here (originally for citations).

    https://forums.zotero.org/discussion/77079/ms-word-macro-to-convert-zotero-citations-into-clickable-hyperlinks

    function doExport() {
    var item;
    while(item = Zotero.nextItem()) {
    const title = item.itemType === 'note' ? Zotero.write(item.note.replace(/<[^>]*>/g, '').replace(/\n/g, ' ').split(/\s+/).slice(0,4).join(' ')+"#c1#"+"LINK"+"#c2#") : Zotero.write(item.title+"#c1#"+"LINK"+"#c2#")
    Zotero.write("#a1#"+"zotero://select/groups");
    var group_id = item.groupID ? item.groupID : 0;
    Zotero.write(group_id+"/collections/"+collection.key+"/items/"+item.key+"#a2#"+"\n");
    }
    }
  • https://github.com/retorquere/zotero-seektable-export/releases/tag/v0.0.17 gets the collections (and their keys), but it's entirely likely simpler ones exist at https://github.com/zotero/translators. You could grab a copy of that repo and grep for "nextCollection", that will give you the translators that get collection info.
  • @emilianoeheyns there are only two translators in the repo that use Zotero.nextCollection() (TEI.js and Zotero.RDF.js), and the repo you link to doesn't use it at all.

    I'm having the same problem -- nextCollection() doesn't seem to return anything for a given item.
  • @cohubicol: The Zutilo add-on provides a "Copy select collection link" function that copies links of the form zotero://select/library/collections/[collectionKey] to the clipboard, see here. (Note that the link format on this site needs to be corrected.)

    If you're looking for links to items within a collection, there's an open issue for it here: https://github.com/willsALMANJ/Zutilo/issues/105. You can create such links manually by combining the collection link with Zutilo's "Copy select item links", which return links of the form zotero://select/library/items/[itemKey]. A link to an item within a collection would have this form: zotero://select/library/collections/[collectionKey]/items/[itemKey].

    See also this discussion:
    https://forums.zotero.org/discussion/73893/zotero-select-for-collections

    If this is not what you're looking for, it might help to explain what you're trying to achieve.
  • edited May 21, 2020
    @qqbb that was actually me, posting from my group's account by mistake :)

    Basically what I'm trying to achieve is to get the names of the collections an item is in, for use in an export translator. Unfortunately I don't think it's possible because of the translator sandbox not having access to other collection-related methods (we have access to the IDs/keys, but AFAIK there's no way to derive the names from them). See https://forums.zotero.org/discussion/comment/356661/#Comment_356661
Sign In or Register to comment.