Display Item Key

Is there no way to expose the unique item key (with or without library key) in the GUI (Standalone or add-on)?

I'm working on a website that will use the API calls to display citation information on pages. The pages are currently offline in a spreadsheet with a meta field "zotero_key" that I'm adding as I pull citations. These will be used to autogenerate the citation on the site.

Currently, to find that key, I need to wait for the web sync, then go to the item and copy it's id. Surely this is stored locally and could be coaxed out somehow?

Note - I've read up on what I can find here, with no success. It seems lots of people are wanting to change ID's. I just want to see what the ItemKey is so I can use it later with the API.
  • You can see the item key by generating a report from an item (at least in Zotero for Firefox - it's part of the URL in the address bar.)
    I know that's not super convenient, but in terms of currently available options I think that's the best there is.
    I'd think it would be possible to write a translator that can export the item key, but I don't think that's been done.
  • Thanks - I've cobbled together a workaround by including "key" in a custom export translator...

    Any clue as to where I could hack it in to, say, display the key in the report generated by standalone? (Is there a translator for the standard Zotero "generate report"?)

    Of course, the ultimate would be to include the key as an un-editable field in the Info tab of an item. It is available, why not let us see it?

    Thanks for the awesome work.
  • Addendum: Is there any way to pull the ID through a .csl style filter? That would also be slick - but I can't seem to find what it is called (or if it is available.)
  • no, the id is not mapped to/available as a CSL variable.
  • @ Driftless

    Do you mind sharing your custom export filter?

    I want to be able to reference documents from the zotero database in other applications and documents, that an easy key would be handy.

    Thanks
    Florian
  • edited August 8, 2012
    Hi Florian - its a hack-a-thon for a specific need, so wouldn't be much use. But in simplest form:

    function doExport() {
    var item;
    while(item = Zotero.nextItem()) {
    Zotero.write(item.key + " - " + item.title + "\n");
    }
    }
  • Just came across this:

    https://gist.github.com/3134386

    Very nice.
  • And you'll want to set that as your quickcopy export format to just drag-and-drop the keys.
  • Brilliant @ajlyon! Didn't know that feature... you just saved me collective hours.
  • Have there been any updates to this issue? Seems like a vital feature. I've just been exporting to csv to get the item keys.
  • not sure why it's vital -- I think the situations in which users need access to the key are quite rare, but I put together a tranlator that'll export the item uri (which includes the key). Description & instructions here:
    https://zoteromusings.wordpress.com/2013/04/23/zotero-item-uris-from-client/
  • @adamsmith Thanks a lot! Ok, maybe not 'vital' but handy for API users, especially to new Zotero users like me. My use case is similar to the OP. After the initial population of Zotero info in a database we will use bibliographic info for developers to select a citation rather than a zotero_key.
  • There seems to be a persistent minority that needs access to the Zotero item key. The following allows to extract the item key from the local SQlite database (some knowledge about running Python language required):
    https://marutschke.eu/extract-zotero-item-key-from-local-sqlite-database-using-python/
  • edited December 9, 2020
    @moritzmarutschke:

    1) For what it's worth, this can be done much more easily in the Run JavaScript window.

    2) If you're going to do it directly on the DB from outside, the proper way to do it would be by joining the `items` table with other tables (`itemCreators`, `creators`, `itemData`, `fields`), not using `syncCache`, which is, as the name suggests, a cache for syncing, not the canonical source for the data. That table won't necessarily reflect current data and won't even be populated if people aren't using syncing.

    3) If you're going to use `syncCache`, you certainly don't want to be parsing it with a regex. I'm not sure why you even include that option in your post. It's a JSON string — it should be parsed as JSON.
  • @dstillman

    Thank you for your feedback. No objections here.
    This was meant as an additional approach. I will implement 2) when time allows.
    Explanation and disclaimer for 3) are given in the text.
  • edited December 9, 2020
    Explanation and disclaimer for 3) are given in the text.
    I'm not sure what you mean by that — my point is just that there's no reason to publish an example like that and encourage anyone exploring the Zotero database to use that method for parsing JSON. It's just objectively wrong, and you have a better method on the page. You should remove it.
  • @dstillman

    Thank you again. I see that it could be misunderstood. I spelled it out more clearly and removed the coding sections in question.
Sign In or Register to comment.