how does Zotero locate the correct item from a BBT citekey using the zotero://select/items/ link?

edited January 10, 2022
The BBT hook into the `zotero://select/items/` functionality is incredibly useful. Thank you for implementing it.

Is there a way that I can use the Zotero API to get the item using the same citekey string (e.g. `somecitekey` from `zotero://select/items/@somecitekey`)?

I'd like to get an item's data using the javascript API from within the application, using the same citekey (which is generated by BBT).

I know that the citekey string isn't part of the `item` properties, but I thought there might be a way to use the same item resolving function that the `zotero://select/items/@somecitekey` link uses to find the item from within Zotero's API?

Thanks for the help
  • Which API do you mean? The online public API (zotero api v3), or something that can be queried locally? The former, no, not possible, the latter, sort of; search will also, but not exclusively, search for citekeys with BBT installed. I could consider adding Zotero's faceted search to the JSON-RPC API, which should allow searching for the citekey as a field (I think).
  • Hi emilianoeheyns —Thanks for being so generous with you time. I'm only referring to the local library. Adding faceted search to the JSON-RPC API is an interesting idea. But please don't bother doing it for this single-use, though.

    Ultimately I just want the citekey to be part of the item's data properties and I can wait (eagerly) for Zotero to add it as a proper field. I don't want to waste your time modifying things for a quick hack on my end.
  • Current search will find on citekey, and because citekeys are unlikely to show up elsewhere in the items, usually will search inky on citekey.

    If you want the citekey itself, an export in csl json will give you that. If you want more detailed information, BBT JSON will give you that. Exports can be grabbed via API too.
  • WRT the "how" question -- BBT monkey-patches the Zotero select-link handler to detect that a citekey is being passed and changes that in-place to the equivalent library+key. As far as Zotero knows, the select-link always had that library+key in the link.
  • edited December 26, 2021
    It's really great that you've managed to make that work-around work so flawlessly.

    Have you thought about exposing the citekey resolver (e.g. through the JSON-RPC API)? From reading the forms it seems like a number of people would appreciate the ability to programmatically translate between zotero id keys < - - > BBT citekeys.

    Again, it will be a moot point once Zotero introduces at citekey field for items, and I'm definitely not asking you to do anything on my account, but it would be great if there was an easy way to get the zotero id from a citekey, and the citekey from a zotero id.

    (I was considering making a tinny plugin to help me keep track of which papers I've made notes for in my markdown database, but ran aground in trying to locate the zotero item associated with the citekey in the MD note.)

    Thanks for the info, and so so much for making & maintaining BBT. (At the moment I'm particularly grateful for the the auto-updating bibtex exports -- it's such a useful feature.)
  • You can currently do this using item.export, which takes citekeys; if you export to BBT-JSON you also get the item key/library ID.
  • I'm know that the citekey string isn't part of the `item` properties
    @daeh: You could make it part of the Extra field. With BBT's autoPinDelay option, citation keys will automatically be written to the Extra field.
  • > You can currently do this using item.export, which takes citekeys; if you export to BBT-JSON you also get the item key/library ID.

    Thanks. That gives me what I need for a work around.
  • Appreciate the help. I got an alpha version running. (Finds files marked with citekeys in an external folder and adds a colored tag to the corresponding Zotero items )
Sign In or Register to comment.