(DT3 Bibliography) Formatted reference from Custom MD

This could work like the download metadata smart rule. You’d set the bibkey on DT3 and it would get the data attached to this bibkey on Zotero.

If do this @retorquere I would be happy to adapt the AS to make it work.

P.S.: http://retorque.re/zotero-better-bibtex/citing/cayw/

Very interesting - honestly I have not tried that smart rule yet.

Let me give that a try tonight and get back to you.

Can you give me an example how you incoprporated that into a smart rule and how you activate it and what the output is?

@rkaplan if you just want the CSL-JSON for any given collection, this is already available:

  • make sure you have BBT installed
  • right-click the collection of interest and select “Show BibLaTeX Server URL” from the popup menu
  • copy one of the URLs in the dialog that now appears and change the .biblatex at the end into .csljson
  • paste that URL into your browser, or have DT fetch it, etc

That URL gives you the CSL-JSON for that collection you selected in step 1.

@Bernardo_V I could add a method to the existing JSON-RPC endpoint to fetch an item by its bibtex key. The curl equivalent call would look something like

curl -X POST --data-binary '{"jsonrpc": "2.0", "method": "item.fetch", "params": ["bibtexkey"]}'

if a web POST is hard to do, I could add a dedicated GET endpoint, but for POST I have all the plumbing in place.

edit: lookie here, me with the fancy URL-posting rights

Thanks - it may take me a few days to try out this and the smartrule option - I will give further thoughts after that

That’s cool. For anything that requires changes on the Zotero end of things I would need to invite you guys over to create an issue at https://github.com/retorquere/zotero-better-bibtex/issues; I have a workflow in place that can get you custom builds while we figure this out, but this workflow requires a github issue to work against.

1 Like

I have no ideia what all this means :upside_down_face:
What I need is a simple URL address to which I can attach the bibkey and get to the right JSON file. Is that possible?

Posting this on behalf of retorquere (who is limited in posts today as a new user by Discourse defaults)

It means

  • send an HTTP POST request (rather than the standard HTTP GET request)
  • to the URL,
  • and when connected send the text {"jsonrpc": "2.0", "method": "item.fetch", "params": ["bibtexkey"]}

But it looks like applescript can’t easily do POST (man applescript is one broken language :roll_eyes:) so I could instead offer something like<something>.csljson which would just return the csl-json form of the item (or anything else you’d want). I can get you something to test with on github – I can’t easily get custom builds to you otherwise.

man applescript is one broken language :roll_eyes:

I would strongly disagree with this.

That’s like saying a screwdriver is broken because it doesn’t effectively hammer nails. :stuck_out_tongue:

1 Like


OK I tried out the various suggestions and here are my thoughts:

(1) The Download Metadata smart rule basically tries to do what Zotero has mastered over many years, i.e. identifying DOI for a document. I am not sure it would be much help to reinvent that wheel

(2) Using BBT in Zotero to create a URL with JSON output from a Zotero collection is very nice. I like the idea of the various endpoints you suggest that could be created. As a first step to get what I think would be a working useful integration, would it be possible to modify the existing Pubmed search script (Data - New From Template-Search-PubMed) to paste the BBT-created URL as the “search” and then have the script create individual documents in DT3 just as the script does now for the search results?

(1) The Download Metadata smart rule basically tries to do what Zotero has mastered over many years, i.e. identifying DOI for a document. I am not sure it would be much help to reinvent that wheel

Many people are not running Zotero (or other apps you are referring to), so it’s not reinventing the wheel.


I did not mean to suggest that the smart rule is not useful.

What I meant is that for this project which we are discussing (integrating Zotero with DT3) I do not think the smart rule would be helpful as a building block.

Thanks to @rkaplan @retorquere and @Bernardo_V for continuing to work on the Zotero and DT integration question. Your technical knowledge quickly surpassed my own, so I’m watching how this develops with great interest.

As this post has evolved significantly since it was started, I just wanted to highlight some of the initial questions (not mutually exclusive) as I saw them:

  1. Following @Bernardo_V example could we get DT to handle some of the citation management and organization functions currently being done in other programs? Demonstrated more clearly here: https://discourse.devontechnologies.com/t/dt3-and-bibdesk/48765?u=cali310
  2. How can we better integrate DT and Zotero? How can we get Zotero data into DT efficiently without having to rely on exporting the database or drag-and-drop etc?

I’m out of my league here, but the Alfred workflow ZotHero pulls from the Zotero SQL database even when Zotero is open (I assume it caches the db info). The code for it is in github, so it might offer some of the plumbing that’s being discussed here: https://github.com/deanishe/zothero

Dean created ZotHero to fix an older broken workflow called ZotQuery, which had been created by a grad student who got in way over his head. You can read all about it here:


(I’m user dfay in that thread - I did a lot of testing etc. but in the end stuck with BibDesk, which is way easier to automate).

ZotHero seems like a nice workflow - thanks. But it appears to only select one citation at a time. Is there some way with ZotHero to choose a Zotero collection and then have it create a bibliography of all the citations in that collection?

I would say this is a question for the developer of ZotHero, unless you wanted to fork his repo.

Very nice solution now on Github

See here

@rkaplan Thank you for the followup on this. From your description it sounds like @retorquere has indeed developed a viable solution - one that many of us have been looking for. I am eager to experiment with it!


One point I did not clarify… the app does does directly interface with DT3 at all. It does however create a set of nested folders with .html files corresponding to Zotero records and folders corresponding to Zotero collections. The interface to DT3 is simply by indexing the top level of those folders. It works very well by that mechanism.

That’s actually brilliant, and easily replicable in BibDesk with a custom html output template.

Here’s an AppleScript that creates html, one file per publication, ready for import. As written it uses the default html template which isn’t ideal but easy to customise.

set loc to "/path/to/folder/"

tell application "BibDesk"
	set s to selection of document 1
	repeat with i in s
		export document 1 using template "Default HTML template" for i to POSIX file (loc & ((cite key of i) as string) & ".html")
	end repeat
end tell